Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

132 Neutral

About belgreth

  • Rank
  1. Hm, writing to a MemoryStream then sending that off sounds like a solution, thanks hplus. As far as world data, it's split into cells and players can change most aspects of it so I have to save everything, at least the active cells. You bring up a good point about item duplication...but I'm not at that hurdle yet. My server/client is small scale (think minecraft). It's aimed for 2-8+ people to play together in a persistent world. I'm trying to stay away from having to deal with databases like mySQL as I'm mostly illiterate in that area. If I can just keep everything saved in binary, that would be ideal.
  2. I'm not too sure how to go about this. I'd like to have the server save the game world and client data every so often but how would I do this while server is running and clients are connected to the server? Currently everything is saved in binary which I hope to keep doing. The world file + clients is roughly 160mb currently. I'd rather try to spin off a thread to slowly save everything instead of stopping everything for a few seconds for it to do its thing, however I'm not sure if that's the best way or how I can do this without adding locks around every code that changes client/world data. Any tips?
  3. belgreth

    Issue with scissorrectangle

    I don't believe so. Isn't that what SpriteSortMode.Deferred means? No z sorting, just draw everything on top of each other in draw call order? Plus I'm not specifying a depth when drawing any element i.e. [source lang="csharp"]sb.Draw(mapBiomeColorTexture, mapRect, new Color(1, 1, 1, 0.2f)); [/source]
  4. I'm stumped on how to fix this issue. I draw the map using a scissor rect during spriteBatch and later I draw my paperdoll however the scissor rect for the map is cutting off the paperdoll model somehow. Here's an example of it: http://imageshack.us...2/scissor1.jpg/ http://imageshack.us...3/scissor2.jpg/ I'm drawing part of the map via: [source lang="csharp"]sb.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.None, scissorRS); scissorRect.X = mapElementRect.X; scissorRect.Y = mapElementRect.Y; scissorRect.Width = mapElementRect.Width; scissorRect.Height = mapElementRect.Height; // Make sure rect doesn't go out of bounds of screen if (scissorRect.X + scissorRect.Width > screenWidth - 1) scissorRect.Width = screenWidth - scissorRect.X; if (scissorRect.Y + scissorRect.Height > screenHeight - 1) scissorRect.Height = screenHeight - scissorRect.Y; sb.GraphicsDevice.ScissorRectangle = scissorRect;[/source] The paperdoll is drawn after the map. I believe it has to do with depth as setting device.DepthStencilState to none draws the model fully but of course it's inside out at that point. However I set depth to none when drawing the map. Any ideas? EDIT : Ok I feel silly. After combing my code for the past two hours there was one line when drawing the map outline that was setting DepthStencilState to Default during spritebatch.Begin() that I kept missing. Case closed!
  5. I decided to put the received message processing back into the main thread. I am unsure why I originally had a separate thread that only processed incoming messages from the server. I'm also unsure what I was thinking when I put the whole draw call into the lock when I could've just held the lock long enough to copy the world variable into a temp matrix and then call draw... I already have 2 threads for networking, one that only listens, and stuffs the packet into a list and immediately goes back to listening and another thread that just decodes the packets into messages. My locks for those things seem to be working as I haven't had any race conditions or out of index errors yet. In fact there's no need for the second thread as well, I can stuff that into the main thread too. I agree, keeping it simple is best. I am not aware of polling so I'll definitely be looking into that. Thanks for the reply rip-off. EDIT: Well after putting the message processor in the main thread I was still having the same issue so apparently the locks weren't the problem to begin with! The direction wasn't getting normalized for the player when calling unitContainer.otherPlayers[index].Direction.Normalize(); It works when I did: unitContainer.otherplayers[index].Direction = Vector3.Normalize(unitContainer.otherplayers[index].Direction); If anyone has any idea why the first one didn't work I'd love to know.
  6. I was fairly sure I had my locks correct until I had my network thread update the direction of players during state changes. So whenever players turn they get distorted for a bit when changing directions. My setup is briefly as follows: [source lang="csharp"]public class UnitContainer { public static readonly object OtherPlayersLocker = new object(); // i tried non-static as well List<Player> otherPlayers; // ... }[/source] I pass the unitContainer to all the classes that contain threads so they can access the player list and any time a thread accesses and/or modifies player data they call the lock (such as) [source lang="csharp"]lock (UnitContainer.OtherPlayersLocker) { unitContainer.otherPlayers[index].Direction = msg.messageList.direction; unitContainer.otherPlayers[index].Direction.Normalize(); }[/source] The problem goes away when I normalize the direction before setting it to the otherplayer. But regardless, the way I have it set up, it shouldn't matter if I do or not. My guess is either the Draw call is drawing while the world variable is being updated, or the world variable is being updated after direction was set but before it was normalized. However if everything is in that lock (including draw call)..how are the two threads modifying/accessing the player data at the same time?
  7. belgreth

    In-game map techniques?

    Thanks for the replies jeffery, that might actually fit my needs. I dont need elevation, more symbolic than anything topographic-wise. I'll try generating a low rez version of the world and use an orthographic camera and see how that works out. This'll even let me do some lighting so it's not plain looking.
  8. belgreth

    In-game map techniques?

    Hm, that won't work for viewing the whole world (as it would be too much to draw) however I do like that idea for a local 'radar' type map *adds to todo list*. I'm looking for a decent looking full world map that can be zoomed and scrolled around and possibly have highlightable icons on it. The icons and zooming/scrolling I can figure out, I just need something that isn't plain and boring to look at.
  9. I'm having difficulty searching for any sort of tutorial for drawing interactive in-game maps as any search with "map" usually comes up with terrain and game level stuff. As the game world is procedurally generated I can't pre-fab maps so they'll have to be created during world generation. Currently I just have a boring biome map being generated but I'm hoping for something with more pizzazz. http://www.imageshack.us/photo/my-images/254/biomemap.png/ (Tried to make an image link but didn't seem to work) Eventually other markers such as towns and forts would need to be drawn on the map as well. The map will start out with a fog-of-war and will fill in as the player moves around in the world. Does anyone know of any popular techniques/shaders for drawing in-game maps?
  10. belgreth

    Using both TCP and UDP?

    Thanks for the responses guys, I'll just stick with UDP only then and keep it simple. hplus, your answer is great but it also makes me go "Now why didn't I think of that!?", especially considering the terrain generation is still on the client side as I was testing it there to get it all working first... ugh ! samoth - I guess I was first looking for an easier answer to trying to send all that data instead of creating a way to handle breaking the cells into parts and getting them all to the receiver and reassembling them. Thus my first thought was TCP since I can just pack the cell in one large array, stream it and let TCP handle the breaking and re-assembly and at receiving end just expect a certain size. Plus that's good advice about players hanging close together, I'll be keeping that in mind. Thanks again everyone.
  11. To learn both protocols I had recently made two server/client models each using the UPD/TCP to practice interpolating movement and chat message packet handling. Now that I understand both protocols more I'm curious how best to go about my actual game server architecture. The server generates the world procedurally and will need to send large chunks of data: when a player first logs in, or when a player moves to a new cell and needs that cell's height for vertices, and static models, etc. (Cells will be saved on client's computer once downloaded) While making the two test server/clients I came to really like UDP more however I can't just stuff 80k+ worth of data into a single packet and I need reliablity for the packets. So I figured instead of trying to implement a layer over UDP to make sure I get several packets' worth of data for a single cell, I could use TCP for those packets and just stream the data. However, I prefer UDP for movement and other details that are time sensitive so my question is - Can't I just use two separate ports, one for TCP traffic and one for UDP traffic? Have the client send requests for cell data on TCP port, and clients/server communicate over UDP for position, action responses, etc? Is there some none-obvious hurdles I might come across?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!