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?
  12. Hello everyone! I've run into a big problem and had no idea how bad it was until I started tackling the GC. I have my terrain in chunks and I load in new chunks as the player walks around in another thread. During the loading, and I've narrowed it down to when using binaryreader, I see massive amounts of boxing. This causes the GC to be called about 16 times in a row. This problem only exists on the XBOX and when testing it on my PC, my PC and CLR profiler doesn't show any problems. My google fu has failed me as I can't find much anyone else talking about using binaryreader with xbox. I tried using xml earlier in the development but the files ended up being huge. I have to really crunch the data down so it'll all fit. Anyone got any ideas or leads? Appreciate your time! (Btw, pic of remote performer during the 3-5 seconds when loading data, and a link to a portion of my loading method if anyone is curious) http://pastebin.com/cTUvaUA8
  13. Hi everyone, I have all my game data in binary format and as the player moves around the world, the game will load in chunks for the terrain. Now, the loading is in a separate thread but the game can stutter due to the garbage collector being called numerous times while I'm loading in the new data. The gc is apparently being called when I do : [font="Courier New"]using (FileStream inFile = File.Open(filename, FileMode.Open, FileAccess.Read)) { using (BinaryReader br = new BinaryReader(inFile))[/font] { etc. } } I've located all other instances of when the gc is being called and got rid of all but 2 of them and when I'm not crossing chunks gc is only called around every 15 - 20 seconds. Is there a way to load the data when needed without having the gc called? I'd love to just have everything loaded during the whole game but I believe the terrain data alone will exceed the xbox's memory eventually.
  14. I think I got it! My character's face no longer has cracks in it. You're correct, I didn't have to touch the original positions of my terrain. In case anyone was curious, all I did was: Create view matrix with position zero instead of absolute position so camera is zero point. Then when drawing my terrain/models, i created a transform by Matrix.CreateTranslation(Vector3.Zero - camera_abs_pos); and passed that along to the shader as the world. That was a lot easier than I was anticipating. Thanks for your help Nexuskill!
  15. Wow thanks for the replies guys! Radikalism - I have the terrain scaled by 5 so I guess that'd be 5units for 1 meter? I'm really trying to figure out how to scale everything that works best. Each terrain chunk has a coord with coord 0,0 being at the 0,0xz absolute position. I only stay in the positive quadrant just to make data managment easier. So I was putting my character in an arbitrary far bottom right corner to see how things worked. Currently, I just take my character's absolute position, figure out which coord the character is in, that ends up being the center chunk and i draw 8 chunks around that chunk. Everything is in absolute positions. braincell - That chart is pretty awesome. I did notice pushing the near plane up to 6 or 7 really helped the z-fighting but at that point, my camera would start clipping through the terrain and I could see through the terrain. I guess I could increase the distance the camera could get to the ground but it already seemed big enough. (Camera freely rotated around the player's character) nexuxskill - I think that's what I was trying to figure out how to do. You are right on how I set up each chunk's vertices. Instead of using the center of each chunk, could I use the upper left (0) vertex of each chunk? (The vertices aren't stored in a 2d array, just a single array) I'm having trouble mentally figuring how to set this up. Currently the vertex positions are in absolute. I would need to instead just set their positions to "local" position based on the upper left vertex? Which would make the position for vertices in every chunk the same actually. So then, if I'm correct so far, I need to determine the transformation matrix for each chunk based on that chunk's 0,0 position to the camera's position? I'm using XNA so would that be something like: Matrix transform = Matrix.CreateTranslation(chunk's_upper_left_abs_pos - camera_abs_pos); And when sending the "World" effect parameter just send that transform instead of Matrix.Identity ? Would that be correct? Again, thanks for the replies guys, gave me some mental food to munch on.
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!