From a82e3dd75ed13d439be1db3d6d312590bad5c7d1 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Thu, 2 Jun 2022 14:33:10 +0300 Subject: [PATCH] Fog_FogCommand_f: remove function calls from CLAMP and q_max macros --- Quake/gl_fog.c | 63 +++++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/Quake/gl_fog.c b/Quake/gl_fog.c index 9043b1a7..3a6cb235 100644 --- a/Quake/gl_fog.c +++ b/Quake/gl_fog.c @@ -115,6 +115,8 @@ handle the 'fog' console command */ void Fog_FogCommand_f (void) { + float d, r, g, b, t; + switch (Cmd_Argc()) { default: @@ -128,43 +130,52 @@ void Fog_FogCommand_f (void) Con_Printf(" \"red\" is \"%f\"\n", fog_red); Con_Printf(" \"green\" is \"%f\"\n", fog_green); Con_Printf(" \"blue\" is \"%f\"\n", fog_blue); - break; + return; case 2: - Fog_Update(q_max(0.0, atof(Cmd_Argv(1))), - fog_red, - fog_green, - fog_blue, - 0.0); + d = atof(Cmd_Argv(1)); + t = 0.0f; + r = fog_red; + g = fog_green; + b = fog_blue; break; case 3: //TEST - Fog_Update(q_max(0.0, atof(Cmd_Argv(1))), - fog_red, - fog_green, - fog_blue, - atof(Cmd_Argv(2))); + d = atof(Cmd_Argv(1)); + t = atof(Cmd_Argv(2)); + r = fog_red; + g = fog_green; + b = fog_blue; break; case 4: - Fog_Update(fog_density, - CLAMP(0.0, atof(Cmd_Argv(1)), 1.0), - CLAMP(0.0, atof(Cmd_Argv(2)), 1.0), - CLAMP(0.0, atof(Cmd_Argv(3)), 1.0), - 0.0); + d = fog_density; + t = 0.0f; + r = atof(Cmd_Argv(1)); + g = atof(Cmd_Argv(2)); + b = atof(Cmd_Argv(3)); break; case 5: - Fog_Update(q_max(0.0, atof(Cmd_Argv(1))), - CLAMP(0.0, atof(Cmd_Argv(2)), 1.0), - CLAMP(0.0, atof(Cmd_Argv(3)), 1.0), - CLAMP(0.0, atof(Cmd_Argv(4)), 1.0), - 0.0); + d = atof(Cmd_Argv(1)); + r = atof(Cmd_Argv(2)); + g = atof(Cmd_Argv(3)); + b = atof(Cmd_Argv(4)); + t = 0.0f; break; case 6: //TEST - Fog_Update(q_max(0.0, atof(Cmd_Argv(1))), - CLAMP(0.0, atof(Cmd_Argv(2)), 1.0), - CLAMP(0.0, atof(Cmd_Argv(3)), 1.0), - CLAMP(0.0, atof(Cmd_Argv(4)), 1.0), - atof(Cmd_Argv(5))); + d = atof(Cmd_Argv(1)); + r = atof(Cmd_Argv(2)); + g = atof(Cmd_Argv(3)); + b = atof(Cmd_Argv(4)); + t = atof(Cmd_Argv(5)); break; } + + if (d < 0.0f) d = 0.0f; + if (r < 0.0f) r = 0.0f; + else if (r > 1.0f) r = 1.0f; + if (g < 0.0f) g = 0.0f; + else if (g > 1.0f) g = 1.0f; + if (b < 0.0f) b = 0.0f; + else if (b > 1.0f) b = 1.0f; + Fog_Update(d, r, g, b, t); } /*