- 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?
Code structure
Moderator: Moderators
Code structure
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:
-
- Posts: 834
- Joined: 19 May 2009, 21:10
Re: Code structure
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!
Re: Code structure
indeed
Re: Code structure
This explanation should be in wiki, srsly.
MelKor
MelKor
Re: Code structure
then put it in there.MelKor wrote:This explanation should be in wiki, srsly.
-Smoth
oh and my name is on the left of this post also.