From 0ffe70f3135f6fefe8f8316dc5b24c655f45eb41 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Fri, 17 Oct 2025 09:13:59 -0400 Subject: [PATCH 1/4] Update Discord RPC Based on some of the changes from RR. Accounts for the fact discord does not have tags anymore and makes skin code easier to manage --- src/d_netcmd.c | 5 --- src/discord.c | 93 ++++++++++++++++++-------------------------------- src/discord.h | 13 +++++++ src/m_menu.c | 4 +-- src/r_skins.c | 12 +++++++ 5 files changed, 61 insertions(+), 66 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index dc4db789c..509759f06 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1990,11 +1990,6 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) // set follower K_SetFollowerByNum(playernum, follower); - -#ifdef HAVE_DISCORDRPC - if (playernum == consoleplayer) - DRPC_UpdatePresence(); -#endif } enum { diff --git a/src/discord.c b/src/discord.c index 595b17901..295ad0990 100644 --- a/src/discord.c +++ b/src/discord.c @@ -48,8 +48,31 @@ struct discordInfo_s discordInfo; discordRequest_t *discordRequestList = NULL; +size_t g_discord_skins = 0; + static char self_ip[IP_SIZE]; +/*-------------------------------------------------- + * const char *DRPC_HideUsername(const char *input) + * + * See header file for description. + * --------------------------------------------------*/ +const char *DRPC_HideUsername(const char *input) +{ + static char buffer[5]; + int i; + + buffer[0] = input[0]; + + for (i = 1; i < 4; ++i) + { + buffer[i] = '.'; + } + + buffer[4] = '\0'; + return buffer; +} + boolean drpc_init = false; /*-------------------------------------------------- @@ -102,11 +125,11 @@ static void DRPC_HandleReady(const DiscordUser *user) { if (cv_discordstreamer.value) { - CONS_Printf("Discord: connected to %s\n", user->username); + CONS_Printf("Discord: connected to %s\n", DRPC_HideUsername(user->username)); } else { - CONS_Printf("Discord: connected to %s#%s (%s)\n", user->username, user->discriminator, user->userId); + CONS_Printf("Discord: connected to %s (%s)\n", user->username, user->userId); } } @@ -242,8 +265,10 @@ static void DRPC_HandleJoinRequest(const DiscordUser *requestUser) newRequest->username = Z_Calloc(344, PU_STATIC, NULL); snprintf(newRequest->username, 344, "%s", requestUser->username); +#if 0 newRequest->discriminator = Z_Calloc(8, PU_STATIC, NULL); snprintf(newRequest->discriminator, 8, "%s", requestUser->discriminator); +#endif newRequest->userID = Z_Calloc(32, PU_STATIC, NULL); snprintf(newRequest->userID, 32, "%s", requestUser->userId); @@ -309,6 +334,9 @@ void DRPC_RemoveRequest(discordRequest_t *removeRequest) } Z_Free(removeRequest->username); +#if 0 + Z_Free(removeRequest->discriminator); +#endif Z_Free(removeRequest->userID); Z_Free(removeRequest); } @@ -770,66 +798,13 @@ void DRPC_UpdatePresence(void) // Character info if (Playing() && playeringame[consoleplayer] && !players[consoleplayer].spectator) { - // Supported skin names - static const char *supportedSkins[] = { - // base game - "sonic", - "tails", - "knuckles", - "eggman", - "metalsonic", - // bonus chars - "flicky", - "motobug", - "amy", - "mighty", - "ray", - "espio", - "vector", - "chao", - "gamma", - "chaos", - "shadow", - "rouge", - "herochao", - "darkchao", - "cream", - "omega", - "blaze", - "silver", - "wonderboy", - "arle", - "nights", - "sakura", - "ulala", - "beat", - "vyse", - "aiai", - "kiryu", - "aigis", - "miku", - "doom", - NULL - }; - - boolean customChar = true; - UINT8 checkSkin = 0; - // Character image - while (supportedSkins[checkSkin] != NULL) + if ((unsigned)players[consoleplayer].skin < g_discord_skins) // Supported skins { - if (!strcmp(skins[players[consoleplayer].skin].name, supportedSkins[checkSkin])) - { - snprintf(charimg, 22, "char_%s", supportedSkins[checkSkin]); - discordPresence.smallImageKey = charimg; - customChar = false; - break; - } - - checkSkin++; + snprintf(charimg, 21, "char_%s", skins[ players[consoleplayer].skin ].name); + discordPresence.smallImageKey = charimg; } - - if (customChar == true) + else { // Use the custom character icon! discordPresence.smallImageKey = "charcustom"; diff --git a/src/discord.h b/src/discord.h index 667d941da..80d23b15e 100644 --- a/src/discord.h +++ b/src/discord.h @@ -33,7 +33,9 @@ extern struct discordInfo_s { struct discordRequest_t { char *username; // Discord user name. +#if 0 // Good night, sweet prince... char *discriminator; // Discord discriminator (The little hashtag thing after the username). Separated for a "hide discriminators" cvar. +#endif char *userID; // The ID of the Discord user, gets used with Discord_Respond() // HAHAHA, no. @@ -48,6 +50,17 @@ struct discordRequest_t { extern discordRequest_t *discordRequestList; +extern size_t g_discord_skins; + +/*-------------------------------------------------- + * const char *DRPC_HideUsername(const char *input); + * + * Handle usernames while cv_discordstreamer is activated. + * (The loss of discriminators is still a dumbass regression + * that I will never forgive the Discord developers for.) + * --------------------------------------------------*/ + +const char *DRPC_HideUsername(const char *input); /*-------------------------------------------------- void DRPC_RemoveRequest(void); diff --git a/src/m_menu.c b/src/m_menu.c index e96235471..ad10169a9 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9128,9 +9128,9 @@ static const char *M_GetDiscordName(discordRequest_t *r) return ""; if (cv_discordstreamer.value) - return r->username; + return DRPC_HideUsername(r->username); - return va("%s#%s", r->username, r->discriminator); + return r->username; } void MD_DrawDiscordRequests(void) diff --git a/src/r_skins.c b/src/r_skins.c index 6affcd4e6..e83916a9f 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -36,6 +36,8 @@ #include "hardware/hw_md2.h" #endif +#include "discord.h" + INT32 numskins = 0; skin_t skins[MAXSKINS]; INT32 skinsorted[MAXSKINS]; @@ -235,6 +237,11 @@ void R_InitSkins(void) if (!wadfiles[i]->compatmode) R_PatchSkins((UINT16)i); R_LoadSpriteInfoLumps(i, wadfiles[i]->numlumps); + + if (i < NUMMAINWADS) + { + g_discord_skins = numskins; + } } ST_ReloadSkinFaceGraphics(); } @@ -541,6 +548,11 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) // for replays: We have changed our skin mid-game; let the game know so it can do the same in the replay! demo_extradata[playernum] |= DXD_SKIN; +#ifdef HAVE_DISCORDRPC + if (player - players == consoleplayer) + DRPC_UpdatePresence(); +#endif + return; } From 166648f0083221fd5b868af272ae3f4aaf2b3f7a Mon Sep 17 00:00:00 2001 From: NepDisk Date: Fri, 17 Oct 2025 09:55:24 -0400 Subject: [PATCH 2/4] Kill BUGTRAP This probably never worked --- src/sdl/i_main.c | 8 ----- src/win32/win_dbg.c | 79 --------------------------------------------- src/win32/win_dbg.h | 8 ----- 3 files changed, 95 deletions(-) diff --git a/src/sdl/i_main.c b/src/sdl/i_main.c index 77387aa8e..31935bf72 100644 --- a/src/sdl/i_main.c +++ b/src/sdl/i_main.c @@ -223,9 +223,6 @@ int main(int argc, char **argv) #if 0 // just load the DLL p_IsDebuggerPresent pfnIsDebuggerPresent = (p_IsDebuggerPresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsDebuggerPresent"); if ((!pfnIsDebuggerPresent || !pfnIsDebuggerPresent()) -#ifdef BUGTRAP - && !InitBugTrap() -#endif ) #endif { @@ -250,11 +247,6 @@ int main(int argc, char **argv) // never return D_SRB2Loop(); -#ifdef BUGTRAP - // This is safe even if BT didn't start. - ShutdownBugTrap(); -#endif - // return to OS return 0; } diff --git a/src/win32/win_dbg.c b/src/win32/win_dbg.c index a9947d55d..a35042724 100644 --- a/src/win32/win_dbg.c +++ b/src/win32/win_dbg.c @@ -29,85 +29,6 @@ LPTOP_LEVEL_EXCEPTION_FILTER prevExceptionFilter = NULL; -#ifdef BUGTRAP - - -typedef void (APIENTRY *BT_SETSUPPORTURL)(LPCTSTR pszSupportURL); -typedef void (APIENTRY *BT_SETFLAGS)(DWORD dwFlags); -typedef void (APIENTRY *BT_SETAPPNAME)(LPCTSTR pszAppName); -typedef void (APIENTRY *BT_SETAPPVERSION)(LPCTSTR pszAppVersion); -typedef void (APIENTRY *BT_SETSUPPORTSERVER)(LPCTSTR pszSupportHost, SHORT nSupportPort); - -// BT constant definitions that we use, as given in the docs. -#define BTF_DETAILEDMODE 0x01 -#define BTF_ATTACHREPORT 0x04 - - -static HMODULE g_hmodBugTrap; - - -// -------------------------------------------------------------------------- -// Initialises the Bug Trap exception-handling library. Returns true iff -// successful. -// -------------------------------------------------------------------------- -BOOL InitBugTrap(void) -{ - BT_SETFLAGS lpfnBT_SetFlags; - BT_SETSUPPORTURL lpfnBT_SetSupportURL; - BT_SETAPPNAME lpfnBT_SetAppName; - BT_SETAPPVERSION lpfnBT_SetAppVersion; - BT_SETSUPPORTSERVER lpfnBT_SetSupportServer; - - // Loading the library installs the exception handler. -#ifdef UNICODE - g_hmodBugTrap = LoadLibrary(L"BugTrapU.dll"); -#else - g_hmodBugTrap = LoadLibrary("BugTrap.dll"); -#endif - - // Get the functions. - lpfnBT_SetFlags = (BT_SETFLAGS)GetProcAddress(g_hmodBugTrap, "BT_SetFlags"); - lpfnBT_SetSupportURL = (BT_SETSUPPORTURL)GetProcAddress(g_hmodBugTrap, "BT_SetSupportURL"); - lpfnBT_SetAppName = (BT_SETAPPNAME)GetProcAddress(g_hmodBugTrap, "BT_SetAppName"); - lpfnBT_SetAppVersion = (BT_SETAPPVERSION)GetProcAddress(g_hmodBugTrap, "BT_SetAppVersion"); - lpfnBT_SetSupportServer = (BT_SETSUPPORTSERVER)GetProcAddress(g_hmodBugTrap, "BT_SetSupportServer"); - - if (g_hmodBugTrap) - { - lpfnBT_SetAppName(TEXT("SRB2Kart")); - lpfnBT_SetAppVersion(TEXT(VERSIONSTRING)); - lpfnBT_SetFlags(BTF_DETAILEDMODE | BTF_ATTACHREPORT); - lpfnBT_SetSupportURL(TEXT("http://www.srb2.org/")); - lpfnBT_SetSupportServer(TEXT("srb2.org"), 9999); - - return TRUE; - } - - return FALSE; -} - - -// -------------------------------------------------------------------------- -// Removes the BugTrap exception handler. Safe to call even if BT was never -// initialized. -// -------------------------------------------------------------------------- -void ShutdownBugTrap(void) -{ - if (g_hmodBugTrap) FreeLibrary(g_hmodBugTrap); -} - -// -------------------------------------------------------------------------- -// Simple test to check whether BugTrap is loaded without exposing its -// handle. -// -------------------------------------------------------------------------- -BOOL IsBugTrapLoaded(void) -{ - return !!g_hmodBugTrap; -} - -#endif // (defined BUGTRAP) - - #define NumCodeBytes 16 // Number of code bytes to record. #define MaxStackDump 2048 // Maximum number of DWORDS in stack dumps. #define StackColumns 8 // Number of columns in stack dump. diff --git a/src/win32/win_dbg.h b/src/win32/win_dbg.h index 6daf991b4..ca2250c8e 100644 --- a/src/win32/win_dbg.h +++ b/src/win32/win_dbg.h @@ -27,14 +27,6 @@ extern "C" { #endif -#ifdef BUGTRAP - -BOOL InitBugTrap(void); -void ShutdownBugTrap(void); -BOOL IsBugTrapLoaded(void); - -#endif - // called in the exception filter of the __try block, writes all useful debugging information // to a file, using only win32 functions in case the C runtime is in a bad state. LONG WINAPI RecordExceptionInfo(PEXCEPTION_POINTERS data/*, LPCSTR Message, LPSTR lpCmdLine*/); From ff467c676c9e123792d9d47fcaf1e99d3c19749c Mon Sep 17 00:00:00 2001 From: NepDisk Date: Fri, 17 Oct 2025 10:32:21 -0400 Subject: [PATCH 3/4] port over most fixes from srb2classics clang-tidy pr Based on https://github.com/Indev450/SRB2Kart-Saturn/commit/939354f4834a3c62dd051fb4150e21e818ad4a3a --- src/am_map.c | 9 ++++++++- src/command.c | 6 ++---- src/d_netcmd.c | 2 +- src/deh_soc.c | 26 +++++++++++++------------- src/filesrch.c | 9 ++++++--- src/g_game.c | 3 +-- src/hardware/hw_cache.c | 4 +++- src/hardware/hw_main.c | 4 +--- src/hardware/hw_md2.c | 23 +---------------------- src/hu_stuff.c | 12 ++++++------ src/m_fixed.c | 4 ++-- src/m_misc.cpp | 4 ++++ src/p_enemy.c | 11 ++++++----- src/p_mobj.c | 8 ++++---- src/p_pspr.h | 3 ++- src/p_spec.c | 2 -- src/r_skins.c | 12 ++++++------ src/r_things.cpp | 28 ++++++++++++---------------- src/sdl/i_system.cpp | 2 +- src/tables.c | 7 ++++--- src/v_video.c | 7 +++---- 21 files changed, 86 insertions(+), 100 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index 46f889800..0ef1eb053 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -265,6 +265,11 @@ static void AM_findMinMaxBoundaries(void) max_w = minimapinfo.map_w << MAPBITS; max_h = minimapinfo.map_h << MAPBITS; + if (max_w == 0) + max_w = 1; + if (max_h == 0) + max_h = 1; + a = FixedDiv(f_w< max_scale_mtof) - scale_mtof = min_scale_mtof; + scale_mtof = max_scale_mtof; + if (scale_mtof == 0) + scale_mtof = 1; scale_ftom = FixedDiv(FRACUNIT, scale_mtof); } diff --git a/src/command.c b/src/command.c index fb59909d1..f1b07a2fb 100644 --- a/src/command.c +++ b/src/command.c @@ -797,12 +797,10 @@ static void COM_CEcho_f(void) for (i = 1; i < COM_Argc(); i++) { - strncat(cechotext, COM_Argv(i), sizeof(cechotext)-1); - strncat(cechotext, " ", sizeof(cechotext)-1); + strlcpy(cechotext, COM_Argv(i), sizeof(cechotext)-1); + strlcpy(cechotext, " ", sizeof(cechotext)-1); } - cechotext[sizeof(cechotext) - 1] = '\0'; - HU_DoCEcho(cechotext); } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 509759f06..02067ef86 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5627,7 +5627,7 @@ retryscramble: memset(&scrambleplayers, 0, sizeof(scrambleplayers)); memset(&scrambleteams, 0, sizeof(scrambleplayers)); scrambletotal = scramblecount = 0; - blue = red = maxcomposition = newteam = playercount = 0; + blue = red = newteam = playercount = 0; repick = true; // Put each player's node in the array. diff --git a/src/deh_soc.c b/src/deh_soc.c index ed906fa00..93b96bc54 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -405,7 +405,7 @@ void readskincolor(MYFILE *f, INT32 num, boolean mainfile) strupr(word); // Now get the part after - word2 = tmp += 2; + word2 = tmp + 2; if (fastcmp(word, "NAME")) { @@ -867,7 +867,7 @@ void readlevelheader(MYFILE *f, char * name) strupr(word); // Now get the part after - word2 = tmp += 2; + word2 = tmp + 2; i = atoi(word2); // used for numerical settings @@ -1947,7 +1947,7 @@ static void readmenuitem(MYFILE *f, menuitem_t *menuitem) strupr(word); // Now get the part after - word2 = tmp += 2; + word2 = tmp + 2; //strupr(word2); if (fastcmp(word, "X")) @@ -2525,7 +2525,7 @@ void readsound(MYFILE *f, INT32 num) strupr(word); // Now get the part after - word2 = tmp += 2; + word2 = tmp + 2; value = atoi(word2); // used for numerical settings if (fastcmp(word, "SINGULAR")) @@ -2631,7 +2631,7 @@ void reademblemdata(MYFILE *f, INT32 num) strupr(word); // Now get the part after - word2 = tmp += 2; + word2 = tmp + 2; value = atoi(word2); // used for numerical settings // Up here to allow lowercase in hints @@ -2738,7 +2738,7 @@ void readextraemblemdata(MYFILE *f, INT32 num) strupr(word); // Now get the part after - word2 = tmp += 2; + word2 = tmp + 2; value = atoi(word2); // used for numerical settings @@ -2821,7 +2821,7 @@ void readunlockable(MYFILE *f, INT32 num) strupr(word); // Now get the part after - word2 = tmp += 2; + word2 = tmp + 2; i = atoi(word2); // used for numerical settings @@ -3082,7 +3082,7 @@ void readconditionset(MYFILE *f, UINT8 setnum) strupr(word); // Now get the part after - word2 = tmp += 2; + word2 = tmp + 2; strupr(word2); if (fastncmp(word, "CONDITION", 9)) @@ -3146,7 +3146,7 @@ void readmaincfg(MYFILE *f) strupr(word); // Now get the part after - word2 = tmp += 2; + word2 = tmp + 2; strupr(word2); value = atoi(word2); // used for numerical settings @@ -3437,7 +3437,7 @@ void readwipes(MYFILE *f) { char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); char *word = s; - char *pword = word; + char *pword; char *word2; char *tmp; INT32 value; @@ -3470,7 +3470,7 @@ void readwipes(MYFILE *f) strupr(word); // Now get the part after - word2 = tmp += 2; + word2 = tmp + 2; value = atoi(word2); // used for numerical settings if (value < -1 || value > 99) @@ -3615,7 +3615,7 @@ void readcupheader(MYFILE *f, cupheader_t *cup) strupr(word); // Now get the part after - word2 = tmp += 2; + word2 = tmp + 2; i = atoi(word2); // used for numerical settings strupr(word2); @@ -4009,7 +4009,7 @@ void readweather(MYFILE *f, INT32 num) strupr(word); // Now get the part after - word2 = tmp += 2; + word2 = tmp + 2; if (fastcmp(word, "TYPE")) { diff --git a/src/filesrch.c b/src/filesrch.c index ddda10f02..5da959b52 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -373,10 +373,13 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut) Z_Free(dirmenu); dirmenu = NULL; - for (; sizecoredirmenu > 0; sizecoredirmenu--) // clear out existing items + if (coredirmenu != NULL) { - Z_Free(coredirmenu[sizecoredirmenu-1]); - coredirmenu[sizecoredirmenu-1] = NULL; + for (; sizecoredirmenu > 0; sizecoredirmenu--) // clear out existing items + { + Z_Free(coredirmenu[sizecoredirmenu-1]); + coredirmenu[sizecoredirmenu-1] = NULL; + } } while (true) diff --git a/src/g_game.c b/src/g_game.c index 30a907ec6..ce0a74d34 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -5403,8 +5403,6 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, if (!( realmapname = G_BuildMapTitle(mapnum) )) continue; - aprop = realmapname; - /* Now that we found a perfect match no need to fucking guess. */ if (strnicmp(realmapname, mapname, mapnamelen) == 0) { @@ -5433,6 +5431,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, writesimplefreq(freq, &freqc, mapnum, aprop - realmapname, mapnamelen); } + if (apromapnum == 0) { apromapnum = mapnum; diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 8940d4ee1..bdf2f026b 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -1572,7 +1572,9 @@ static void HWR_CacheFadeMask(GLMipmap_t *grMipmap, lumpnum_t fademasklumpnum) break; default: // Bad lump CONS_Alert(CONS_WARNING, "Fade mask lump of incorrect size, ignored\n"); // I should avoid this by checking the lumpnum in HWR_RunWipe - break; + fmwidth = 0; + fmheight = 0; + return; } // Thankfully, this will still work for this scenario diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9d6362c5c..3734e2bb6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3386,7 +3386,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr) tmult = (tbot - ttop) / (top - bot); endrealtop = endtop = baseWallVerts[2].y; - endrealbot = endbot = baseWallVerts[1].y; + endrealbot = baseWallVerts[1].y; // copy the contents of baseWallVerts into the drawn wallVerts array // baseWallVerts is used to know the final shape to easily get the vertex @@ -5484,8 +5484,6 @@ void HWR_BuildSkyDome(void) sky->loops[sky->loopcount].use_texture = false; sky->loopcount++; - delta = 0.0f; - for (c = 0; c < col_count; c++) { HWR_SkyDomeVertex(sky, vertex_p, 1, c, yflip, 0.0f, true); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 1bb3fbd2d..6b42c4361 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1007,25 +1007,7 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi continue; } - firsti = 0; - mul = 0; - mulmax = 1; - - /*for (i = 0; i < translen; i++) - { - if (brightness > colorbrightnesses[i]) // don't allow greater matches (because calculating a makeshift gradient for this is already a huge mess as is) - continue; - - compare = abs((INT16)(colorbrightnesses[i]) - (INT16)(brightness)); - - if (compare < brightdif) - { - brightdif = (UINT16)compare; - firsti = i; // best matching color that's equal brightness or darker - } - }*/ firsti = color_match_lookup[brightness]; - secondi = firsti+1; // next color in line m = (INT16)brightness - (INT16)colorbrightnesses[secondi]; @@ -1360,10 +1342,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) FTransform p; FSurfaceInfo Surf; - if (!cv_glmodels.value) - return false; - - if (spr->precip) + if (!cv_glmodels.value || spr->precip) return false; // Lactozilla: Disallow certain models from rendering diff --git a/src/hu_stuff.c b/src/hu_stuff.c index ff8101538..f32610e78 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -784,7 +784,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) || target == 0 // To everyone || consoleplayer == target-1) // To you { - const char *prefix = "", *cstart = "", *cend = "", *adminchar = "\x82~\x83", *remotechar = "\x82@\x83", *fmt2, *textcolor = "\x80"; + const char *prefix, *cstart, *adminchar = "\x82~\x83", *remotechar = "\x82@\x83", *fmt2, *textcolor = "\x80"; char *tempchar = NULL; char color_prefix[2]; @@ -877,13 +877,13 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) // name, color end, and the message itself. // '\4' makes the message yellow and beeps; '\3' just beeps. if (action) - fmt2 = "* %s%s%s%s \x82%s%s"; + fmt2 = "* %s%s%s %s%s"; else if (target-1 == consoleplayer) // To you { prefix = "\x82[PM]"; cstart = "\x82"; textcolor = "\x82"; - fmt2 = "%s<%s%s>%s\x80 %s%s"; + fmt2 = "%s<%s%s> %s%s"; } else if (target > 0) // By you, to another player { @@ -891,11 +891,11 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) dispname = player_names[target-1]; prefix = "\x82[TO]"; cstart = "\x82"; - fmt2 = "%s<%s%s>%s\x80 %s%s"; + fmt2 = "%s<%s%s> %s%s"; } else // To everyone or sayteam, it doesn't change anything. - fmt2 = "%s<%s%s%s>\x80 %s%s"; + fmt2 = "%s<%s%s> %s%s"; /*else // To your team { if (players[playernum].ctfteam == 1) // red @@ -908,7 +908,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) fmt2 = "%s<%s%s>\x80%s %s%s"; }*/ - HU_AddChatText(va(fmt2, prefix, cstart, dispname, cend, textcolor, msg), (cv_chatnotifications.value) && !(flags & HU_SHOUT)); // add to chat + HU_AddChatText(va(fmt2, prefix, cstart, dispname, textcolor, msg), (cv_chatnotifications.value) && !(flags & HU_SHOUT)); // add to chat if ((cv_chatnotifications.value) && (flags & HU_SHOUT)) S_StartSound(NULL, sfx_sysmsg); diff --git a/src/m_fixed.c b/src/m_fixed.c index c5b4ab03f..517d28902 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -755,12 +755,12 @@ fixed_t FV3_Normal(const vector3_t *a_triangle, vector3_t *a_normal) fixed_t FV3_Strength(const vector3_t *a_1, const vector3_t *dir) { vector3_t normal; - fixed_t dist = FV3_NormalizeEx(a_1, &normal); + FV3_NormalizeEx(a_1, &normal); fixed_t dot = FV3_Dot(&normal, dir); FV3_ClosestPointOnVector(dir, a_1, &normal); - dist = FV3_Magnitude(&normal); + fixed_t dist = FV3_Magnitude(&normal); if (dot < 0) // Not facing same direction, so negate result. dist = -dist; diff --git a/src/m_misc.cpp b/src/m_misc.cpp index aa49d6574..0d0e190a1 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -1625,6 +1625,10 @@ void M_DoScreenShot(void) palette = nullptr; } #endif + else + { + I_Error("rendermode %d is not valid", rendermode); + } #ifdef USE_PNG ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, palette); diff --git a/src/p_enemy.c b/src/p_enemy.c index 8e2116dc4..f7bfe41cd 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -6120,10 +6120,11 @@ void A_Boss3Path(mobj_t *actor) actor->momx = 0; actor->momy = 0; actor->momz = 0; - P_SetTarget(&actor->target, actor->tracer->target); + if (actor->tracer) + P_SetTarget(&actor->target, actor->tracer->target); var1 = 0, var2 = 0; A_FaceTarget(actor); - if (actor->tracer->state == &states[actor->tracer->info->missilestate]) + if (actor && actor->tracer && actor->tracer->state == &states[actor->tracer->info->missilestate]) P_SetMobjState(actor, actor->info->missilestate); return; } @@ -8331,7 +8332,7 @@ void A_SetCustomValue(mobj_t *actor) if (cht_debug) CONS_Printf("Init custom value is %d\n", actor->cusval); - if (locvar1 == 0 && locvar2 == 4) + if (locvar1 == 0 && (locvar2 == 3 || locvar2 == 4)) return; // DON'T DIVIDE BY ZERO // no need for a "temp" value here, just modify the cusval directly @@ -8389,7 +8390,7 @@ void A_UseCusValMemo(mobj_t *actor) tempM = actor->cvmem; } - if (tempM == 0 && locvar2 == 4) + if (locvar1 == 0 && (locvar2 == 3 || locvar2 == 4)) return; // DON'T DIVIDE BY ZERO // now get new value for cusval/cvmem using the other @@ -8455,7 +8456,7 @@ void A_RelayCustomValue(mobj_t *actor) else // tracer's custom value tempT = actor->tracer->cusval; - if (temp == 0 && locvar2 == 4) + if (locvar1 == 0 && (locvar2 == 3 || locvar2 == 4)) return; // DON'T DIVIDE BY ZERO // now get new cusval using target's and the reference diff --git a/src/p_mobj.c b/src/p_mobj.c index 7e801a78f..deae79720 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -5565,7 +5565,7 @@ static void P_Boss9Thinker(mobj_t *mobj) { mobj_t *spawner; fixed_t dist = 0; - angle = 0x06000000*leveltime; + angle = ANGLE_135*leveltime; // Alter your energy bubble's size/position if (mobj->health > 3) @@ -5744,7 +5744,7 @@ static void P_Boss9Thinker(mobj_t *mobj) return; } - angle = 0x06000000*leveltime; + angle = ANGLE_135*leveltime; mobj->momz += FixedMul(FINECOSINE(angle>>ANGLETOFINESHIFT),2*FRACUNIT); // Use that "angle" to bob gently in the air // This is below threshold because we don't want to bob while zipping around @@ -14731,7 +14731,7 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 allowai // angle at which you fire, is player angle an = angle; - if (allowaim) // aiming allowed? + if (source->player && allowaim) // aiming allowed? slope = AIMINGTOSLOPE(source->player->aiming); x = source->x; @@ -14764,7 +14764,7 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 allowai th->momx = FixedMul(speed, FINECOSINE(an>>ANGLETOFINESHIFT)); th->momy = FixedMul(speed, FINESINE(an>>ANGLETOFINESHIFT)); - if (allowaim) + if (source->player && allowaim) { th->momx = FixedMul(th->momx,FINECOSINE(source->player->aiming>>ANGLETOFINESHIFT)); th->momy = FixedMul(th->momy,FINECOSINE(source->player->aiming>>ANGLETOFINESHIFT)); diff --git a/src/p_pspr.h b/src/p_pspr.h index f91db809e..a42363388 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -110,7 +110,8 @@ extern "C" { */ typedef enum { - tr_trans10 = 1, + tr_trans0 = 0, + tr_trans10, tr_trans20, tr_trans30, tr_trans40, diff --git a/src/p_spec.c b/src/p_spec.c index a9b2eed95..a72d053b2 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -8183,7 +8183,6 @@ void T_Scroll(scroll_t *s) case sc_carry: sec = sectors + s->affectee; - height = sec->floorheight; // sec is the control sector, find the real sector(s) to use for (i = 0; i < sec->linecount; i++) @@ -8260,7 +8259,6 @@ void T_Scroll(scroll_t *s) case sc_carry_ceiling: // carry on ceiling (FOF scrolling) sec = sectors + s->affectee; - height = sec->ceilingheight; // sec is the control sector, find the real sector(s) to use for (i = 0; i < sec->linecount; i++) diff --git a/src/r_skins.c b/src/r_skins.c index e83916a9f..a0e1b0bff 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -1001,8 +1001,9 @@ void R_AddSkins(UINT16 wadnum) if ((stoken[0] == '/' && stoken[1] == '/') || (stoken[0] == '#'))// skip comments { - stoken = strtok(NULL, "\r\n"); // skip end of line - goto next_token; // find the real next token + strtok(NULL, "\r\n"); // skip end of line + stoken = strtok(NULL, "\r\n= "); + continue; // find the real next token } value = strtok(NULL, "\r\n= "); @@ -1052,7 +1053,6 @@ void R_AddSkins(UINT16 wadnum) else if (!R_ProcessPatchableFields(skin, stoken, value)) CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); -next_token: stoken = strtok(NULL, "\r\n= "); } free(buf2); @@ -1136,8 +1136,9 @@ void R_PatchSkins(UINT16 wadnum) if ((stoken[0] == '/' && stoken[1] == '/') || (stoken[0] == '#'))// skip comments { - stoken = strtok(NULL, "\r\n"); // skip end of line - goto next_token; // find the real next token + strtok(NULL, "\r\n"); // skip end of line + stoken = strtok(NULL, "\r\n= "); + continue; // find the real next token } value = strtok(NULL, "\r\n= "); @@ -1215,7 +1216,6 @@ void R_PatchSkins(UINT16 wadnum) if (!skin) break; -next_token: stoken = strtok(NULL, "\r\n= "); } free(buf2); diff --git a/src/r_things.cpp b/src/r_things.cpp index d65eb2a81..e811d43ea 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2993,6 +2993,10 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps visplane_t *plane; INT32 sintersect; fixed_t scale = 0; + const INT32 vidheight = vid.height; + + if (mask->drawsegs[0] == mask->drawsegs[1]) + return; // Add the 3D floors, thicksides, and masked textures... for (ds = drawsegs + mask->drawsegs[1]; ds-- > drawsegs + mask->drawsegs[0];) @@ -3011,7 +3015,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps plane = ds->curline->polyseg->visplane; R_PlaneBounds(plane); - if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low) + if (plane->low < 0 || plane->high > vidheight || plane->high > plane->low) ; else { // Put it in! @@ -3039,7 +3043,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps plane = ds->ffloorplanes[p]; R_PlaneBounds(plane); - if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low || plane->polyobj) + if (plane->low < 0 || plane->high > vidheight || plane->high > plane->low || plane->polyobj) { ds->ffloorplanes[p] = NULL; continue; @@ -3078,7 +3082,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps plane = PolyObjects[i].visplane; R_PlaneBounds(plane); - if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low) + if (plane->low < 0 || plane->high > vidheight || plane->high > plane->low) { PolyObjects[i].visplane = NULL; continue; @@ -3100,7 +3104,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps const boolean alwaysontop = cv_debugrender_spriteclip.value || (rover->renderflags & RF_ALWAYSONTOP); const INT32 ontopflag = cv_debugrender_spriteclip.value ? 0 : (rover->renderflags & RF_ALWAYSONTOP); - if (rover->szt > vid.height || rover->sz < 0) + if (rover->szt > vidheight || rover->sz < 0) continue; sintersect = (rover->x1 + rover->x2) / 2; @@ -3171,9 +3175,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps continue; } - entry = R_CreateDrawNode(NULL); - (entry->prev = r2->prev)->next = entry; - (entry->next = r2)->prev = entry; + entry = R_CreateDrawNode(r2); entry->sprite = rover; break; } @@ -3205,9 +3207,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps (botplanecameraz > viewz && rover->gz > botplaneobjectz)) #endif { - entry = R_CreateDrawNode(NULL); - (entry->prev = r2->prev)->next = entry; - (entry->next = r2)->prev = entry; + entry = R_CreateDrawNode(r2); entry->sprite = rover; break; } @@ -3224,9 +3224,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps if (rover->sortscale < scale) { - entry = R_CreateDrawNode(NULL); - (entry->prev = r2->prev)->next = entry; - (entry->next = r2)->prev = entry; + entry = R_CreateDrawNode(r2); entry->sprite = rover; break; } @@ -3273,9 +3271,7 @@ static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean temps if (infront) { - entry = R_CreateDrawNode(NULL); - (entry->prev = r2->prev)->next = entry; - (entry->next = r2)->prev = entry; + entry = R_CreateDrawNode(r2); entry->sprite = rover; break; } diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 22845d82d..aadddda18 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -2549,7 +2549,7 @@ const char *I_LocateWad(void) SetCurrentDirectoryA(waddir); #else waddir = realpath(waddir, NULL); - if (chdir(waddir) == -1) + if (waddir == NULL || chdir(waddir) == -1) I_OutputMsg("Couldn't change working directory\n"); #endif } diff --git a/src/tables.c b/src/tables.c index 491841c6e..bd8260be7 100644 --- a/src/tables.c +++ b/src/tables.c @@ -24,6 +24,7 @@ // fixed_t tantoangle[2049] - ArcTan LUT, // Maps tan(angle) to angle fast. Gotta search. +#include "doomdef.h" #include "tables.h" unsigned SlopeDiv(unsigned num, unsigned den) @@ -66,9 +67,9 @@ fixed_t AngleFixed(angle_t af) return rf; } -static FUNCMATH angle_t AngleAdj(const fixed_t fa, const fixed_t wf, - angle_t ra) +static FUNCMATH angle_t AngleAdj(const fixed_t fa, const fixed_t wf, angle_t ra) { + I_Assert(wf > 0); const angle_t adj = 0x77; const boolean fan = fa < 0; const fixed_t sl = FixedDiv(fa, wf*2); @@ -566,4 +567,4 @@ matrix_t *FM_RotateZ(matrix_t *dest, angle_t rad) return dest; } -#undef M \ No newline at end of file +#undef M diff --git a/src/v_video.c b/src/v_video.c index 50b9a6713..80f458d85 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -522,17 +522,16 @@ static void CV_constextsize_OnChange(void) // -------------------------------------------------------------------------- // Copy a rectangular area from one bitmap to another (8bpp) // -------------------------------------------------------------------------- -void VID_BlitLinearScreen(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT32 height, size_t srcrowbytes, - size_t destrowbytes) +void VID_BlitLinearScreen(const UINT8 *restrict srcptr, UINT8 *restrict destptr, INT32 width, INT32 height, size_t srcrowbytes, size_t destrowbytes) { - if (srcrowbytes == destrowbytes && srcrowbytes == width) + if (srcrowbytes == destrowbytes && srcrowbytes == (size_t)width) { size_t i = srcrowbytes * height; #if defined(__SSE__) while (i >= 16) { // TODO: find where the buffer is misaligned at times and align it - _mm_storeu_ps((float *)destptr, _mm_loadu_ps((const float *)srcptr)); + _mm_storeu_ps((void *)destptr, _mm_loadu_ps((const void *)srcptr)); srcptr += 16; destptr += 16; i -= 16; From f7378caf66488a09515ccb0385c6a539581b8f9c Mon Sep 17 00:00:00 2001 From: NepDisk Date: Fri, 17 Oct 2025 10:53:45 -0400 Subject: [PATCH 4/4] Use more vars for multireads to vid.height and vid.width --- src/r_draw.cpp | 22 +++++++++-------- src/r_draw_column.cpp | 9 ++++--- src/r_plane.cpp | 26 +++++++++++--------- src/r_segs.cpp | 5 ++-- src/r_splats.c | 17 ++++++------- src/r_things.cpp | 56 +++++++++++++++++++++++-------------------- 6 files changed, 75 insertions(+), 60 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index a95384c57..c42ede7e8 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -533,6 +533,8 @@ void R_FillBackScreen(void) UINT8 *src, *dest; patch_t *patch; INT32 x, y, step, boff; + const INT32 vidheight = vid.height; + const INT32 vidwidth = vid.width; // quickfix, don't cache lumps in both modes if (rendermode != render_soft) @@ -540,29 +542,29 @@ void R_FillBackScreen(void) // draw pattern around the status bar too (when hires), // so return only when in full-screen without status bar. - if (scaledviewwidth == vid.width && viewheight == vid.height) + if (scaledviewwidth == vidwidth && viewheight == vidheight) return; src = scr_borderpatch; dest = screens[1]; - for (y = 0; y < vid.height; y++) + for (y = 0; y < vidheight; y++) { - for (x = 0; x < vid.width/128; x++) + for (x = 0; x < vidwidth/128; x++) { M_Memcpy (dest, src+((y&127)<<7), 128); dest += 128; } - if (vid.width&127) + if (vidwidth&127) { - M_Memcpy(dest, src+((y&127)<<7), vid.width&127); - dest += (vid.width&127); + M_Memcpy(dest, src+((y&127)<<7), vidwidth&127); + dest += (vidwidth&127); } } - // don't draw the borders when viewwidth is full vid.width. - if (scaledviewwidth == vid.width) + // don't draw the borders when viewwidth is full vidwidth. + if (scaledviewwidth == vidwidth) return; step = 8; @@ -641,13 +643,13 @@ void R_DrawViewBorder(void) #ifdef DEBUG fprintf(stderr,"RDVB: vidwidth %d vidheight %d scaledviewwidth %d viewheight %d\n", - vid.width, vid.height, scaledviewwidth, viewheight); + vid.width, vidheight, scaledviewwidth, viewheight); #endif if (scaledviewwidth == vid.width) return; - top = (vid.height - viewheight)>>1; + top = (vidheight - viewheight)>>1; side = (vid.width - scaledviewwidth)>>1; // copy top and one line of left side diff --git a/src/r_draw_column.cpp b/src/r_draw_column.cpp index 297065ae0..38aa2cfed 100644 --- a/src/r_draw_column.cpp +++ b/src/r_draw_column.cpp @@ -99,6 +99,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc) { INT32 count; UINT8 *dest; + const INT32 vidheight = vid.height; const INT32 vidwidth = vid.width; count = dc->yh - dc->yl; @@ -108,7 +109,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc) return; } - if ((unsigned)dc->x >= (unsigned)vidwidth || dc->yl < 0 || dc->yh >= vid.height) + if ((unsigned)dc->x >= (unsigned)vidwidth || dc->yl < 0 || dc->yh >= vidheight) { return; } @@ -349,6 +350,7 @@ void R_DrawFogColumn(drawcolumndata_t *dc) INT32 count; UINT8 *dest; + const INT32 vidheight = vid.height; const INT32 vidwidth = vid.width; count = dc->yh - dc->yl; @@ -357,7 +359,7 @@ void R_DrawFogColumn(drawcolumndata_t *dc) if (count < 0) return; - if ((unsigned)dc->x >= (unsigned)vidwidth || dc->yl < 0 || dc->yh >= vid.height) + if ((unsigned)dc->x >= (unsigned)vidwidth || dc->yl < 0 || dc->yh >= vidheight) return; // Framebuffer destination address. @@ -417,6 +419,7 @@ void R_DrawColumn_Flat(drawcolumndata_t *dc) INT32 count; UINT8 color = dc->lightmap[dc->r8_flatcolor]; UINT8 *dest; + const INT32 vidheight = vid.height; const INT32 vidwidth = vid.width; count = dc->yh - dc->yl; @@ -424,7 +427,7 @@ void R_DrawColumn_Flat(drawcolumndata_t *dc) if (count < 0) // Zero length, column does not exceed a pixel. return; - if ((unsigned)dc->x >= (unsigned)vidwidth || dc->yl < 0 || dc->yh >= vid.height) + if ((unsigned)dc->x >= (unsigned)vidwidth || dc->yl < 0 || dc->yh >= vidheight) return; // Framebuffer destination address. diff --git a/src/r_plane.cpp b/src/r_plane.cpp index cded78e31..879fdd490 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -568,12 +568,14 @@ void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop) static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(drawspandata_t*), INT32, INT32, INT32, boolean), spandrawfunc_t* spanfunc, drawspandata_t* ds, INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2, boolean allow_parallel) { ZoneScoped; + const INT32 vidheight = vid.height; + const INT32 vidwidth = vid.width; // Alam: from r_splats's R_RasterizeFloorSplat - if (t1 >= vid.height) t1 = vid.height-1; - if (b1 >= vid.height) b1 = vid.height-1; - if (t2 >= vid.height) t2 = vid.height-1; - if (b2 >= vid.height) b2 = vid.height-1; - if (x-1 >= vid.width) x = vid.width; + if (t1 >= vidheight) t1 = vidheight-1; + if (b1 >= vidheight) b1 = vidheight-1; + if (t2 >= vidheight) t2 = vidheight-1; + if (b2 >= vidheight) b2 = vidheight-1; + if (x-1 >= vidwidth) x = vidwidth; // We want to draw N spans per subtask to ensure the work is // coarse enough to not be too slow due to task scheduling overhead. @@ -942,12 +944,13 @@ d.z = (v1.x * v2.y) - (v1.y * v2.x) void R_SetTiltedSpan(drawspandata_t* ds, INT32 span) { + const INT32 vidheight = vid.height; if (ds_su == NULL) - ds_su = static_cast(Z_Calloc(sizeof(*ds_su) * vid.height, PU_STATIC, NULL)); + ds_su = static_cast(Z_Calloc(sizeof(*ds_su) * vidheight, PU_STATIC, NULL)); if (ds_sv == NULL) - ds_sv = static_cast(Z_Calloc(sizeof(*ds_sv) * vid.height, PU_STATIC, NULL)); + ds_sv = static_cast(Z_Calloc(sizeof(*ds_sv) * vidheight, PU_STATIC, NULL)); if (ds_sz == NULL) - ds_sz = static_cast(Z_Calloc(sizeof(*ds_sz) * vid.height, PU_STATIC, NULL)); + ds_sz = static_cast(Z_Calloc(sizeof(*ds_sz) * vidheight, PU_STATIC, NULL)); ds->sup = ds_su[span]; ds->svp = ds_sv[span]; @@ -1000,6 +1003,7 @@ void R_DrawSinglePlane(drawspandata_t *ds, visplane_t *pl, boolean allow_paralle debugrender_highlight_t debug = debugrender_highlight_t::SW_HI_PLANES; void (*mapfunc)(drawspandata_t*, void(*)(drawspandata_t*), INT32, INT32, INT32, boolean) = R_MapPlane; INT16 highlight; + const INT32 vidwidth = vid.width; if (!(pl->minx <= pl->maxx)) return; @@ -1134,13 +1138,13 @@ void R_DrawSinglePlane(drawspandata_t *ds, visplane_t *pl, boolean allow_paralle } } - offset = (scry*vid.width) + scrx; + offset = (scry*vidwidth) + scrx; // No idea if this works VID_BlitLinearScreen(screens[0] + offset, - screens[1] + (top*vid.width), // intentionally not +offset + screens[1] + (top*vidwidth), // intentionally not +offset viewwidth, bottom-top, - vid.width, vid.width); + vidwidth, vidwidth); } } } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 4fe0d7d50..7de00301b 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -118,6 +118,7 @@ void R_ClearSegTables(void) static void R_Render2sidedMultiPatchColumn(drawcolumndata_t* dc, column_t *column, column_t *brightmap, INT32 baseclip) { INT32 topscreen, bottomscreen; + const INT32 vidheight = vid.height; topscreen = sprtopscreen; // + spryscale*column->topdelta; topdelta is 0 for the wall bottomscreen = topscreen + spryscale * lengthcol; @@ -141,10 +142,10 @@ static void R_Render2sidedMultiPatchColumn(drawcolumndata_t* dc, column_t *colum if (dc->yh >= baseclip && baseclip != -1) dc->yh = baseclip; - if (dc->yl >= vid.height || dc->yh < 0) + if (dc->yl >= vidheight || dc->yh < 0) return; - if (dc->yl <= dc->yh && dc->yh < vid.height && dc->yh > 0) + if (dc->yl <= dc->yh && dc->yh < vidheight && dc->yh > 0) { dc->source = (UINT8 *)column + 3; dc->sourcelength = lengthcol; diff --git a/src/r_splats.c b/src/r_splats.c index 9acbe9745..f4d27927e 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -313,6 +313,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr fixed_t planeheight = 0; fixed_t step; drawspandata_t ds = {0}; + const INT32 vidheight = vid.height; int spanfunctype = SPANDRAWFUNC_SPRITE; @@ -337,13 +338,13 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr } \ ry1 = 0; \ } \ - if (ry1 >= vid.height) { \ + if (ry1 >= vidheight) { \ if (step) { \ x1 <<= FRACBITS; \ - x1 -= (vid.height-1-ry1)*step; \ + x1 -= (vidheight-1-ry1)*step; \ x1 >>= FRACBITS; \ } \ - ry1 = vid.height - 1; \ + ry1 = vidheight - 1; \ } \ if (y2 < 0) { \ if (step) { \ @@ -353,13 +354,13 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr } \ y2 = 0; \ } \ - if (y2 >= vid.height) { \ + if (y2 >= vidheight) { \ if (step) { \ x2 <<= FRACBITS; \ - x2 += (vid.height-1-y2)*step; \ + x2 += (vidheight-1-y2)*step; \ x2 >>= FRACBITS; \ } \ - y2 = vid.height - 1; \ + y2 = vidheight - 1; \ } \ rasterize_segment_tex(x1, ry1, x2, y2, tv1, tv2, tc, dir); \ if (ry1 < miny) \ @@ -446,8 +447,8 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr R_SetSpanFunc(spanfunctype, !ds.powersoftwo, false); - if (maxy >= vid.height) - maxy = vid.height-1; + if (maxy >= vidheight) + maxy = vidheight-1; for (y = miny; y <= maxy; y++) { diff --git a/src/r_things.cpp b/src/r_things.cpp index e811d43ea..0e683ab9c 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -672,6 +672,7 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column, column_t *bright INT32 bottomscreen; fixed_t basetexturemid; INT32 topdelta, prevdelta = 0; + const INT32 vidheight = vid.height; basetexturemid = dc->texturemid; @@ -707,8 +708,8 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column, column_t *bright if (dc->yl < 0) dc->yl = 0; - if (dc->yh >= vid.height) // dc_yl must be < vid.height, so reduces number of checks in tight loop - dc->yh = vid.height - 1; + if (dc->yh >= vidheight) // dc_yl must be < vid.height, so reduces number of checks in tight loop + dc->yh = vidheight - 1; if (dc->yh >= baseclip && baseclip != -1) dc->yh = baseclip; @@ -759,6 +760,7 @@ void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column, column_t fixed_t basetexturemid = dc->texturemid; INT32 topdelta, prevdelta = -1; UINT8 *d,*s; + const INT32 vidheight = vid.height; R_SetColumnFunc(colfunctype, brightmap != NULL); dc->brightmap = NULL; @@ -797,8 +799,8 @@ void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column, column_t if (dc->yl < 0) dc->yl = 0; - if (dc->yh >= vid.height) // dc_yl must be < vid.height, so reduces number of checks in tight loop - dc->yh = vid.height - 1; + if (dc->yh >= vidheight) // dc_yl must be < vid.height, so reduces number of checks in tight loop + dc->yh = vidheight - 1; if (dc->yl <= dc->yh && dc->yh > 0 && column->length != 0) { @@ -921,6 +923,7 @@ static void R_DrawVisSprite(vissprite_t *vis) INT64 overflow_test; INT32 baseclip = -1; drawcolumndata_t dc {0}; + const INT32 vidwidth = vid.width; if (!patch) return; @@ -976,22 +979,22 @@ static void R_DrawVisSprite(vissprite_t *vis) dc.shadowcolor = vis->color; } else if (!(vis->cut & SC_PRECIP) && - R_ThingIsFlashing(vis->mobj)) // Bosses "flash" - { - R_SetColumnFunc(COLDRAWFUNC_TRANS, false); // translate certain pixels to white - } - else if (vis->transmap && dc.translation) // Color mapping - { - R_SetColumnFunc(COLDRAWFUNC_TRANSTRANS, false); - dc.transmap = vis->transmap; - } - else if (vis->transmap) - { - R_SetColumnFunc(COLDRAWFUNC_FUZZY, false); - dc.transmap = vis->transmap; //Fab : 29-04-98: translucency table - } - else if (dc.translation) // translate green skin to another color - R_SetColumnFunc(COLDRAWFUNC_TRANS, false); + R_ThingIsFlashing(vis->mobj)) // Bosses "flash" + { + R_SetColumnFunc(COLDRAWFUNC_TRANS, false); // translate certain pixels to white + } + else if (vis->transmap && dc.translation) // Color mapping + { + R_SetColumnFunc(COLDRAWFUNC_TRANSTRANS, false); + dc.transmap = vis->transmap; + } + else if (vis->transmap) + { + R_SetColumnFunc(COLDRAWFUNC_FUZZY, false); + dc.transmap = vis->transmap; //Fab : 29-04-98: translucency table + } + else if (dc.translation) // translate green skin to another color + R_SetColumnFunc(COLDRAWFUNC_TRANS, false); if (vis->extra_colormap && !(vis->cut & SC_FULLBRIGHT) && !(vis->renderflags & RF_NOCOLORMAPS)) { @@ -1062,8 +1065,8 @@ static void R_DrawVisSprite(vissprite_t *vis) vis->x1 = 0; } - if (vis->x2 >= vid.width) - vis->x2 = vid.width-1; + if (vis->x2 >= vidwidth) + vis->x2 = vidwidth-1; localcolfunc = (vis->cut & SC_VFLIP) ? R_DrawFlippedMaskedColumn : R_DrawMaskedColumn; lengthcol = patch->height; @@ -1128,8 +1131,8 @@ static void R_DrawVisSprite(vissprite_t *vis) if (x1test < 0) x1test = 0; - if (x2test >= vid.width) - x2test = vid.width-1; + if (x2test >= vidwidth) + x2test = vidwidth-1; const INT32 t = (vis->startfrac + (vis->xiscale * (x2test - x1test))) >> FRACBITS; @@ -1171,6 +1174,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) fixed_t this_scale = vis->thingscale; INT64 overflow_test; drawcolumndata_t dc {0}; + const INT32 vidwidth = vid.width; //Fab : R_InitSprites now sets a wad lump number patch = vis->patch; @@ -1210,8 +1214,8 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) if (vis->x1 < 0) vis->x1 = 0; - if (vis->x2 >= vid.width) - vis->x2 = vid.width-1; + if (vis->x2 >= vidwidth) + vis->x2 = vidwidth-1; for (dc.x = vis->x1; dc.x <= vis->x2; dc.x++, frac += vis->xiscale) {