This won’t make much sense to anyone except people familiar with my code... But I've been thinking about writing a real-time game network library lately, and came up with this on my way home...
- Variables will be wrapped in classes. CReplicatedVar is the base class.
- Data types will derive from this, including CReplicatedFloat, CReplicatedBool, CReplicatedInt.
- More complex data types like CReplicatedVector and CReplicatedMatrix will derive off the primitive replicant.
- The class initializer should specify update frequency in terms of server frames. This allows us to effectively express network update frequency as a percentage of total throughput.
- When it is created it will register itself with the network engine. The network engine will update each variable with each server update.
- The network engine is responsible for keeping the last X server snapshots, enough to derive an effective interpolation and/or extrapolation of the variable’s value. Some variables are on/off and do not require interpolation.
- Each variable has a Get(float time) action, which will get the interpolated value of the variable given what the network engine knows.
- Note to the above: This also means we need some way to cache server snapshots so that we’re not constantly doing array lookups and interpolating, a rolling array index may be a better way to do it.
Some thoughts on game code:
- Each entity will have a FrameThink() and Think() function. These are used exclusively by the server and will not execute in plain client mode.
- Each entity in addition will have a ClientFrameThink() and ClientThink() function. These are used exclusively by the client.
- It is expected that the vast majority of functionality, particularly gameplay-specific functions, be implemented server side only.
- The Render() function is strictly client-side, as the server has no rendering capability.
- Meshes and other preloads that are loaded at OnLoad() are still loaded server side, as their geometry or data may be used in the entity’s thinking.