Move sphere redistribution to its own function

This commit is contained in:
LJ Sonic 2022-12-29 21:28:53 +01:00
parent 2b2797ec66
commit dc39957539

View file

@ -2316,30 +2316,16 @@ static void UnlinkPlayerFromNode(INT32 playernum)
}
}
//
// CL_RemovePlayer
//
// Removes a player from the current game
//
void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
{
// Sanity check: exceptional cases (i.e. c-fails) can cause multiple
// kick commands to be issued for the same player.
if (!playeringame[playernum])
return;
if (server)
UnlinkPlayerFromNode(playernum);
if (gametyperules & GTR_TEAMFLAGS)
P_PlayerFlagBurst(&players[playernum], false); // Don't take the flag with you!
// If in a special stage, redistribute the player's spheres across
// the remaining players.
if (G_IsSpecialStage(gamemap))
// If in a special stage, redistribute the player's
// spheres across the remaining players.
// I feel like this shouldn't even be in this file at all, but well.
static void RedistributeSpecialStageSpheres(INT32 playernum)
{
INT32 i, count, sincrement, spheres, rincrement, rings;
if (!G_IsSpecialStage(gamemap))
return;
for (i = 0, count = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
@ -2385,6 +2371,26 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
}
}
//
// CL_RemovePlayer
//
// Removes a player from the current game
//
void CL_RemovePlayer(INT32 playernum, kickreason_t reason)
{
// Sanity check: exceptional cases (i.e. c-fails) can cause multiple
// kick commands to be issued for the same player.
if (!playeringame[playernum])
return;
if (server)
UnlinkPlayerFromNode(playernum);
if (gametyperules & GTR_TEAMFLAGS)
P_PlayerFlagBurst(&players[playernum], false); // Don't take the flag with you!
RedistributeSpecialStageSpheres(playernum);
LUA_HookPlayerQuit(&players[playernum], reason); // Lua hook for player quitting
// don't look through someone's view who isn't there