Game initialization
Jump to navigation
Jump to search
The 'ignition circuit' of every Source game and mod is the file traditonally named <game>_client.cpp
. It contains several scopeless functions (i.e. not in a class) that are called when server.dll is loaded, when the world spawns, when a player connects, and so on. For obvious reasons there can only be one game_client.cpp in a project!
Todo: Why is this file called "client" when it's on the server, and what is the client equivalent?
Client.cpp functions
Various console commands etc. that are processed on the server but only affect one player. Changing player model, saying things, god mode...
The code is shared between all games and mods, so don't put anything game-specific in here!
Game_client.cpp functions
The functions in _client.cpp are apparently called from within the engine, and as such must always be the same.
void ClientPutInServer()
void ClientActive()
- Called when a player connects and activates respectively. These functions define the C++ class used for players.
void respawn()
- Called by
ClientKill()
andDeadThink()
whenever a player dies. Spawns ragdolls in multiplayer, reloads the last saved game in singleplayer. const char* GetGameDescription()
- Returns the descriptive name of the .dll (e.g. Half-Life or Team Fortress 2).
CBaseEntity* FindEntity()
- Called when the !picker targetname is invoked.
void ClientGamePrecache()
- Precache function for the player. Todo: Why not use
CBasePlayer::Precache()
? void GameStartFrame()
- The very first function to be called when a new (server) frame starts?
void InstallGameRules()
- Decides which GameRules to use. Use
CreateGameRulesObject( string ClassName )
to do this.