Code structure

Code structure

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
Muon
Posts: 24
Joined: 23 Jan 2012, 21:42

Code structure

Post by Muon » 05 Feb 2013, 04:03

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:
  • 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?
0 x

SirMaverick
Posts: 834
Joined: 19 May 2009, 21:10

Re: Code structure

Post by SirMaverick » 05 Feb 2013, 13:16

Muon wrote:I've been wading around in the code for some time now, and I honestly don't understand much of it.
It's complex (450000 lines of code). It takes time.
[*]Where does the world get updated?
I assume "world == all stuff you see: units, features, map etc.".
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!
0 x

Muon
Posts: 24
Joined: 23 Jan 2012, 21:42

Re: Code structure

Post by Muon » 09 Feb 2013, 01:24

Thanks! :-) That was very informative.
0 x

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10239
Joined: 24 Jan 2006, 21:12

Re: Code structure

Post by PicassoCT » 09 Feb 2013, 18:05

indeed
0 x

User avatar
MelKor
Posts: 38
Joined: 15 Oct 2010, 16:05

Re: Code structure

Post by MelKor » 17 Feb 2013, 06:44

This explanation should be in wiki, srsly.

MelKor
0 x

User avatar
smoth
Posts: 22300
Joined: 13 Jan 2005, 00:46

Re: Code structure

Post by smoth » 17 Feb 2013, 08:17

MelKor wrote:This explanation should be in wiki, srsly.
then put it in there.

-Smoth

oh and my name is on the left of this post also.
0 x

Post Reply

Return to “Engine”

cron