From 387f59e2cb9ab6291ba193eeb56990d964d45ba8 Mon Sep 17 00:00:00 2001 From: Richard Helgeby Date: Sun, 22 Mar 2015 18:52:31 +0100 Subject: [PATCH] Simplify pre-check logic in ZTeleClient. --- src/zr/ztele.inc | 51 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/zr/ztele.inc b/src/zr/ztele.inc index 9d68a8f..84bd52b 100644 --- a/src/zr/ztele.inc +++ b/src/zr/ztele.inc @@ -129,30 +129,6 @@ bool:ZTeleClient(client, bool:force = false) return false; } - new bool:infected = InfectIsClientInfected(client); - - if (!force && ZTeleMustBeHuman(client)) - { - // Tell client they must be human to use this feature. - TranslationPrintToChat(client, "Must be human"); - return false; - } - - if (!force && !infected && !ZTeleCanHumanTeleport()) - { - // Tell client that feature is restricted at this time. - TranslationPrintToChat(client, "ZTele restricted human"); - return false; - } - - if (!force && ZTeleHasReachedLimit(client)) - { - // Tell client that they have already reached their limit. - int maxTeleports = ZTeleGetClientLimit(client); - TranslationPrintToChat(client, "ZTele max", maxTeleports); - return false; - } - // If teleport is already in progress, then stop. if (tZTele[client] != INVALID_HANDLE) { @@ -164,15 +140,38 @@ bool:ZTeleClient(client, bool:force = false) return false; } - // If we are forcing, then teleport now and stop. if (force) { - // Teleport client to spawn. + // Forcing teleport. ZTeleTeleportClient(client); + // Skip everything else. return true; } + if (ZTeleMustBeHuman(client)) + { + // Tell client they must be human to use this feature. + TranslationPrintToChat(client, "Must be human"); + return false; + } + + new bool:infected = InfectIsClientInfected(client); + if (!infected && !ZTeleCanHumanTeleport()) + { + // Tell client that feature is restricted at this time. + TranslationPrintToChat(client, "ZTele restricted human"); + return false; + } + + if (ZTeleHasReachedLimit(client)) + { + // Tell client that they have already reached their limit. + int maxTeleports = ZTeleGetClientLimit(client); + TranslationPrintToChat(client, "ZTele max", maxTeleports); + return false; + } + // Get current location. GetClientAbsOrigin(client, g_vecZTeleOrigin[client]);