Death and Resurrection

When the player is shot to bits his die function of the edict_t is called. In this case, it points at player_die in p_client.c. Basically, it sets the player to be nonsolid when touching other objects, clears the inventory and tells the player to look at the killer. If this is an ordinary game it all ends here. The player has to restart somehow and reconnect to the server.

If it is a cooperative game or a deathmatch, the player has an option to respawn by pressing the attack button. In this case, ClientBeginServerFrame calls respawn in p_client.c. It is actually in respawn that the decision is taken whether to restart the game or just respawn the player.

The player places a copy of its edict's information in a global dead body queue. This body queue is a circular queue in the g_edicts array. It is situated just above the clients in the array. Remember that the first maxclients entities were reserved for clients. Perhaps this body queue is used to let bodies lie around on the ground whereas the player is actually resurecting in its old body.

After placing a copy of the body in the dead body queue, the DLL calls PutClientInServer with the dead edict_t as argument. This means that the player will be respawned somewhere in the game, still using the same edict_t.