Breaking up the GAME module
I came accross the idea of allowing networked gameplay over LAN in VDrift. I am new to the code base, so I looked it up, and as far as I could gather, most of the event loop runs in GAME module. I gathered that the dynamics.update(GetTimeStep()) call does all the physics heavy-lifting, and most of the rest deals with user interaction.
In order to implement network support, I'd like to start off by breaking up the GAME module into two modules - SERVER and CLIENT, where CLIENT does most of the user interaction handling, and passes the control inputs to the SERVER over a UDP socket (or some other way, if it is on the same computer). So there would be multiple CLIENT threads running, one for the human player and others for the AI. In case of a networked game, CLIENTs would run on all the computers. The SERVER takes input commands for all CLIENTs, and does the physics heavy-lifting.
Since I'm a novice to the source code, any suggestions or criticism is welcome. Please comment on the idea.
|