Starting the Game

Everything starts by exchanging the game import and the game export API. You can find the GetGameAPI function in g_main.c.

Next, the engine will call InitGame though the API. You can find this function in g_save.c. A lot of global variables, shared between engine and dll, are set up. InitGame also pre-allocates space for all edict_t entities and all eventual gclient_t structures. The number of entities in these is specified by the engine and can be configured when starting the server.

After calling InitGame, the engine will call SpawnEntities. Here, all entities are parsed off the game PAK file. Depending on skill level, some entities are spawned while others are not. Some entities are also linked together as teams. Presumably, the flyers are linked as teams. A call to PlayerTrail_Init makes sure that the trail produced by the client is initialized (see 3 How the Player Works).