From 12f5092e9ef1576a9edcc4d63763e745fb9a57b6 Mon Sep 17 00:00:00 2001 From: Richard Helgeby Date: Sun, 14 Feb 2010 16:27:20 +0100 Subject: [PATCH] Imported fix from dev: 640:a8280796340e - Fixed the default sky on the first map not reverting properly if zr_veffects_sky was enabled in zombiereloaded.cfg. --- .../zombiereloaded/zombiereloaded.cfg | 2 +- src/zombiereloaded.sp | 1 + src/zr/visualeffects/visualambience.inc | 32 +++++++++++-------- src/zr/visualeffects/visualeffects.inc | 9 ++++++ 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg index 09d1b25..d7403ed 100644 --- a/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg +++ b/cstrike/cfg/sourcemod/zombiereloaded/zombiereloaded.cfg @@ -453,7 +453,7 @@ zr_veffects_sky_path "sky_borealis01up.vmt" // Sun // Disable sun rendering on map. -// Default: "1" +// Default: "0" zr_veffects_sun_disable "0" // Fog (UNSUPPORTED) SourceMod currently doesn't support this feature. diff --git a/src/zombiereloaded.sp b/src/zombiereloaded.sp index 480053b..2d3a7d6 100644 --- a/src/zombiereloaded.sp +++ b/src/zombiereloaded.sp @@ -188,6 +188,7 @@ public OnMapEnd() { // Forward event to modules. VolOnMapEnd(); + VEffectsOnMapEnd(); } /** diff --git a/src/zr/visualeffects/visualambience.inc b/src/zr/visualeffects/visualambience.inc index 4623a1f..f28460b 100644 --- a/src/zr/visualeffects/visualambience.inc +++ b/src/zr/visualeffects/visualambience.inc @@ -30,24 +30,21 @@ */ new String:g_VAmbienceDefaultSky[PLATFORM_MAX_PATH]; +/** + * The map is ending. + */ +VAmbienceOnMapEnd() +{ + // Reset the default sky cache to empty, to be re-cached for the next map. + g_VAmbienceDefaultSky[0] = 0; +} + /** * Validate cvar data. */ VAmbienceLoad() { - // Find map's default sky. - new Handle:hSkyname = FindConVar("sv_skyname"); - if (hSkyname != INVALID_HANDLE) - { - // Store map's default sky before applying new one. - GetConVarString(hSkyname, g_VAmbienceDefaultSky, sizeof(g_VAmbienceDefaultSky)); - } - else - { - LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_VEffects, "Sky Caching", "Couldn't find handle to cvar: \"sv_skyname\""); - } - - // Apply all visual effects now + // Apply all visual effects now. VAmbienceApplyAll(); // If sky is disabled, then stop. @@ -240,18 +237,25 @@ VAmbienceApplyLightStyle(bool:disable = false) VAmbienceApplySky(bool:disable = false) { - // if we can't find the sv_skyname cvar, then stop. + // If we can't find the sv_skyname cvar, then stop. new Handle:hSkyname = FindConVar("sv_skyname"); if (hSkyname == INVALID_HANDLE) { return; } + // Store map's default sky before applying new one. + if (!g_VAmbienceDefaultSky[0]) + { + GetConVarString(hSkyname, g_VAmbienceDefaultSky, sizeof(g_VAmbienceDefaultSky)); + } + // If default, then set to default sky. if (disable) { if (g_VAmbienceDefaultSky[0]) { + // Set default sky on all clients. SetConVarString(hSkyname, g_VAmbienceDefaultSky, true); } diff --git a/src/zr/visualeffects/visualeffects.inc b/src/zr/visualeffects/visualeffects.inc index eb3d16d..a03f3aa 100644 --- a/src/zr/visualeffects/visualeffects.inc +++ b/src/zr/visualeffects/visualeffects.inc @@ -28,6 +28,15 @@ #include "zr/visualeffects/visualambience" #include "zr/visualeffects/ragdoll" +/** + * The map is ending. + */ +VEffectsOnMapEnd() +{ + // Forward event to sub-modules. + VAmbienceOnMapEnd(); +} + /** * Visual effect loading. */