From 168b0385cf256ca0c32047f1179ee068b6d98abc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Mar 2021 09:13:16 +0100 Subject: [PATCH] - moved shadeToLight out of build.h. --- source/build/include/build.h | 24 ----------------------- source/build/src/engine_priv.h | 1 + source/core/gamecontrol.cpp | 1 + source/core/gamefuncs.h | 10 ++++++++++ source/core/palette.cpp | 2 +- source/core/palette.h | 2 +- source/core/rendering/scene/hw_portal.cpp | 7 ++++++- source/games/duke/src/2d_d.cpp | 1 + source/games/duke/src/2d_r.cpp | 1 + source/games/exhumed/src/2d.cpp | 1 + source/glbackend/glbackend.cpp | 1 + 11 files changed, 24 insertions(+), 27 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 4ce2d757d..0196754cc 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -190,17 +190,8 @@ EXTERN int32_t display_mirror; EXTERN int32_t randomseed; -EXTERN int16_t numshades; EXTERN uint8_t paletteloaded; -// Return type is int because this gets passed to variadic functions where structs may produce undefined behavior. -inline int shadeToLight(int shade) -{ - shade = clamp(shade, 0, numshades-1); - int light = Scale(numshades-1-shade, 255, numshades-1); - return PalEntry(255,light,light,light); -} - EXTERN int32_t maxspritesonscreen; enum { @@ -337,22 +328,8 @@ SPRITE VARIABLES: be in some sector, and must have some kind of status that you define. -TILE VARIABLES: - NUMTILES - the number of tiles found TILES.DAT. - -TIMING VARIABLES: - NUMFRAMES - The number of times the draw3dscreen function was called - since the engine was initialized. This helps to determine frame - rate. (Frame rate = numframes * 120 / I_GetBuildTime().) - OTHER VARIABLES: - STARTUMOST[320] is an array of the highest y-coordinates on each column - that my engine is allowed to write to. You need to set it only - once. - STARTDMOST[320] is an array of the lowest y-coordinates on each column - that my engine is allowed to write to. You need to set it only - once. SINTABLE[2048] is a sin table with 2048 angles rather than the normal 360 angles for higher precision. Also since SINTABLE is in all integers, the range is multiplied by 16383, so instead of the @@ -454,7 +431,6 @@ int findwallbetweensectors(int sect1, int sect2); inline int sectoradjacent(int sect1, int sect2) { return findwallbetweensectors(sect1, sect2) != -1; } int32_t getsectordist(vec2_t const in, int const sectnum, vec2_t * const out = nullptr); extern const int16_t *chsecptr_onextwall; -int32_t checksectorpointer(int16_t i, int16_t sectnum); #if !KRANDDEBUG inline int32_t krand(void) diff --git a/source/build/src/engine_priv.h b/source/build/src/engine_priv.h index eae8d6cc8..e0008dfd8 100644 --- a/source/build/src/engine_priv.h +++ b/source/build/src/engine_priv.h @@ -13,6 +13,7 @@ #ifndef ENGINE_PRIV_H #define ENGINE_PRIV_H +extern int32_t globalpal, globalfloorpal; extern tspriteptr_t tspriteptr[MAXSPRITESONSCREEN + 1]; extern int32_t xdimen, xdimenscale, xdimscale, ydimen; extern float fxdimen; diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index fccd9406b..57e284862 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -73,6 +73,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "automap.h" #include "v_draw.h" #include "gi.h" +#include "gamefuncs.h" CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 79087bb9d..75266b643 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -98,4 +98,14 @@ inline int sectorofwall(int wallNum) return -1; } +extern int numshades; + +// Return type is int because this gets passed to variadic functions where structs may produce undefined behavior. +inline int shadeToLight(int shade) +{ + shade = clamp(shade, 0, numshades - 1); + int light = Scale(numshades - 1 - shade, 255, numshades - 1); + return PalEntry(255, light, light, light); +} + diff --git a/source/core/palette.cpp b/source/core/palette.cpp index a5c256f41..4b6ef73e1 100644 --- a/source/core/palette.cpp +++ b/source/core/palette.cpp @@ -48,6 +48,7 @@ #include "../../glbackend/glbackend.h" LookupTableInfo lookups; +int numshades; //========================================================================== // @@ -136,7 +137,6 @@ void paletteLoadFromDisk(void) void LookupTableInfo::postLoadTables(void) { - globalpal = 0; GPalette.GenerateGlobalBrightmapFromColormap(getTable(0), numshades); // Try to detect fullbright translations. Unfortunately this cannot be used to detect fade strength because of loss of color precision in the palette map. diff --git a/source/core/palette.h b/source/core/palette.h index ac6e441b7..ac3140ffb 100644 --- a/source/core/palette.h +++ b/source/core/palette.h @@ -165,7 +165,7 @@ inline void videoclearFade() void videoTintBlood(int32_t r, int32_t g, int32_t b); -extern int32_t globalpal, globalfloorpal; +extern int numshades; extern void paletteLoadFromDisk(void); diff --git a/source/core/rendering/scene/hw_portal.cpp b/source/core/rendering/scene/hw_portal.cpp index 0e4d7b9a0..72a569343 100644 --- a/source/core/rendering/scene/hw_portal.cpp +++ b/source/core/rendering/scene/hw_portal.cpp @@ -804,7 +804,12 @@ bool HWSkyboxPortal::AllowSSAO() { return false; } // [MK] sector skyboxes don't //----------------------------------------------------------------------------- bool HWSectorStackPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clipper) { - auto state = mState; + // TODO: Handle recursion more intelligently + auto& state = mState; + if (state->renderdepth > r_mirror_recursions) + { + return false; + } auto portal = origin; auto &vp = di->Viewpoint; diff --git a/source/games/duke/src/2d_d.cpp b/source/games/duke/src/2d_d.cpp index 28e268964..846b66429 100644 --- a/source/games/duke/src/2d_d.cpp +++ b/source/games/duke/src/2d_d.cpp @@ -41,6 +41,7 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "mapinfo.h" #include "c_dispatch.h" #include "gamestate.h" +#include "gamefuncs.h" BEGIN_DUKE_NS diff --git a/source/games/duke/src/2d_r.cpp b/source/games/duke/src/2d_r.cpp index 9d01601cb..e31a65af3 100644 --- a/source/games/duke/src/2d_r.cpp +++ b/source/games/duke/src/2d_r.cpp @@ -39,6 +39,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #include "texturemanager.h" #include "c_dispatch.h" #include "gamestate.h" +#include "gamefuncs.h" BEGIN_DUKE_NS diff --git a/source/games/exhumed/src/2d.cpp b/source/games/exhumed/src/2d.cpp index 5e0fefce0..5621ae4ac 100644 --- a/source/games/exhumed/src/2d.cpp +++ b/source/games/exhumed/src/2d.cpp @@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "v_draw.h" #include "m_random.h" #include "gstrings.h" +#include "gamefuncs.h" #include diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index c10742a92..6eed048ed 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -50,6 +50,7 @@ #include "hw_cvars.h" #include "gamestruct.h" #include "gl_models.h" +#include "gamefuncs.h" CVARD(Bool, hw_hightile, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "enable/disable hightile texture rendering") bool hw_int_useindexedcolortextures;