The last few days I've been doing major work on the multiplayer aspects of the game. The more packets I added to the game, the more delayed everything would get...On my LAN I was only sending 15-25 packets a second, and eventually the game would get delayed 1-2 seconds.
I had no idea what was going on...so I went through and optimized everything...wrote some crucial prediction/interpolation algorithms to blend the states of all of the actors in the world over the network, so I only had to send a few packets a second. At the same time I was optimizing the bandwidth down to the bit.
All of this optimization wasn't fixing anything, I kept working on other parts of the game. Later I noticed the code where I handle packets (client side) was NOT inside a while loop...so the client was handling only 1 packet per frame, which was causing the delays. The game logic/networking is not updated more than 30 times a second.
Once I fixed that, and changed some parameters in RakNet (the UDP netowrking library I'm using)...everything works like a charm, and all the optimizing I did earlier really just pushed it over the edge.
Everything runs 1000x better now. In my haste I must have forgotten to add the while loop. I was doing everything fine server side at least.
Anyways, that was the only barrier I was hitting, now that's out of the way...I can get trucking on other parts of the game.
The weird part is that the game was actually playable over the LAN/Internet with my client only handling 1 packet per frame.
I've still got to add some kind of post processing glow effect into the game, as well as a particle system for sparks, blood, shell casings, debris, etc.
I'm also still playing around with the user interface as well. I'm going to have a series of boxes stacked on eachother in the bottom right corner of the screen, for things like inventory, health, orders, wanted level, etc.
All else is going well...the game is starting to shape up, I'm a happy camper now that multiplayer is lookin' good [grin]
- Dan
A screenshot from my testing earlier:
![](http://www.radioactive-software.com/gangwar/newpics/fender_truck.jpg)
But wouldn't you want to have a seperate listener thread for incoming packets? Set up a producer-consumer system that the main loop can then pop entries off?
Or is that what you've done with this while loop you mention?
Jack