From 3325ef272eda7743e737d052c62e50f8cdb1b482 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 21 Jun 2020 13:08:46 +1000 Subject: [PATCH] - make r_ambientlight work globally for all games by performing adjustment engine-side. --- source/blood/src/view.cpp | 4 ++-- source/build/src/polymost.cpp | 2 +- source/core/gamecvars.cpp | 3 --- source/core/gamecvars.h | 1 - source/duke3d/src/game.cpp | 2 +- source/exhumed/src/osdcmds.h | 2 -- source/rr/src/game.cpp | 2 +- 7 files changed, 5 insertions(+), 11 deletions(-) diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 19020c6c5..8a397d1a6 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -3277,7 +3277,7 @@ void viewDrawScreen(bool sceneonly) } memcpy(bakMirrorGotpic, gotpic + 510, 2); memcpy(gotpic + 510, otherMirrorGotpic, 2); - g_visibility = (int32_t)(ClipLow(gVisibility - 32 * pOther->visibility, 0) * (numplayers > 1 ? 1.f : r_ambientlightrecip)); + g_visibility = (int32_t)(ClipLow(gVisibility - 32 * pOther->visibility, 0)); int vc4, vc8; getzsofslope(vcc, vd8, vd4, &vc8, &vc4); if (vd0 >= vc4) @@ -3351,7 +3351,7 @@ void viewDrawScreen(bool sceneonly) } nSprite = nextspritestat[nSprite]; } - g_visibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - unk, 0) * (numplayers > 1 ? 1.f : r_ambientlightrecip)); + g_visibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - unk, 0)); cA = (cA + interpolateangfix16(fix16_from_int(deliriumTurnO), fix16_from_int(deliriumTurn), gInterpolate)) & 0x7ffffff; int vfc, vf8; getzsofslope(nSectnum, cX, cY, &vfc, &vf8); diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index f06e2a07b..549882ffb 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -266,7 +266,7 @@ static void polymost_updaterotmat(void) }; multiplyMatrix4f(matrix, tiltmatrix); renderSetViewMatrix(matrix); - renderSetVisibility(g_visibility * fviewingrange * (4.f / (65536.f * 65536.f))); + renderSetVisibility(((float)(g_visibility) / r_ambientlight) * fviewingrange * (4.f / (65536.f * 65536.f))); } static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, int32_t method, const vec2_16_t& tilesiz); diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index 1bee17dff..edd0a0cb3 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -343,13 +343,10 @@ CUSTOM_CVARD(Int, r_showfpsperiod, 0, 0, "time in seconds before averaging min a if (self < 0 || self > 5) self = 1; } -float r_ambientlightrecip; - CUSTOM_CVARD(Float, r_ambientlight, 1.0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "sets the global map light level") { if (self < 0.1f) self = 0.1f; else if (self > 10.f) self = 10.f; - else r_ambientlightrecip = 1.f / self; } CVARD(Bool, r_shadows, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable sprite and model shadows") diff --git a/source/core/gamecvars.h b/source/core/gamecvars.h index 011f96c37..92e716aab 100644 --- a/source/core/gamecvars.h +++ b/source/core/gamecvars.h @@ -115,7 +115,6 @@ EXTERN_CVAR(Int, playercolor) EXTERN_CVAR(Int, playerteam) extern bool gNoAutoLoad; -extern float r_ambientlightrecip; extern int hud_statusbarrange; // will be set by the game's configuration setup. bool G_ChangeHudLayout(int direction); bool G_CheckAutorun(bool button); diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index ae36a8060..63356d940 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -650,7 +650,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) smoothRatio = 65536; int const playerVis = pPlayer->visibility; - g_visibility = (playerVis <= 0) ? 0 : (int32_t)(playerVis * (numplayers > 1 ? 1.f : r_ambientlightrecip)); + g_visibility = (playerVis <= 0) ? 0 : (int32_t)(playerVis); CAMERA(sect) = pPlayer->cursectnum; diff --git a/source/exhumed/src/osdcmds.h b/source/exhumed/src/osdcmds.h index 02a2d63a0..e45295bcb 100644 --- a/source/exhumed/src/osdcmds.h +++ b/source/exhumed/src/osdcmds.h @@ -30,8 +30,6 @@ int32_t registerosdcommands(void); void GAME_onshowosd(int shown); void GAME_clearbackground(int numcols, int numrows); -//extern float r_ambientlight,r_ambientlightrecip; - extern const char *const ConsoleButtons[]; //extern uint32_t cl_cheatmask; diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp index 5cf5668f7..6fa0ff901 100644 --- a/source/rr/src/game.cpp +++ b/source/rr/src/game.cpp @@ -860,7 +860,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) pPlayer->visibility = ud.const_visibility; int const playerVis = pPlayer->visibility; - g_visibility = (playerVis <= 0) ? 0 : (int32_t)(playerVis * (numplayers > 1 ? 1.f : r_ambientlightrecip)); + g_visibility = (playerVis <= 0) ? 0 : (int32_t)(playerVis); CAMERA(sect) = pPlayer->cursectnum;