by Chacal » Mon Aug 01, 2011 10:13 am
Yes, and all this is well-known, time-proven server design concepts. I'm sure there are even books about it.
What I know about it comes from endless discussions on game server admin forums, a few years ago when I was running a couple of dozens of BF42 and BF2 commercial servers.
The way other game servers such as BF42 do this is:
- server and clients maintain a data structure with all avatar positions, speed, angle, etc;
- the client sends its current action (either keypresses, current speed, angle, etc) to the server;
- the server calculates the client avatar's new position and updates its data structure;
- once in a while, the server's world update process sends this data structure to all clients;
- the client updates its own datastructure (position, speed, etc of all avatars including its own) accordingly.
The idea here is that clients tell the server what they are trying to do, but the server itself descides the outcome (calculates new positions and does collision detection). All clients accept the server's decision.
This usually leads to some rubber-banding because clients use client-side prediction.
BTW, you often mention "memory" by opposition to database. You don't need to, as all game servers and clients work with data structures residing in memory (the "world"), and will only serialize (write to disk) such data structures that need to be persistent across sessions. This serialization is usually done by a separate process, and it uses caching, so it doesn't have an impact on other processes. The real-time game server process usually doesn't even know which data structures are serialized and which aren't.
Unless the game is badly designed, that is. During MOUL, the only dynamic things in the City that were serialized were cone positions. The City was horribly lagging until Cyan removed the cones. My guess is they were serialized on the clients, which caused massive lag for most players.
Chacal
"The weak can never forgive. Forgiveness is an attribute of the strong."
-- Mahatma Gandhi