Network!


More on the network. There will be two type of servers after all, but they weren't how I originally outlined. Basically, there is a "gameserver" which is essentially a remote database that does some basic coordination between all the players but other than that is pretty simple and low-CPU-usage, and then there is a "localserver"

localserver runs on each players machine, and accepts connections from other players. So two players that are in the same system will be connected to each other's localservers. On the most simple level, the localserver provides updates about where each player is in the system, each frame. One level above that, the localserver also coordinates enemies and other objects (e.g., weapons fire, NPC craft, what have you) so that players can cooperate further. Each localserver basically broadcasts "what is happening on this machine locally" so that other clients can make an effort to synchronize.

The gameserver itself seems to run quite nicely. I had problems with CPU, and also some other basic problems with network code, which I think is now worked out. I was getting major framerate problems with vex engine when it was connected to the gameserver, which I naturally (i.e., incorrectly) assumed was due to some kind of network blocking, and/or the process getting put to sleep. Such wasn't the case; instead, the gameserver was getting trapped in an infinite loop and sucking up CPU, and what I was seeing in stuttering framerate was actually linux being clever and scheduling things as best as it could.

It's tricky coding two programs at once, that interact, becuase it's easy to miss an obvious problem in one program or another becuase you are so focused on the hard stuff of making them interact.

At any rate, the gameserver now seems to work great! I am going to code more and more on that today, and probably also start the localserver code. I want to get it set up so that two clients can start to coordinate together today, perhaps by printing a message when they warp together into the same system.

2004-04-26


◀ Back