Evil Bug -> The Random Destructor
This one had me baffled. Since the results that were produced from this bug were pretty much random (very much like memory corruption bugs) it was exceedingly hard to track down. I ended up having to output all packet reading information and actually count up all of the bytes going in and out manually to figure out:
the server-out instance of PACKET_SWITCHWEAPON was sending out 2 bytes and the client was trying to read 3. Whoops. I forgot that clients don't need to send Player ID data to the server (server can figure it out based on address/port/socket), but the server needs to send Player ID data to clients. Thus the clients would all read one extra byte, rendering all of the remaining data in the packet (sometimes up to 100+ bytes) with essentially 'corrupt'/'garbage' data. This made for some very strange client-side occurances ingame. Things like non-existant players joining, weird garbage text/messageboxes, and in one case players spontaneously dieing. Very disturbing.
But now it's fixed, so all is now well.
Movement Prediction Revamp
This was the other issue that was getting on my nerves. It seemed that a lot of the time I'd land several consecutive hits in a row on another player, and it wouldn't deal any damage. This was obviously because the player is not in the location that my client is predicting he is. This is evident in many online games where you need to 'lead' the target to make hits, by firing bullets ahead of a moving player to where he will be in a moment. I don't like that at all, so I knew today was the day I'd start debugging movement prediction.
The first thing I did was rig up a temporary 'ghost' player to move around my local client with simulated ping. So basically what I'd see is both my local player and what the server would be see at a packet-update rate of 250ms. Wow; what I saw shocked me. On average, the player's true location was about 30 pixels off. That makes a big difference when you're fighting someone who is moving around.
So my solution was a (vaguely speaking) combination of forcing more powerful smoothening (none of that light nudging business :P) and more accurate guessing of where the player will be by the time the next update arrives.
Right now it's working beautifully on my simulation, but I still need to have it factor in the client's lag. Tonight's test should be a good one. My goal of having a bug-free quasi-large-scale test might be realized! :D
Oh, and I was so happy I celebrated by adding an automatic shotgun. I'm sure the testers will like that. [grin]