Spring Engine Code: Difference between revisions

From Spring
Jump to navigationJump to search
Spring engine code walkthrough
 
No edit summary
Line 1: Line 1:
To get people somewhat started into the mass of spring engine code, here is a small "walkthrough" of the game process:
To get people somewhat started into the mass of spring engine code, here is a small "walkthrough" of the game process.
Another good way of learning the code is building it in debug mode, setting a breakpoint at some place, and running spring. When it breaks on that point you'll be able to see full call stack which is very educational.


# Application entry point (lesson2.cpp)
# Application entry point (lesson2.cpp)
## Window is created
## Window is created
## VFS is initialized (ArchiveScanner.cpp)
## VFS is initialized (VFSHandler.cpp)
## Game setup:
## Game setup:
### if there is a start script (like script.txt) this is used to initialize the global gameSetup (in GameSetup.cpp)
### if there is a start script (like script.txt) this is used to initialize the global gameSetup (in GameSetup.cpp)
## Game loop starts
### CPreGame is created
### [[Spring_Engine_Code|Drawing]]
#### if it's a client: CPreGame either waits for a start script.txt i
### [[Spring_Engine_Code|Game Update]]
#### if it's a server: CPreGame uses the given start script (if one) or shows the list of startup CScript classes such as Commanders or Global AI
 
### CGame is created
==Drawing==
#### CGame::CGame() will load all game data such as the map, unit models, textures, features
 
## Main window message loop starts
### [[Spring_Engine_Code | Drawing]]
### [[Spring_Engine_Code | Game_Update]]


==Game Update==
==Game Update==
# update the networking, and when a message for a new frame arrives start update the game. This might seem weird, but because all game simulations have to be synced, it should run the game further until the server is ready.
## unit handler update
## feature update
## projectile handler update
## ...

Revision as of 16:26, 8 November 2005

To get people somewhat started into the mass of spring engine code, here is a small "walkthrough" of the game process. Another good way of learning the code is building it in debug mode, setting a breakpoint at some place, and running spring. When it breaks on that point you'll be able to see full call stack which is very educational.

  1. Application entry point (lesson2.cpp)
    1. Window is created
    2. VFS is initialized (VFSHandler.cpp)
    3. Game setup:
      1. if there is a start script (like script.txt) this is used to initialize the global gameSetup (in GameSetup.cpp)
      2. CPreGame is created
        1. if it's a client: CPreGame either waits for a start script.txt i
        2. if it's a server: CPreGame uses the given start script (if one) or shows the list of startup CScript classes such as Commanders or Global AI
      3. CGame is created
        1. CGame::CGame() will load all game data such as the map, unit models, textures, features
    4. Main window message loop starts
      1. Drawing
      2. Game_Update

Game Update

  1. update the networking, and when a message for a new frame arrives start update the game. This might seem weird, but because all game simulations have to be synced, it should run the game further until the server is ready.
    1. unit handler update
    2. feature update
    3. projectile handler update
    4. ...