From f35d8cb38150c6c604413359f5748976030bfab8 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Tue, 21 Apr 2009 03:10:14 +0200 Subject: [PATCH] Fixed memory leak, fixed disconnect bug. --- src/zr/event.inc | 1 + src/zr/roundend.inc | 3 +++ src/zr/zombie.inc | 34 ++++++++++++++++++++++++---------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/zr/event.inc b/src/zr/event.inc index f6a92ba..c067b85 100644 --- a/src/zr/event.inc +++ b/src/zr/event.inc @@ -262,6 +262,7 @@ public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) RespawnOnClientDeath(index, attacker, weapon); ZHPOnClientDeath(index); + // Terminate round if round is over. new RoundEndOutcome:outcome; if (RoundEndGetRoundStatus(outcome)) { diff --git a/src/zr/roundend.inc b/src/zr/roundend.inc index feb66ce..51b50ae 100644 --- a/src/zr/roundend.inc +++ b/src/zr/roundend.inc @@ -377,6 +377,9 @@ RoundEndBalanceTeams(bool:spawn = false) // Respawn client. CS_RespawnPlayer(client); } + + // Destroy handle. + CloseHandle(arrayEligibleClients); } /** diff --git a/src/zr/zombie.inc b/src/zr/zombie.inc index 364b38f..5296db0 100644 --- a/src/zr/zombie.inc +++ b/src/zr/zombie.inc @@ -398,33 +398,47 @@ JumpBoost(client, Float:distance, Float:height) */ PlayerLeft(client) { + // If zombie hasn't spawned, then stop. + if (!g_bZombieSpawned) + { + return; + } + // If client is dead, then stop. if (!IsPlayerAlive(client)) { return; } - // If client isn't a zombie, then stop. - if (!IsPlayerZombie(client)) - { - return; - } + // Get zombie flag on client. + new zombieclient = IsPlayerZombie(client); // Initialize count variables new zombiecount; new humancount; - // Count valid clients. (true to only allow living clients) + // Count valid clients. ZRCountValidClients(zombiecount, humancount); - // If there are other zombies besides the disconnecting player, then stop. - if (zombiecount - 1) + // If client is a human, and is the last one, then terminate round. + if (IsPlayerHuman(client) && humancount <= 1) { + // If there are no more clients in the server, then stop. + if (!ZRTeamHasClients(CS_TEAM_T)) + { + return; + } + + // Manually terminate round. + RoundEndTerminateRound(ZombiesWin); + return; } - // If there is 1 or no humans left, then stop. - if (humancount <= 1) + // We know here that player is a zombie. + + // If there are other zombies (ignoring this zombie), then stop. + if (zombiecount - 1) { return; }