Omega Race (C++, Networked)
DePaul’s Real-Time Networking course taught me about data-driven architecture, game state management, and many other concepts that go into creating networked games with a client/server model.
Omega Race was given to us in a non-data-driven, non-networked form. Our final project tasked us with converting the game to use data-driven architecture, and add networking code to the game.
The focal point of Omega Race is what happens under the hood.
-
At the beginning of each frame, both game clients process a queue of outgoing and incoming messages which keep track of the game state. Data such as player position, missile-firing or mine-laying commands, detected collisions and more are all communicated through a single, centralized pair queues for input and output.
-
In order to maintain one centralized game state, the server is the only place where physics calculations and collision detection are processed. While the clients appear to be doing these operations as well, they are simply mimicking the game state on the server. For example, if a player movement input is read on a client, that input is sent to the server, who does the movement calculation (a relative movement). The server then simply sends a message to both clients to set the position of the player to match (an absolute positional adjustment).
-
In the real world, network conditions are never ideal. Prediction algorithms help keep the experience smooth and responsive while waiting for messages from the server. These prediction algorithms come in two flavors: Client-Side, and Dead Reckoning. The former involves the client using past data from the server to predict player position and rotation, without any extra work on the part of the server. The latter, however, sees both the client and the server doing these predictions, so that the server only needs to send updated position and rotation data when it knows the client’s prediction will be outside an acceptable margin of error. The benefit here is that fewer messages are sent over the network, reducing congestion and allowing for better reliability in the delivery method.