- Where does the world get updated?
- How is rendering done, and what is responsible for it?
- What is exposed to Lua?
- How stable is the Lua interface?
- Why are there so many globals?
- Why do so many files include GlobalRendering.h?
Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.
6 posts • Page 1 of 1
I've been wading around in the code for some time now, and I honestly don't understand much of it. I'd really like to actually do something useful! So, here are my initial questions:
It's complex (450000 lines of code). It takes time.Muon wrote:I've been wading around in the code for some time now, and I honestly don't understand much of it.
I assume "world == all stuff you see: units, features, map etc.".[*]Where does the world get updated?
Let's follow the code! The main function is in rts/System/Main.*, which starts an instance of SpringApp (rts/System/SpringApp.*) and runs SpringApp::Run(). After Initialization etc. it runs a loop where it calls UpdateSim() (internally calls activeController->Update()) and activeController->Draw().
The activeController (base class CGameController) is an abstraction of the interface. There are several types: e.g. PreGame, LoadScreen and Game. Once the game is loaded and running CGame (rts/Game/Game.*) is the activeController.
So each controller has an Update and Draw function. The Update function updates the game state. The Draw function will update the graphics.
CGame::Update() reads the network input. As the simulation is synced, updates will only be done on input that is send from the server.
Once the server sends a NEWFRAME message CGame::SimFrame() is called, where you can see a long list of stuff that gets updated (map, units, features, wind, los, teams, players etc.).
Follow the code further to see more details!