![]() |
Breaking up the GAME module - Printable Version +- Forums (https://www.vdrift.net/Forum) +-- Forum: Project (https://www.vdrift.net/Forum/forumdisplay.php?fid=4) +--- Forum: Development (https://www.vdrift.net/Forum/forumdisplay.php?fid=9) +--- Thread: Breaking up the GAME module (/showthread.php?tid=1663) |
Breaking up the GAME module - wyuka - 09-24-2012 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. RE: Breaking up the GAME module - NaN - 09-24-2012 The client server concept is good even for non networked application. The idea is to move the simulation into a separate thread anyway. The issue you will have to deal with is latency. But then it is a racing sim not a FPS. I'd say go ahead and see how it works out. Btw there is StuntRally https://github.com/stuntrally which is based on VDrift and has network/LAN support. They are using prediction/correction and run the simulation on clients and correct the velocity/position. I haven't really looked into their code, not sure how they deal with the latency when calculating the state correction. |