From 48556ca428bd3fbec7c7aed5e2d01a083e98a6fa Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 4 Jul 2025 12:07:46 +0200 Subject: [PATCH 01/18] oop lmao --- src/k_hud.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 9ceb42860..dcd85cc27 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1970,8 +1970,8 @@ static void K_DrawKartPositionNum(INT32 num) if ((cv_posanim.value && stplyr->kartstuff[k_positiondelay]) || stplyr->exiting) { - const UINT8 delay = (stplyr->exiting) ? POS_DELAY_TIME : stplyr->positiondelay; - const fixed_t add = (scale * 3) >> ((r_splitscreen == 1) ? 1 : 2); + const UINT8 delay = (stplyr->exiting) ? POS_DELAY_TIME : stplyr->kartstuff[k_positiondelay]; + const fixed_t add = (scale * 3) >> ((splitscreen == 1) ? 1 : 2); scale = cv_smoothposition.value ? scale + min((add * (delay * delay)) / (POS_DELAY_TIME * POS_DELAY_TIME), add) : scale*2; overtake = true; // this is used for splitscreen stuff in conjunction with flipdraw. } From 4c0ea2695e5a73411ff21abf573979352bddf9a4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 4 Jul 2025 12:32:39 +0200 Subject: [PATCH 02/18] remove smoothpos cvar and add it as setting for "postitionanimation" cvar --- src/k_hud.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index dcd85cc27..c3b49bd3b 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -96,9 +96,9 @@ consvar_t cv_showminimapnames = {"showminimapnames", "Off", CV_SAVE, CV_OnOff, N CV_PossibleValue_t minimapdot_cons_t[NUMMINIMAPDOTSTUFF]; consvar_t cv_showminimapangle = {"showminimapangle", "Off", CV_SAVE, minimapdot_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_posanim = {"postitionanimation", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_smallposnum = {"smallpositionnumber", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_smoothposition = {"smoothposition", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t posanim_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}}; +consvar_t cv_posanim = {"postitionanimation", "On", CV_SAVE, posanim_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_smallposnum = {"smallpositionnumber", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showlapemblem = {"showlapemblem", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -211,7 +211,6 @@ void K_RegisterKartHudStuff(void) CV_RegisterVar(&cv_posanim); CV_RegisterVar(&cv_smallposnum); - CV_RegisterVar(&cv_smoothposition); CV_RegisterVar(&cv_fancyroulette); @@ -1970,9 +1969,15 @@ static void K_DrawKartPositionNum(INT32 num) if ((cv_posanim.value && stplyr->kartstuff[k_positiondelay]) || stplyr->exiting) { - const UINT8 delay = (stplyr->exiting) ? POS_DELAY_TIME : stplyr->kartstuff[k_positiondelay]; - const fixed_t add = (scale * 3) >> ((splitscreen == 1) ? 1 : 2); - scale = cv_smoothposition.value ? scale + min((add * (delay * delay)) / (POS_DELAY_TIME * POS_DELAY_TIME), add) : scale*2; + if (cv_posanim.value == 2) + { + const UINT8 delay = (stplyr->exiting) ? POS_DELAY_TIME : stplyr->kartstuff[k_positiondelay]; + const fixed_t add = (scale * 3) >> ((splitscreen == 1) ? 1 : 2); + scale = (scale + min((add * (delay * delay)) / (POS_DELAY_TIME * POS_DELAY_TIME), add)); + } + else + scale *= 2; + overtake = true; // this is used for splitscreen stuff in conjunction with flipdraw. } From 0df5ef996c9d08c05922ae2d4d4c83b3b53b30f5 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 4 Jul 2025 23:15:31 +0300 Subject: [PATCH 03/18] (kinda) unify LookupPlayer and nametonum, rename first into D_LookupPlayer --- src/d_clisrv.c | 27 ++++----------------------- src/d_netcmd.c | 7 +++---- src/d_netcmd.h | 1 + src/hu_stuff.c | 2 +- 4 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index da864f151..d85f824ba 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3508,31 +3508,12 @@ static void Command_GetPlayerNum(void) SINT8 nametonum(const char *name) { - INT32 playernum, i; + INT32 playernum = D_LookupPlayer(name); - if (!strcmp(name, "0")) - return 0; + if (playernum == -1) + CONS_Printf(M_GetText("There is no player named \"%s\"\n"), name); - playernum = (SINT8)atoi(name); - - if (playernum < 0 || playernum >= MAXPLAYERS) - return -1; - - if (playernum) - { - if (playeringame[playernum]) - return (SINT8)playernum; - else - return -1; - } - - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && !stricmp(player_names[i], name)) - return (SINT8)i; - - CONS_Printf(M_GetText("There is no player named \"%s\"\n"), name); - - return -1; + return playernum; } /** Lists all players and their player numbers. diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8a4e12ebf..52ad2ca1a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2082,7 +2082,7 @@ static void Command_ResetCamera_f(void) } /* Consider replacing nametonum with this */ -static INT32 LookupPlayer(const char *s) +INT32 D_LookupPlayer(const char *s) { INT32 playernum; @@ -2098,8 +2098,7 @@ static INT32 LookupPlayer(const char *s) for (playernum = 0; playernum < MAXPLAYERS; ++playernum) { /* Match name case-insensitively: fully, or partially the start. */ - if (playeringame[playernum]) - if (strnicmp(player_names[playernum], s, strlen(s)) == 0) + if (playeringame[playernum] && (strnicmp(player_names[playernum], s, strlen(s)) == 0)) { return playernum; } @@ -2210,7 +2209,7 @@ static void Command_View_f(void) } else { - if (( playernum = LookupPlayer(COM_Argv(1)) ) == -1) + if (( playernum = D_LookupPlayer(COM_Argv(1)) ) == -1) { CONS_Alert(CONS_WARNING, "There is no player by that name!\n"); return; diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 657686af4..1078de5d2 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -323,6 +323,7 @@ void ClearAdminPlayers(void); void RemoveAdminPlayer(INT32 playernum); void ItemFinder_OnChange(void); void D_SetPassword(const char *pw); +INT32 D_LookupPlayer(const char *s); // used for the player setup menu UINT8 CanChangeSkin(INT32 playernum); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index cd4c60dd8..1ea07a9cf 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -701,7 +701,7 @@ static void Command_Sayto_f(void) return; } - target = nametonum(COM_Argv(1)); + target = D_LookupPlayer(COM_Argv(1)); if (target == -1) { CONS_Alert(CONS_NOTICE, M_GetText("No player with that name!\n")); From ca34b0c8d66cd0e970f506a8601bab30d6e7654d Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 5 Jul 2025 00:27:17 +0300 Subject: [PATCH 04/18] Add /mute chat command --- src/d_clisrv.c | 5 +++++ src/d_clisrv.h | 2 ++ src/hu_stuff.c | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d85f824ba..905a5bb74 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -90,9 +90,12 @@ char motd[254], server_context[8]; // Message of the Day, Unique Context (even w plrinfo playerinfo[MAXPLAYERS]; SINT8 joinnode = 0; // used for CL_VIEWSERVER +boolean player_muted[MAXPLAYERS] = {0}; + // Server specific vars UINT8 playernode[MAXPLAYERS]; + // Minimum timeout for sending the savegame // The actual timeout will be longer depending on the savegame length tic_t jointimeout = (3*TICRATE); @@ -3488,6 +3491,8 @@ void CL_Reset(void) #endif G_ResetAllDeviceRumbles(); + memset(player_muted, 0, sizeof(player_muted)); + // D_StartTitle should get done now, but the calling function will handle it } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 7ba47cfd6..bf5005e64 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -671,6 +671,8 @@ SINT8 nametonum(const char *name); extern char motd[254], server_context[8]; extern UINT8 playernode[MAXPLAYERS]; +extern boolean player_muted[MAXPLAYERS]; + INT32 D_NumPlayers(void); void D_ResetTiccmds(void); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 1ea07a9cf..07ebdd26f 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -949,6 +949,9 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) else stop_spamming[playernum] = 4; // you can hold off for 4 tics, can you? + if (player_muted[playernum]) + spam_eatmsg = 1; // Let lua know we're skipping this message + // run the lua hook even if we were supposed to eat the msg, netgame consistency goes first. if (LUA_HookPlayerMsg(playernum, target, flags, msg, spam_eatmsg)) @@ -1179,6 +1182,23 @@ static boolean HU_clearChatSpaces(void) return nothingbutspaces; } +static void DoMute(const char *name) +{ + INT32 pnum = D_LookupPlayer(name); + + if (pnum < 0) + { + HU_AddChatText("\x85""ERROR: \x80Player not found.", false); + return; + } + + player_muted[pnum] = !player_muted[pnum]; + + HU_AddChatText(va("Player '%s' has been %smuted.", player_names[pnum], player_muted[pnum] ? "" : "un"), false); + if (player_muted[pnum]) + HU_AddChatText("Use same command to unmute them.", false); +} + static void HU_SendChatMessage(void) { char buf[2 + HU_MAXMSGLEN + 1]; @@ -1205,7 +1225,19 @@ static void HU_SendChatMessage(void) return; } - if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm + size_t len = strlen(msg); + + if (len >= 5 && strnicmp(msg, "/mute", 5) == 0) // Used /mute + { + if (len > 6) + DoMute(msg+6); + else + HU_AddChatText("\x82NOTICE: \x80Usage: /mute ", false); + + return; + } + + if (len > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm { INT32 spc = 1; // used if nodenum[1] is a space. char *nodenum = (char*) malloc(3); From 4e2f1bcf2b1475e3cf2c5719d1ddd2d639990ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Thu, 5 Jun 2025 19:23:20 +0200 Subject: [PATCH 05/18] Fix invalid formats being passed to interal texture formats The effects that this had on the engine is unknown, but the reference pages makes in very clear that the old behavior is wrong. --- src/hardware/r_opengl/r_opengl.c | 15 ++++++--------- src/sdl/ogl_sdl.c | 2 ++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index a8e9d6350..1fc319f0e 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -689,7 +689,7 @@ typedef enum gluniform_leveltime, gluniform_scr_resolution, - + gluniform_max, } gluniform_t; @@ -1803,7 +1803,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) case GL_TEXFMT_ALPHA_INTENSITY_88: GL_AllocTextureBuffer(pTexInfo); ptex = tex = textureBuffer; - texformat = GL_LUMINANCE_ALPHA; + texformat = GL_RGBA; for (idx = 0, j = 0; j < h; j++) { @@ -1821,7 +1821,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) case GL_TEXFMT_ALPHA_8: // Used for fade masks GL_AllocTextureBuffer(pTexInfo); ptex = tex = textureBuffer; - texformat = GL_ALPHA; + texformat = GL_RGBA; memset(&tex->s, 255, sizeof(byteColor_t)*w*h); // 255 because the fade mask is modulated with the screen texture, so alpha affects it while the colours don't @@ -1857,8 +1857,6 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) if (MipMap && !transparent) // No mipmaps on transparent stuff { - int maxlod = (texformat == GL_LUMINANCE_ALPHA || texformat == GL_ALPHA) ? 4 : 5; - pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); if (update) @@ -1868,7 +1866,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) // Control the mipmap level of detail pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, maxlod); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 5); } else { @@ -1892,7 +1890,6 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropic_filter); } - // -----------------+ // SetTexture : The mipmap becomes the current texture source // -----------------+ @@ -2735,7 +2732,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics poly.green = byte2float[Surface->PolyColor.s.green]; poly.blue = byte2float[Surface->PolyColor.s.blue]; poly.alpha = byte2float[Surface->PolyColor.s.alpha]; - + pglColor4ubv((GLubyte*)&Surface->PolyColor.s); GL_SetBlend(((poly.alpha < 1) ? Surface->PolyFlags : (PF_Masked|PF_Occlude))|PF_Modulated); @@ -2749,7 +2746,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics fade.green = byte2float[Surface->FadeColor.s.green]; fade.blue = byte2float[Surface->FadeColor.s.blue]; fade.alpha = byte2float[Surface->FadeColor.s.alpha]; - + if (Surface->LightTableId && Surface->LightTableId != lt_downloaded) { pglActiveTexture(GL_TEXTURE2); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index c8701506e..93609685c 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -237,6 +237,8 @@ boolean OglSdlSurface(INT32 w, INT32 h) first_init = true; + HWR_Startup(); + return true; } From 22f50402fec4825649da01769d09cb7d2b0bbc2a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 5 Jul 2025 15:51:15 +0200 Subject: [PATCH 06/18] remove this --- src/sdl/ogl_sdl.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 93609685c..c8701506e 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -237,8 +237,6 @@ boolean OglSdlSurface(INT32 w, INT32 h) first_init = true; - HWR_Startup(); - return true; } From 2aa53242252867d7a94892db8f0c9e1f17cc5944 Mon Sep 17 00:00:00 2001 From: BlueStaggo Date: Mon, 31 Mar 2025 18:04:53 +0000 Subject: [PATCH 07/18] Manual mipmapping + Texture padding --- src/hardware/r_opengl/r_opengl.c | 127 +++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 1fc319f0e..12d46942d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1729,6 +1729,114 @@ static void GL_AllocTextureBuffer(GLMipmap_t *pTexInfo) } } +#define PADDING_CHECK(offset, alphaCheck) { from = to + (offset); if ((alphaCheck)) from = NULL; else goto foundFrom; } + +static void PadRGBABitmap(RGBA_t *tex, UINT16 w, UINT16 h) +{ + INT32 i; + boolean notLeft, notRight, notTop, notBottom; + RGBA_t *to = tex - 1, *from; + + for (i = 0; i < w * h; i++) + { + to++; + if (to->rgba != 0) + continue; + from = NULL; + + notLeft = i % w != 0; + notRight = i % w != w - 1; + notTop = i / w != 0; + notBottom = i / w != h - 1; + + if (notRight) PADDING_CHECK(1, from->s.alpha == 0) // Check +X + if (notBottom) PADDING_CHECK(w, from->s.alpha == 0) // Check +Y + if (notLeft) PADDING_CHECK(-1, from->s.alpha == 0) // Check -X + if (notTop) PADDING_CHECK(-w, from->s.alpha == 0) // Check -Y + if (notRight && notBottom) PADDING_CHECK(1 + w, from->s.alpha == 0) // Check +X+Y + if (notLeft && notBottom) PADDING_CHECK(-1 + w, from->s.alpha == 0) // Check -X+Y + if (notLeft && notTop) PADDING_CHECK(-1 - w, from->s.alpha == 0) // Check -X-Y + if (notRight && notTop) PADDING_CHECK(1 - w, from->s.alpha == 0) // Check +X-Y + +foundFrom: + if (from != NULL) + { + *to = *from; + to->s.alpha = 0; + } + } +} + +#undef PADDING_CHECK + +static void GenerateMipmaps(INT32 w, INT32 h, RGBA_t *tex, INT32 maxLOD) +{ + if (tex == NULL) + { + GL_MSG_Warning("GenerateMipmaps: attempted to generate mipmaps without texture data"); + return; + } + + RGBA_t samplePoint[4]; + boolean padTexture; + INT32 pointsSampled = 0; + INT32 m, j, i, p; + UINT16 sumR, sumG, sumB, sumA; + + for (m = 0; m < maxLOD; m++) + { + if (w <= 1 || h <= 1) + return; + + padTexture = false; + + for (j = 0; j < h / 2; j++) + { + for (i = 0; i < w / 2; i++) + { + samplePoint[0] = tex[w*j*2 + i*2]; + samplePoint[1] = tex[w*j*2 + i*2+1]; + samplePoint[2] = tex[w*(j*2+1) + i*2]; + samplePoint[3] = tex[w*(j*2+1) + i*2+1]; + + pointsSampled = sumR = sumG = sumB = sumA = 0; + + for (p = 0; p < 4; p++) + { + if (samplePoint[p].s.alpha == 0) + continue; + sumR += samplePoint[p].s.red; + sumG += samplePoint[p].s.green; + sumB += samplePoint[p].s.blue; + sumA += samplePoint[p].s.alpha; + pointsSampled++; + } + + if (pointsSampled > 0) + { + tex[(w/2)*j+i].s.red = sumR / pointsSampled; + tex[(w/2)*j+i].s.green = sumG / pointsSampled; + tex[(w/2)*j+i].s.blue = sumB / pointsSampled; + tex[(w/2)*j+i].s.alpha = sumA / pointsSampled; + } + else + { + tex[(w/2)*j+i].rgba = 0; + padTexture = true; + } + } + } + + w /= 2; + h /= 2; + + if (padTexture) + PadRGBABitmap(tex, w, h); + + pglTexSubImage2D(GL_TEXTURE_2D, m + 1, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, tex); + } +} + // -----------------+ // UpdateTexture : Updates texture data. // -----------------+ @@ -1737,6 +1845,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) // Upload a texture GLuint num = pTexInfo->downloaded; boolean update = true; + const boolean applyPadding = mag_filter == GL_LINEAR || min_filter == GL_LINEAR; INT32 w = pTexInfo->width, h = pTexInfo->height; INT32 i, j; @@ -1795,10 +1904,27 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) pImgData++; } } + + if (applyPadding) + PadRGBABitmap(tex, w, h); + break; case GL_TEXFMT_RGBA: // Directly upload the texture data without any kind of conversion. ptex = pImgData; + + // However, it does need to be copied to a buffer for generating mipmaps and padding + if (MipMap || applyPadding) + { + AllocTextureBuffer(pTexInfo); + tex = textureBuffer; + memcpy(tex, ptex, w * h * 4); + ptex = tex; + + if (applyPadding) + PadRGBABitmap(tex, w, h); + } + break; case GL_TEXFMT_ALPHA_INTENSITY_88: GL_AllocTextureBuffer(pTexInfo); @@ -1867,6 +1993,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) // Control the mipmap level of detail pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 5); + GenerateMipmaps(w, h, tex, 5); } else { From fe5a0b7c64c6dedbcb19310224f686bd5d0f7a65 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 5 Jul 2025 15:36:27 +0200 Subject: [PATCH 08/18] GL_ --- src/hardware/r_opengl/r_opengl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 12d46942d..497b1b08a 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1916,7 +1916,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo) // However, it does need to be copied to a buffer for generating mipmaps and padding if (MipMap || applyPadding) { - AllocTextureBuffer(pTexInfo); + GL_AllocTextureBuffer(pTexInfo); tex = textureBuffer; memcpy(tex, ptex, w * h * 4); ptex = tex; From 3b34f0a972d4e320ac6c09fc0136e1d258509984 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 6 Jul 2025 15:48:18 +0300 Subject: [PATCH 09/18] Sort replays in replay hut --- src/m_menu.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index 6a7ce2294..99d4057cb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6872,6 +6872,32 @@ static void M_HutCheckReplays(size_t maxnum) } } +static int ReplayListSortComparator(const void *entry1, const void *entry2) +{ + const menudemo_t *demo1 = (const menudemo_t*)entry1; + const menudemo_t *demo2 = (const menudemo_t*)entry2; + + char filepath1[sizeof(demo1->filepath)]; + char filepath2[sizeof(demo2->filepath)]; + + // First check for directories, they always should be at the top + if (demo1->type == MD_SUBDIR && demo2->type != MD_SUBDIR) + return -1; + else if (demo2->type == MD_SUBDIR && demo1->type != MD_SUBDIR) + return 1; + else if (demo1->type == MD_SUBDIR && demo2->type == MD_SUBDIR) + return 0; + + memcpy(filepath1, demo1->filepath, sizeof(filepath1)); + memcpy(filepath2, demo2->filepath, sizeof(filepath2)); + + nameonly(filepath1); + nameonly(filepath2); + + // Comparing in opposite order to move new replays to the top + return strncmp(filepath2, filepath1, sizeof(filepath1)); +} + static void PrepReplayList(boolean reset) { size_t i; @@ -6915,6 +6941,8 @@ static void PrepReplayList(boolean reset) } } + qs22j(demolist_all, sizedirmenu, sizeof(menudemo_t), ReplayListSortComparator); + Unlock_search_state(); LoadReplayNames(); From 96f5a8adb3ac1511bef81c19deaddd913e251f1a Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 7 Jul 2025 21:47:48 +0200 Subject: [PATCH 10/18] fix for non pow2 width textures in software from doom-legacy --- src/r_data.c | 33 ++++++++++++++++++++++++++++++++- src/r_data.h | 1 - src/r_segs.cpp | 10 +++++++--- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 7ac8ffe2d..058177307 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -473,11 +473,28 @@ UINT8 *R_GetColumn(fixed_t tex, INT32 col) { UINT8 *data; - col &= texturewidthmask[tex]; data = texturecache[tex]; + const INT16 texwidth = textures[tex]->width; + + if (texturewidthmask[tex]) + col &= texturewidthmask[tex]; // set by load textures + else + { + // Odd width texture, cannot just mask. + // Sometime gets colnum = -1 or = width, even without tiling. + // Test LostCiv, Map 20, crates. + col = ( col < 0 ) ? + texwidth - (((-col - 1) % texwidth) + 1) + : col % texwidth; + } + if (!data) + { + // This must be here because cache can be freed by other operations. + // To prevent must lock individual texture cache on every draw. data = R_GenerateTexture(tex); + } return data + LONG(texturecolumnofs[tex][col]); } @@ -662,9 +679,23 @@ void R_LoadTextures(void) Z_Free(patchlump); + // determine width power of 2 +#if 1 + // [WDJ] only need to determine if exact power of 2. + k = 1; + while (k < texture->width) + k<<=1; +#else + // Largest power of 2 that fits within width. k = 1; while (k << 1 <= texture->width) k <<= 1; +#endif + if (k != texture->width) + { + // Odd width + k = 1; // make texturewidthmask = 0 + } texturewidthmask[i] = k - 1; textureheight[i] = texture->height << FRACBITS; diff --git a/src/r_data.h b/src/r_data.h index c3abab0c1..575866478 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -55,7 +55,6 @@ typedef struct UINT8 type; // TEXTURETYPE_ INT16 width, height; boolean holes; - // All the patches[patchcount] are drawn back to front into the cached texture. INT16 patchcount; texpatch_t patches[0]; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 452d1eb8e..6bc139a2d 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -306,8 +306,10 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 else dc->texturemid -= (textureheight[texnum])*times; + const INT16 colnum = maskedtexturecol[dc->x]; + // calculate lighting - if (maskedtexturecol[dc->x] != INT16_MAX) + if (colnum != INT16_MAX) { // Check for overflows first if (R_OverflowTest(dc)) @@ -337,7 +339,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 dc->iscale = 0xffffffffu / (unsigned)spryscale; // draw the texture - col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc->x]) - 3); + col = (column_t *)((UINT8 *)R_GetColumn(texnum, colnum) - 3); auto set_light_vars = [&](INT32 k) { @@ -434,7 +436,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 dc->iscale = 0xffffffffu / (unsigned)spryscale; // draw the texture - col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc->x]) - 3); + col = (column_t *)((UINT8 *)R_GetColumn(texnum, colnum) - 3); colfunc_2s(dc, col); } @@ -1190,6 +1192,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc) INT32 bottom; INT32 i; + // Loop over width for (; rw_x < rw_stopx; rw_x++) { // mark floor / ceiling areas @@ -1563,6 +1566,7 @@ static void R_MarkSegBounds(void) INT32 top, bottom; INT16 topclip, bottomclip; + // Loop over width for (; rw_x < rw_stopx; rw_x++) { // mark floor / ceiling areas From 8d570b7ba3e28014313b4a43926d79c5ce4c2ca4 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 8 Jul 2025 00:09:52 +0300 Subject: [PATCH 11/18] Revert "Disable multithreading in R_DrawMaskedList" This reverts commit 5a44afcd9fdee9be513bfca839a2483941331391. --- src/r_things.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 8f99384c8..7b5c51b4b 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2970,8 +2970,16 @@ static void R_DrawMaskedList(drawnode_t* head) { drawspandata_t ds = {}; next = r2->prev; - // Force disable multithreading since it is usually slower because of waiting for each plane to render - R_DrawSinglePlane(&ds, r2->plane, false); +#ifdef HAVE_THREADS + srb2::ThreadPool::Sema tp_sema; + srb2::g_main_threadpool->begin_sema(); +#endif + R_DrawSinglePlane(&ds, r2->plane, cv_parallelsoftware.value); +#ifdef HAVE_THREADS + tp_sema = srb2::g_main_threadpool->end_sema(); + srb2::g_main_threadpool->notify_sema(tp_sema); + srb2::g_main_threadpool->wait_sema(tp_sema); +#endif R_DoneWithNode(r2); r2 = next; } From a26867bbdb869767a7fe8b02b1748cebeda754ac Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 8 Jul 2025 00:36:25 +0300 Subject: [PATCH 12/18] Add separate option to toggle parallel rendering in R_DrawMaskedList --- src/d_netcmd.c | 1 + src/r_things.cpp | 15 ++++++++++----- src/screen.c | 1 + src/screen.h | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 52ad2ca1a..0d14733da 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1026,6 +1026,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_scr_height); CV_RegisterVar(&cv_parallelsoftware); + CV_RegisterVar(&cv_paralleldrawmasked); CV_RegisterVar(&cv_soundtest); diff --git a/src/r_things.cpp b/src/r_things.cpp index 7b5c51b4b..542b271a7 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2970,15 +2970,20 @@ static void R_DrawMaskedList(drawnode_t* head) { drawspandata_t ds = {}; next = r2->prev; + boolean parallel = cv_parallelsoftware.value && cv_paralleldrawmasked.value; #ifdef HAVE_THREADS srb2::ThreadPool::Sema tp_sema; - srb2::g_main_threadpool->begin_sema(); + if (parallel) + srb2::g_main_threadpool->begin_sema(); #endif - R_DrawSinglePlane(&ds, r2->plane, cv_parallelsoftware.value); + R_DrawSinglePlane(&ds, r2->plane, parallel); #ifdef HAVE_THREADS - tp_sema = srb2::g_main_threadpool->end_sema(); - srb2::g_main_threadpool->notify_sema(tp_sema); - srb2::g_main_threadpool->wait_sema(tp_sema); + if (parallel) + { + tp_sema = srb2::g_main_threadpool->end_sema(); + srb2::g_main_threadpool->notify_sema(tp_sema); + srb2::g_main_threadpool->wait_sema(tp_sema); + } #endif R_DoneWithNode(r2); r2 = next; diff --git a/src/screen.c b/src/screen.c index 40e932442..eb6c2bc82 100644 --- a/src/screen.c +++ b/src/screen.c @@ -49,6 +49,7 @@ consvar_t cv_vhseffect = {"vhspause", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NU consvar_t cv_shittyscreen = {"televisionsignal", "Okay", CV_NOSHOWHELP, shittyscreen_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_parallelsoftware = {"parallelsoftware", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_paralleldrawmasked = {"paralleldrawmasked", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t votescale_cons_t[] = {{0, "Vanilla"}, {1, "Adaptive"}, {2, "VerticalFill"}, {3, "HorizontalFill"}, {0, NULL}}; consvar_t cv_votebgscaling = {"votebgscaling", "Adaptive", CV_SAVE, votescale_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/screen.h b/src/screen.h index c0a2799c1..38483b28d 100644 --- a/src/screen.h +++ b/src/screen.h @@ -88,6 +88,7 @@ extern UINT8 *scr_borderpatch; // patch used to fill the view borders extern consvar_t cv_scr_width, cv_scr_height, cv_renderview, cv_fullscreen, cv_vhseffect, cv_shittyscreen; extern consvar_t cv_parallelsoftware; +extern consvar_t cv_paralleldrawmasked; extern consvar_t cv_highreshudscale; // wait for page flipping to end or not From bd48b24000ab69f59f81f516f2fb5bdaeed2b6f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 8 Jul 2025 00:58:50 +0200 Subject: [PATCH 13/18] some micro optimize --- src/r_plane.cpp | 89 +++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 47 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 653353a2b..336217cd0 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -247,9 +247,7 @@ static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc, INT32 ds->bgofs = -y; } - pindex = distance >> LIGHTZSHIFT; - if (pindex >= MAXLIGHTZ) - pindex = MAXLIGHTZ - 1; + pindex = std::min(distance >> LIGHTZSHIFT, MAXLIGHTZ - 1); ds->colormap = ds->planezlight[pindex]; @@ -352,8 +350,8 @@ void R_ClearPlanes(void) angle = (viewangle-ANGLE_90)>>ANGLETOFINESHIFT; // scale will be unit scale at SCREENWIDTH/2 distance - basexscale = FixedDiv (FINECOSINE(angle), centerxfrac); - baseyscale = -FixedDiv (FINESINE(angle), centerxfrac); + basexscale = FixedDiv (FINECOSINE(angle), centerxfrac); + baseyscale = -FixedDiv (FINESINE(angle), centerxfrac); } static visplane_t *new_visplane(unsigned hash) @@ -442,26 +440,20 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, } } - // This appears to fix the Nimbus Ruins sky bug. - if (picnum == skyflatnum && pfloor) - { - height = 0; // all skies map together - lightlevel = 0; - } - else if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector)) - { - if (reverseLight) - { - lightlevel -= slope->lightOffset * 8; - } - else - { - lightlevel += slope->lightOffset * 8; - } - } - if (!pfloor) { + if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector)) + { + if (reverseLight) + { + lightlevel -= slope->lightOffset * 8; + } + else + { + lightlevel += slope->lightOffset * 8; + } + } + hash = visplane_hash(picnum, lightlevel, height); for (check = visplanes[hash]; check; check = check->next) @@ -485,6 +477,13 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, } else { + // This appears to fix the Nimbus Ruins sky bug. + if (picnum == skyflatnum) + { + height = 0; // all skies map together + lightlevel = 0; + } + hash = MAXVISPLANES - 1; } @@ -592,6 +591,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop) memset(pl->top, 0xff, sizeof(*pl->top) * viewwidth); memset(pl->bottom, 0x00, sizeof(*pl->bottom) * viewwidth); } + return pl; } @@ -628,9 +628,9 @@ static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(draw if (b2 >= vidheight) b2 = vidheight-1; if (x-1 >= vid.width) x = vid.width; - drawspandata_t dc_copy = *ds; - #ifdef HAVE_THREADS + drawspandata_t ds_copy = *ds; + // 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. // To safely do this, we need to copy part of spanstart to a local. @@ -652,7 +652,7 @@ static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(draw auto task = [=]() mutable -> void { for (int i = 0; i < taskspans; i++) { - mapfunc(&dc_copy, localspanfunc, t1 + i, spanstartcopy[i], x - 1, false); + mapfunc(&ds_copy, localspanfunc, t1 + i, spanstartcopy[i], x - 1, false); } }; if (allow_parallel) @@ -681,7 +681,7 @@ static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(draw auto task = [=]() mutable -> void { for (int i = 0; i < taskspans; i++) { - mapfunc(&dc_copy, localspanfunc, b1 - i, spanstartcopy[i], x - 1, false); + mapfunc(&ds_copy, localspanfunc, b1 - i, spanstartcopy[i], x - 1, false); } }; if (allow_parallel) @@ -699,12 +699,12 @@ static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(draw while (t1 < t2 && t1 <= b1) { - mapfunc(&dc_copy, localspanfunc, t1, spanstart[t1], x - 1, false); + mapfunc(ds, localspanfunc, t1, spanstart[t1], x - 1, false); t1++; } while (b1 > b2 && b1 >= t1) { - mapfunc(&dc_copy, localspanfunc, b1, spanstart[b1], x - 1, false); + mapfunc(ds, localspanfunc, b1, spanstart[b1], x - 1, false); b1--; } #endif @@ -1022,11 +1022,9 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle ffloor_t *rover; void (*mapfunc)(drawspandata_t*, void(*)(drawspandata_t*), INT32, INT32, INT32, boolean) = R_MapPlane; - if (!(pl->minx <= pl->maxx)) + if (pl->minx > pl->maxx) return; - R_UpdatePlaneRipple(ds); - // sky flat if (pl->picnum == skyflatnum) { @@ -1039,6 +1037,8 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle return; } + R_UpdatePlaneRipple(ds); + ds->planeripple.active = false; R_SetSpanFunc(BASEDRAWFUNC); @@ -1175,12 +1175,6 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle else light = (pl->lightlevel >> LIGHTSEGSHIFT); } - // Don't mess with angle on slopes! We'll handle this ourselves later - if (!pl->slope && viewangle != pl->viewangle+pl->plangle) - { - viewangle = pl->viewangle+pl->plangle; - } - ds->currentplane = pl; ds->source = (UINT8 *)W_CacheLumpNum(levelflats[pl->picnum].lumpnum, PU_STATIC); // Stay here until Z_ChangeTag @@ -1235,11 +1229,7 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle ds->xoffs = pl->xoffs; ds->yoffs = pl->yoffs; - if (light >= LIGHTLEVELS) - light = LIGHTLEVELS-1; - - if (light < 0) - light = 0; + light = CLAMP(light, 0, LIGHTLEVELS-1); if (pl->slope) { @@ -1292,6 +1282,12 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle } else { + // Don't mess with angle on slopes! We'll handle this ourselves later + if (viewangle != pl->viewangle + pl->plangle) + { + viewangle = pl->viewangle + pl->plangle; + } + ds->planeheight = abs(pl->height - pl->viewz); ds->planezlight = zlight[light]; } @@ -1299,10 +1295,8 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle R_SetSpanFunc(spanfunctype); // set the maximum value for unsigned - pl->top[pl->maxx+1] = 0xffff; - pl->top[pl->minx-1] = 0xffff; - pl->bottom[pl->maxx+1] = 0x0000; - pl->bottom[pl->minx-1] = 0x0000; + pl->top[pl->maxx+1] = pl->top[pl->minx-1] = 0xffff; + pl->bottom[pl->maxx+1] = pl->bottom[pl->minx-1] = 0x0000; stop = pl->maxx + 1; @@ -1403,6 +1397,7 @@ void R_PlaneBounds(visplane_t *plane) if (plane->bottom[i] > low) low = plane->bottom[i]; } + plane->high = hi; plane->low = low; } From 96bc7f7aa648ff7f568a03ec9754df855ee468e8 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Mon, 7 Jul 2025 23:19:30 +0200 Subject: [PATCH 14/18] Fix fake floors in Donut Plains disappearing when chasecam is off Also remove the useless R_PointInSubsector calls --- src/r_bsp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 482b7c57f..3b2a24d96 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -198,10 +198,10 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, boolean underwater; UINT8 i = R_GetViewNumber(); - if (viewplayer == &players[displayplayers[i]] && camera[i].chase) - heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec; - else if (i > splitscreen && viewmobj) - heightsec = R_PointInSubsector(pviewmobj->x, pviewmobj->y)->sector->heightsec; + if (viewplayer == &players[displayplayers[i]] && camera[R_GetViewNumber()].chase) + heightsec = camera->subsector->sector->heightsec; + else if (viewmobj) + heightsec = pviewmobj->subsector->sector->heightsec; else return sec; From d2c73f072e93779ad2cb9f69c798ff099efc52e1 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 8 Jul 2025 12:01:27 +0200 Subject: [PATCH 15/18] reuse "i" --- src/r_bsp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 3b2a24d96..0e81a4198 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -198,7 +198,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, boolean underwater; UINT8 i = R_GetViewNumber(); - if (viewplayer == &players[displayplayers[i]] && camera[R_GetViewNumber()].chase) + if (viewplayer == &players[displayplayers[i]] && camera[i].chase) heightsec = camera->subsector->sector->heightsec; else if (viewmobj) heightsec = pviewmobj->subsector->sector->heightsec; From dc24de35016a48b9da08dbc2175633a06c0c1379 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 8 Jul 2025 13:47:36 +0200 Subject: [PATCH 16/18] fix color translated spans lmao oopsie well atleast we got some extra safety with the spandata source lel --- src/r_draw_span.cpp | 15 ++++++++++++++- src/r_plane.cpp | 15 +++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/r_draw_span.cpp b/src/r_draw_span.cpp index cf7878184..a8ed71008 100644 --- a/src/r_draw_span.cpp +++ b/src/r_draw_span.cpp @@ -46,10 +46,23 @@ enum DrawSpanType DS_RIPPLE = 0x0008, }; +template +static constexpr UINT8 R_GetSpanTranslated(drawspandata_t* ds, UINT8 col) +{ + if constexpr (Type & DrawSpanType::DS_COLORMAP) + { + return ds->translation[col]; + } + else + { + return col; + } +} + template static constexpr UINT8 R_GetSpanTranslucent(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT8 col) { - col = colormap[col]; + col = colormap[R_GetSpanTranslated(ds, col)]; if constexpr (Type & DrawSpanType::DS_TRANSMAP) { diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 336217cd0..40a58f165 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -629,13 +629,12 @@ static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(draw if (x-1 >= vid.width) x = vid.width; #ifdef HAVE_THREADS - drawspandata_t ds_copy = *ds; - // 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. // To safely do this, we need to copy part of spanstart to a local. // This is essentially loop unrolling across threads. constexpr const int kSpanTaskGranularity = 8; + drawspandata_t ds_copy = *ds; while (t1 < t2 && t1 <= b1) { INT32 spanstartcopy[kSpanTaskGranularity] = {0}; @@ -1020,6 +1019,7 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle size_t size; INT32 spanfunctype = BASEDRAWFUNC; ffloor_t *rover; + levelflat_t *levelflat; void (*mapfunc)(drawspandata_t*, void(*)(drawspandata_t*), INT32, INT32, INT32, boolean) = R_MapPlane; if (pl->minx > pl->maxx) @@ -1177,8 +1177,15 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle ds->currentplane = pl; - ds->source = (UINT8 *)W_CacheLumpNum(levelflats[pl->picnum].lumpnum, PU_STATIC); // Stay here until Z_ChangeTag - size = W_LumpLength(levelflats[pl->picnum].lumpnum); + levelflat = &levelflats[pl->picnum]; + + // Get the texture + ds->source = (UINT8 *)W_CacheLumpNum(levelflat->lumpnum, PU_STATIC); // Stay here until Z_ChangeTag + + if (ds->source == NULL) + return; + + size = W_LumpLength(levelflat->lumpnum); switch (size) { From f2d68b075c3cb62dcfed5e30804bb0c8add84715 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 8 Jul 2025 13:48:04 +0200 Subject: [PATCH 17/18] texturewidthmask can be static --- src/r_data.c | 6 +++--- src/r_data.h | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 058177307..f3731c3fc 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -103,7 +103,7 @@ static UINT32 **texturecolumnofs; // column offset lookup table for each texture UINT8 **texturecache; // graphics data for each generated full-size texture // texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask -INT32 *texturewidthmask; +static INT32 *texturewidthmask; fixed_t *textureheight; // needed for texture pegging @@ -475,12 +475,12 @@ UINT8 *R_GetColumn(fixed_t tex, INT32 col) data = texturecache[tex]; - const INT16 texwidth = textures[tex]->width; - if (texturewidthmask[tex]) col &= texturewidthmask[tex]; // set by load textures else { + const INT16 texwidth = textures[tex]->width; + // Odd width texture, cannot just mask. // Sometime gets colnum = -1 or = width, even without tiling. // Test LostCiv, Map 20, crates. diff --git a/src/r_data.h b/src/r_data.h index 575866478..58afc34d0 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -64,9 +64,6 @@ typedef struct extern texture_t **textures; extern UINT8 **texturecache; // graphics data for each generated full-size texture -// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask -extern INT32 *texturewidthmask; - extern fixed_t *textureheight; // needed for texture pegging UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha); From a554b886c6fd35891e82f56556a7cb478ac0b9cd Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 8 Jul 2025 14:23:23 +0200 Subject: [PATCH 18/18] fix peeindex overflow lelelele thx indev <3 --- src/r_plane.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 40a58f165..499e302ac 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -247,7 +247,7 @@ static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc, INT32 ds->bgofs = -y; } - pindex = std::min(distance >> LIGHTZSHIFT, MAXLIGHTZ - 1); + pindex = std::min(distance >> LIGHTZSHIFT, MAXLIGHTZ - 1); ds->colormap = ds->planezlight[pindex];