saints row iv · how the game works

How Saints Row IV Works

The game's life cycle in order: start-up, menus, loading, and what happens every frame.

How the Game Works19 rows

The game's life from double-click to quit. Each step names the function where it happens.

StepWhat happensKey functionAddressNotes
Start-up
1Windows starts the exe; the C runtime sets up and calls WinMain.WinMain007250a0
2Reads the command line, creates the 'dumps' and 'mods' folders next to the exe, turns off the screensaver.init_mods_dir00722a60The mods folder is real 2017 mod support - see Files & Mods.
3Creates the window ('Saints Row IV') and the Direct3D 11 graphics device. If that fails you get 'Failed to create graphics device'.game_create_window_and_device00722f50Also registers where files are searched for, mods folder first.
4Registers the BOOT game state and enters it.gamestate_register00865f20The whole game is a stack of states - see Game States.
5BOOT: reserves memory pools, mounts the core packfiles, starts a small loading-screen render thread, loads all data tables (animation, gameplay constants, effects...).game_init_callback / boot_load_game_data00724d70 / 00723bd0Memory sizes: see Memory Budgets.
6Starts the worker threads (rendering, file loading, audio, job scheduler).thread_create010c1a10See Threads.
The main loop (runs until you quit)
7Handle Windows messages (keyboard, focus, close button).platform_pump_messages010befe0
8Run one frame: input, the current game state's update, audio, UI, network, then apply any queued state changes (e.g. menu -> loading).game_frame_tick00724f40Returns 'quit' when the state stack reaches QUIT (10).
9Meanwhile the render thread draws the previous frame: shadows, lighting, effects, UI, then presents it.render_thread_main00729ce0See Rendering.
Going from the menu into the city
10MAIN_MENU state shows the menu and handles save selection.gs_main_menu_enter008ca950
11CITY_LOAD state loads the city on its own thread while a loading screen plays.gs_city_load_enter008c8d20Also starts Havok's physics job threads.
12IN_GAME state: the world simulates every frame - humans, cars, AI, physics, Lua mission scripts, HUD.gs_in_game_enter00861f70
13Streaming: as you move, nearby city zones and assets load in the background and far ones unload.stream2_container_create010dd670Files are read by the 'hdd thread', unpacked by the 'mem thread'.
Inside one in-game frame (simplified)
14Each AI character picks what to do: goals are checked in priority order, and each goal's actions are tried until one succeeds.ai_select_action00532300See AI tab.
15Damage of any kind (bullets, explosions, powers, scripts) goes through one function that lowers health and handles death.human_take_damage00adeb60Health is at human+0x1E20.
16Mission logic runs as Lua scripts that call ~1,900 engine commands.lua_gameplay_vm_init00bbd970See Lua Commands.
17In co-op, changes are sent to the other player as small compressed messages.net_register_msg009a85d098 message types.
Saving and quitting
18Saves are written only to Steam Cloud on a background thread.gamesave_platform_write_begin00d93540Files: sr4save_N.sr4s_pc + savedir.sr3d_pc.
19Quitting pushes the QUIT state; the loop ends and every system shuts down in reverse order.game_shutdown_all_states00866ff0

Built from SR4_Game_Explained.xlsx (650 KB), if you'd rather filter it in Excel. SaintsRowIV.exe v1.0.6.1 (Steam). Names are ours unless they're Volition's own Lua or C++ class names.