From 0df971f88387ba793e88545dc24b9bc45737835e Mon Sep 17 00:00:00 2001 From: MotoLegacy Date: Mon, 25 Nov 2024 00:20:52 -0800 Subject: [PATCH] CTR/PSP: Don't allow bad fog values to pass --- source/ctr/gl/gl_fog.c | 15 +++++++++++++++ source/psp/gu/gu_fog.cpp | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/source/ctr/gl/gl_fog.c b/source/ctr/gl/gl_fog.c index c967681..3c37ef2 100644 --- a/source/ctr/gl/gl_fog.c +++ b/source/ctr/gl/gl_fog.c @@ -44,6 +44,11 @@ update internal variables */ void Fog_Update (float start, float end, float red, float green, float blue, float time) { + if (start <= 0.01f || end <= 0.01f) { + start = 0.0f; + end = 0.0f; + } + //save previous settings for fade if (time > 0) { @@ -99,6 +104,11 @@ void Fog_ParseServerMessage (void) blue = MSG_ReadByte() / 255.0; time = MSG_ReadShort() / 100.0; + if (start < 0.01f || end < 0.01f) { + start = 0.0f; + end = 0.0f; + } + Fog_Update (start, end, red, green, blue, time); } @@ -243,6 +253,11 @@ void Fog_ParseWorldspawn (void) fog_density_gl = ((fog_start / fog_end))/3.5; } + + if (r_refdef.fog_start <= 0.01 || r_refdef.fog_end <= 0.01) { + r_refdef.fog_start = 0.0f; + r_refdef.fog_end = 0.0f; + } } /* diff --git a/source/psp/gu/gu_fog.cpp b/source/psp/gu/gu_fog.cpp index 0385da9..8274b21 100644 --- a/source/psp/gu/gu_fog.cpp +++ b/source/psp/gu/gu_fog.cpp @@ -37,6 +37,11 @@ update internal variables */ void Fog_Update (float start, float end, float red, float green, float blue, float time) { + if (start <= 0.01f || end <= 0.01f) { + start = 0.0f; + end = 0.0f; + } + //save previous settings for fade if (time > 0) { @@ -89,6 +94,11 @@ void Fog_ParseServerMessage (void) blue = MSG_ReadByte() / 255.0; time = MSG_ReadShort() / 100.0; + if (start < 0.01f || end < 0.01f) { + start = 0.0f; + end = 0.0f; + } + Fog_Update (start, end, red, green, blue, time); } @@ -230,6 +240,11 @@ void Fog_ParseWorldspawn (void) sscanf(value, "%f %f %f %f %f", &r_refdef.fog_start, &r_refdef.fog_end, &r_refdef.fog_red, &r_refdef.fog_green, &r_refdef.fog_blue); } } + + if (r_refdef.fog_start <= 0.01 || r_refdef.fog_end <= 0.01) { + r_refdef.fog_start = 0.0f; + r_refdef.fog_end = 0.0f; + } } /*