Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • SRB2 SRB2
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Hannu Hanhi
  • SRB2SRB2
  • Wiki
  • SRB2 documentation drafts and notes

Last edited by Hannu Hanhi Nov 22, 2020
Page history

SRB2 documentation drafts and notes

Main loop

Main loop (in D_SRB2Loop) consists of parts:

  • Game logic: TryRunTics
  • Graphics: D_Display
    • Has special case for frozen netplay, which allows for moving the camera in that situation without running game logic
    • Screenshot and movie mode handling happens after drawing, based on flags set somewhere earlier
  • Sounds: S_UpdateSounds
  • LUA GC: LUA_Step

Calls:

  • TryRunTics
    • COM_BufTicker
    • D_MapChange
    • G_Ticker
      • G_CopyTiccmd
      • P_Ticker
        • P_RunThinkers (also called twice in P_LoadLevel by P_PreTicker)
      • various other tickers
  • D_Display

TryRunTics

  • Runs a number of game logic tics depending on current time.
    • If other code (like rendering) has taken too long, multiple tics can be run to compensate and keep the speed of the game consistent.

Calls:

  • COM_BufTicker
    • pending console command execution
  • D_MapChange
  • NetUpdate
  • GetPackets
  • G_Ticker
  • ExtraDataTicker
    • netxcmd stuff

G_Ticker

  • Runs one tic of game logic.

Calls:

  • G_DoReborn (respawn)
  • tickers for various game states (in level, intermission, cutscene etc.)
  • in level:
    • P_Ticker
    • ST_Ticker
      • title card logic
    • F_TextPromptTicker
    • AM_Ticker
      • automap logic
    • HU_Ticker
      • hud logic (not much)

NetUpdate

  • Input handling and some network functions.
  • when game is running fast enough, it will get run inside TryRunTics?
  • when game is running slowly, it will also get run in various other places scattered in the code
    • not faster than 35 times in a second though

Calls:

  • Local_Maketic
    • I_OsPolling
    • D_ProcessEvents
      • responders
    • G_BuildTiccmd
      • LUAh_PlayerCmd
      • LUAh_ViewpointSwitch (reset back to self when moving)
  • GetPackets
  • CL_SendClientCmd
  • other network stuff
  • M_Ticker
  • CON_Ticker

P_Ticker

  • Handles game world.
  • Runs player thinking.
  • Runs all thinkers.
  • Code for various other fixed game logic parts.
  • Lua ThinkFrame.

P_RunThinkers

  • Runs functions specified in the thinkers.
  • Multiple thinker lists for separate purposes.
    • polyobjects
    • main
      • things that move or do stuff but are not mobjs or polyobjects
    • mobjs
      • P_MobjThinker
    • dynamic slopes
    • precipitation
      • most precip logic is moved to rendering code with culling, but the current implementation still relies on some code running for every precip thinker

P_MobjThinker

  • Thinker function for all mobjs. Run for every mobj by P_RunThinkers, except for those with nothink.
  • Various checks and switch statements for the different mobj types in the game.
  • Mobj states and actions.
  • Movement physics.
    • XY movement
    • Z movement
  • Scenery gets a separate similar but somewhat simpler code path.
Clone repository
  • Main loop
  • OpenGL Backend
  • OpenGL Shader Changes
  • SRB2 Shader Guide
  • SRB2 documentation drafts and notes
  • Home