From e2e15972e252e9c71a8c35e0b3d2c4fc5b4c999e Mon Sep 17 00:00:00 2001 From: BotoX Date: Sat, 5 Dec 2020 20:15:28 +0100 Subject: [PATCH] Fix mother zombie infection cycle not saving picked alternative candidates at end of cycle. --- src/zr/infect.inc | 68 ++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/src/zr/infect.inc b/src/zr/infect.inc index 83dc761..e5be2f4 100644 --- a/src/zr/infect.inc +++ b/src/zr/infect.inc @@ -594,47 +594,43 @@ public Action:InfectMotherZombie(Handle:timer) RemoveFromArray(aCandidatesMain, i); candidatesMain--; } - - // Infect one of the alternate candidates. - else if (candidatesAlt) - { - // Get a random array index. - new i = Math_GetRandomInt(0, candidatesAlt - 1); - - // Get the client stored in the random array index. - new client = GetArrayCell(aCandidatesAlt, i); - - // Infect player. - if (InfectHumanToZombie(client, _, true)) - infected++; - - // Remove player from eligible client list. - RemoveFromArray(aCandidatesAlt, i); - candidatesAlt--; - - // Enable the cycle reset. - resetcycle = true; - } - - // We have no candidates at all, abort! else { - // Enable the cycle reset. - resetcycle = true; - break; + // No main candidates, reset the mother zombie cycle now before infecting anyone else. + if (!resetcycle) + { + resetcycle = true; + // Clear mother zombie round-robin cycle storage. + SteamidCacheReset(g_hInfectMotherCycle); + + // Announce start of new cycle + TranslationPrintToChatAll(true, false, "Mother zombie infect cycle reset"); + } + + // Infect one of the alternate candidates. + if (candidatesAlt) + { + // Get a random array index. + new i = Math_GetRandomInt(0, candidatesAlt - 1); + + // Get the client stored in the random array index. + new client = GetArrayCell(aCandidatesAlt, i); + + // Infect player. + if (InfectHumanToZombie(client, _, true)) + infected++; + + // Remove player from eligible client list. + RemoveFromArray(aCandidatesAlt, i); + candidatesAlt--; + } + else // We have no candidates at all, abort! + { + break; + } } } - if (resetcycle) - { - // Restart the cycle. - // Clear mother zombie round-robin cycle storage. - SteamidCacheReset(g_hInfectMotherCycle); - - // Announce start of new cycle - TranslationPrintToChatAll(true, false, "Mother zombie infect cycle reset"); - } - // Mother zombies have been infected. g_bZombieSpawned = true;