From ff7528f09fb44438d73f118be1f88692cc41b1b6 Mon Sep 17 00:00:00 2001 From: Greyscale Date: Sun, 21 Jun 2009 14:59:18 -0700 Subject: [PATCH] OMG FINALLY FIXED OVERLAYZ. I almost killed myself over this one. --- src/zr/overlays.inc | 10 +++- src/zr/playerclasses/classevents.inc | 6 --- src/zr/playerclasses/clientoverlays.inc | 61 ++++++------------------- src/zr/roundend.inc | 22 +++------ 4 files changed, 28 insertions(+), 71 deletions(-) diff --git a/src/zr/overlays.inc b/src/zr/overlays.inc index d7860e2..bbeaf21 100644 --- a/src/zr/overlays.inc +++ b/src/zr/overlays.inc @@ -210,7 +210,7 @@ OverlaysClientUpdateOverlay(client, OverlaysChannel:channel = OVERLAYS_CHANNEL_N } // Display overlay to client. - ClientCommand(client, "r_screenoverlay %s", g_strOverlayPath[client][channel]); + ClientCommand(client, "r_screenoverlay \"%s\"", g_strOverlayPath[client][channel]); } OverlaysChannel:OverlaysClientFindChannel(client) @@ -239,7 +239,7 @@ OverlaysChannel:OverlaysClientFindChannel(client) * @param update (Optional) Update the overlay when this function is called. * @param toggle (Optional) Set to true to toggle state, false to use value param. * @param value (Optional) New value of the state, only used if toggle is false. - * @param reset (Optional) Clears the overlay from client's screen. + * @param reset (Optional) Resets the channel path. * @return The overlay's new state. */ bool:OverlaysClientSetChannelState(client, OverlaysChannel:channel, bool:update = false, bool:toggle = true, bool:value = false, bool:reset = false) @@ -303,6 +303,12 @@ public Action:OverlaysTimer(Handle:timer) continue; } + // If no overlay is on the client's screen, then stop. + if (OverlaysClientFindChannel(x) == OVERLAYS_CHANNEL_NONE) + { + continue; + } + // Update client's overlay. OverlaysClientUpdateOverlay(x); } diff --git a/src/zr/playerclasses/classevents.inc b/src/zr/playerclasses/classevents.inc index cf74ffa..3f60556 100644 --- a/src/zr/playerclasses/classevents.inc +++ b/src/zr/playerclasses/classevents.inc @@ -133,9 +133,6 @@ ClassOnClientSpawn(client) ClassReloadPlayerCache(client, ClassGetActiveIndex(client)); ClassApplyAttributes(client); } - - // Forward event to sub-modules. - ClassOverlayOnClientSpawn(client); } /** @@ -173,7 +170,4 @@ ClassOnClientInfected(client, bool:motherzombie = false) // Apply the new attributes. ClassApplyAttributes(client, motherzombie); - - // Forward event to sub-modules. - ClassOverlayOnClientInfected(client); } diff --git a/src/zr/playerclasses/clientoverlays.inc b/src/zr/playerclasses/clientoverlays.inc index a7014e3..77e53e7 100644 --- a/src/zr/playerclasses/clientoverlays.inc +++ b/src/zr/playerclasses/clientoverlays.inc @@ -105,31 +105,6 @@ ClassOverlayClientInit(client) } } -/** - * Client is spawning into the game. - * - * @param client The client index. - */ -ClassOverlayOnClientSpawn(client) -{ - // If overlay toggle is enabled and class has an overlay, then send center text. - new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]); - - decl String:overlaypath[PLATFORM_MAX_PATH]; - ClassGetOverlayPath(client, overlaypath, sizeof(overlaypath)); - - if (overlaytoggle && overlaypath[0]) - { - decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH]; - GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds)); - - TranslationPrintHUDText(client, "Classes overlay toggle", togglecmds); - } - - // Update class overlay. - OverlaysClientUpdateOverlay(client, OVERLAYS_CHANNEL_CLASSES); -} - /** * Client has been killed. * @@ -141,28 +116,6 @@ ClassOverlayOnClientDeath(client) OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, false, true); } -/** - * Client has been infected. - * - * @param client The client index. - */ -ClassOverlayOnClientInfected(client) -{ - // If overlay toggle is enabled and class has an overlay, then send center text. - new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]); - - decl String:overlaypath[PLATFORM_MAX_PATH]; - ClassGetOverlayPath(client, overlaypath, sizeof(overlaypath)); - - if (overlaytoggle && overlaypath[0]) - { - decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH]; - GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds)); - - TranslationPrintCenterText(client, "Classes overlay toggle", togglecmds); - } -} - ClassOverlayInitialize(client, const String:overlay[]) { if (IsFakeClient(client)) @@ -177,6 +130,20 @@ ClassOverlayInitialize(client, const String:overlay[]) return; } + // If overlay toggle is enabled and class has an overlay, then send center text. + new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]); + + decl String:overlaypath[PLATFORM_MAX_PATH]; + ClassGetOverlayPath(client, overlaypath, sizeof(overlaypath)); + + if (overlaytoggle && overlaypath[0]) + { + decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH]; + GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds)); + + TranslationPrintHUDText(client, "Classes overlay toggle", togglecmds); + } + // Display class overlays. OverlaysClientSetChannelPath(client, OVERLAYS_CHANNEL_CLASSES, overlay); OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, CookiesGetClientCookieBool(client, g_hOverlayEnabledCookie)); diff --git a/src/zr/roundend.inc b/src/zr/roundend.inc index c88e51f..83ae80a 100644 --- a/src/zr/roundend.inc +++ b/src/zr/roundend.inc @@ -109,6 +109,9 @@ RoundEndOnClientInfected() */ RoundEndOnRoundStart() { + // Stop all overlays. + RoundEndOverlayStop(); + // If round end timer is running, then kill it. if (tRoundEnd != INVALID_HANDLE) { @@ -160,7 +163,7 @@ RoundEndOnRoundEnd(reason) new RoundEndOutcome:outcome = RoundEndReasonToOutcome(reason); // Display the overlay to all clients. - RoundEndOverlayStart(ROUNDEND_DELAY, outcome); + RoundEndOverlayStart(outcome); // Balance teams. RoundEndBalanceTeams(); @@ -355,7 +358,7 @@ RoundEndBalanceTeams() * @param time Time to display overlays. * @param outcome The outcome of the round. */ -RoundEndOverlayStart(Float:time, RoundEndOutcome:outcome) +RoundEndOverlayStart(RoundEndOutcome:outcome) { // If round end overlays are disabled, then stop. new bool:overlay = GetConVarBool(g_hCvarsList[CVAR_ROUNDEND_OVERLAY]); @@ -403,8 +406,6 @@ RoundEndOverlayStart(Float:time, RoundEndOutcome:outcome) OverlaysClientSetChannelPath(x, OVERLAYS_CHANNEL_ROUNDEND, overlaypath); OverlaysClientSetChannelState(x, OVERLAYS_CHANNEL_ROUNDEND, true, false, true); } - - CreateTimer(time, RoundEndOverlayTimer, _, TIMER_FLAG_NO_MAPCHANGE); } RoundEndOverlayStop() @@ -427,15 +428,4 @@ RoundEndOverlayStop() // Disable roundend overlay channel. OverlaysClientSetChannelState(x, OVERLAYS_CHANNEL_ROUNDEND, true, false, false, true); } -} - -/** - * Timer callback, stops overlays on all clients. - * - * @param timer The timer handle. - */ -public Action:RoundEndOverlayTimer(Handle:timer) -{ - // Stop all overlays. - RoundEndOverlayStop(); -} +} \ No newline at end of file