From 72d336071116800e11395e6a809614bcae39c7d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 15:59:47 +0200 Subject: [PATCH 01/30] delet this this doesent exist anymore lol --- src/d_netcmd.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index c9520f1a7..d16d2331f 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -51,10 +51,6 @@ extern consvar_t cv_mousevisible; //WTF extern consvar_t cv_mouseturn; extern consvar_t cv_usejoystick[4]; //MAXSPLITSCREENPLAYERS -#ifdef LJOYSTICK -extern consvar_t cv_joyport; -extern consvar_t cv_joyport2; -#endif extern consvar_t cv_joyscale[4]; //MAXSPLITSCREENPLAYERS // normally in p_mobj but the .h is not read From 761766d353de25972a6381c32e2117a9d48be80e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 16:18:49 +0200 Subject: [PATCH 02/30] whitespace fix --- src/sdl/mixer_sound.c | 4 ++-- src/sounds.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index f177412e7..be67b69eb 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -945,7 +945,7 @@ UINT32 I_GetSongLength(void) boolean I_SetSongLoopPoint(UINT32 looppoint) { - if (!music|| !is_looping) + if (!music || !is_looping) return false; const musictype_t mustype = I_SongType(); @@ -958,7 +958,7 @@ boolean I_SetSongLoopPoint(UINT32 looppoint) if (length > 0) looppoint %= length; - loop_point = max((float)(looppoint / 1000.0L), 0); + loop_point = max((float)(looppoint / 1000.0L), 0.0f); return true; } diff --git a/src/sounds.c b/src/sounds.c index dbd5478bd..611539abe 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1040,6 +1040,7 @@ sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean return i; } } + I_Error("Out of Sound Freeslots while allocating \"%s\"\nLoad less addons to fix this.", name); return 0; } From 1ac029edc6f730a430a7dbbb4c7f35abb732cb3e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 20:04:48 +0200 Subject: [PATCH 03/30] optimize CL_CheckFiles a bit the "already loaded" check will not first compare the md5sum, which is a very simple memcmp, and only then it will do string copies, nameonly mutation and name compare should the md5sum match this should save quite a few unnecessary string operations since the md5 match case will rarely ever hit --- src/d_netfil.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 8865ab618..8e6888e7d 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -549,7 +549,7 @@ INT32 CL_CheckFiles(void) if (fileneeded[i].status != FS_OPEN) filestoload++; - if (fileneeded[i].status != FS_NOTCHECKED) //since we're running this over multiple tics now, its possible for us to come across files checked in previous tics + if (fileneeded[i].status != FS_NOTCHECKED) // since we're running this over multiple tics now, its possible for us to come across files checked in previous tics continue; CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename); @@ -557,14 +557,17 @@ INT32 CL_CheckFiles(void) // Check in already loaded files for (j = mainwads+1; j < numwadfiles; j++) { - nameonly(strcpy(wadfilename, wadfiles[j]->filename)); - - if (fasticmp(wadfilename, fileneeded[i].filename) && - !memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16)) + if (!memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16)) { - CONS_Debug(DBG_NETPLAY, "already loaded\n"); - fileneeded[i].status = FS_OPEN; - return 4; + strcpy(wadfilename, wadfiles[j]->filename); + nameonly(wadfilename); + + if (fasticmp(wadfilename, fileneeded[i].filename)) + { + CONS_Debug(DBG_NETPLAY, "already loaded\n"); + fileneeded[i].status = FS_OPEN; + return 4; + } } } @@ -645,7 +648,7 @@ boolean CL_LoadServerFiles(void) else { const char *s; - switch(fileneeded[i].status) + switch (fileneeded[i].status) { case FS_NOTFOUND: s = "FS_NOTFOUND"; @@ -1066,7 +1069,7 @@ void Got_Filetxpak(void) { const char *s; - switch(file->status) + switch (file->status) { case FS_NOTFOUND: s = "FS_NOTFOUND"; @@ -1194,7 +1197,7 @@ filestatus_t checkfilemd5(char *filename, const UINT8 *wantedmd5sum) fhandle = fopen(filename, "rb"); if (fhandle) { - md5_stream(fhandle,md5sum); + md5_stream(fhandle, md5sum); fclose(fhandle); if (!memcmp(wantedmd5sum, md5sum, 16)) return FS_FOUND; From a3f557f4df9b2a17c394575ed47ed8cd1e2e39d2 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 20:06:59 +0200 Subject: [PATCH 04/30] SV_SendFile: check if I_GetNodeAddress is set before use --- src/d_netfil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 8e6888e7d..8ad9cf07d 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -691,7 +691,7 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid) char wadfilename[MAX_WADPATH]; - if (cv_noticedownload.value) + if (cv_noticedownload.value && I_GetNodeAddress) CONS_Printf("Sending file \"%s\" (id %d) to node %d (%s)\n", filename, fileid, node, I_GetNodeAddress(node)); // Find the last file in the list and set a pointer to its "next" field From df9a23a6c7e9d8d10edc3398833bcd69ae7d6d88 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 20:20:20 +0200 Subject: [PATCH 05/30] CL_CheckFiles: avoid using strcpy wadfile->filename has not a fixed size, so it theoretically might be bigger than wadfilename buffer this probably wont ever happen but better be safe than sorry honestly --- src/d_netfil.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 8ad9cf07d..ff9b1061a 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -559,7 +559,8 @@ INT32 CL_CheckFiles(void) { if (!memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16)) { - strcpy(wadfilename, wadfiles[j]->filename); + strncpy(wadfilename, wadfiles[j]->filename, MAX_WADPATH); + wadfilename[MAX_WADPATH-1] = '\0'; nameonly(wadfilename); if (fasticmp(wadfilename, fileneeded[i].filename)) From 667c67a61aa33d2564498af2e8ee2df62a14e851 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 20:43:11 +0200 Subject: [PATCH 06/30] also avoid strcpy for PutFileNeeded --- src/d_netfil.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index ff9b1061a..61852b436 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -167,7 +167,9 @@ UINT8 *PutFileNeeded(UINT16 firstfile) continue; } - nameonly(strcpy(wadfilename, wadfiles[i]->filename)); + strncpy(wadfilename, wadfiles[i]->filename, MAX_WADPATH); + wadfilename[MAX_WADPATH-1] = '\0'; + nameonly(wadfilename); // Look below at the WRITE macros to understand what these numbers mean. const size_t len = strlen(wadfilename) + 1; @@ -717,7 +719,9 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid) // Look for the requested file through all loaded files for (wadnum = 0; wadfiles[wadnum]; wadnum++) { - strlcpy(wadfilename, wadfiles[wadnum]->filename, MAX_WADPATH); + // im a certified strlcpy hater + strncpy(wadfilename, wadfiles[wadnum]->filename, MAX_WADPATH); + wadfilename[MAX_WADPATH-1] = '\0'; nameonly(wadfilename); if (fasticmp(wadfilename, p->id.filename)) From 4686e8e1125a96d84842d20e23ee7e66f702ad10 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 7 Jun 2022 20:54:10 -0700 Subject: [PATCH 07/30] Do not play invalid sfx --- src/s_sound.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/s_sound.c b/src/s_sound.c index f81690b24..d3265ae0e 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -586,6 +586,14 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) if (!sfx->data) { sfx->data = I_GetSfx(sfx); + + if (!sfx->data) + { + CONS_Alert(CONS_WARNING, + "Tried to load invalid sfx_%s\n", + sfx->name); + return;/* don't play it */ + } } // Avoid channel reverse if surround From b955fdb47db174c2f45b3ae181667b90dcf12357 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 23:07:18 +0200 Subject: [PATCH 08/30] cleanup s_sound a little --- src/s_sound.c | 279 +++++++++++++++++++++++++------------------------- 1 file changed, 142 insertions(+), 137 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index d3265ae0e..5d3c43a3c 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -477,6 +477,11 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) { player_t *player = &players[displayplayers[i]]; + if (!player) + { + continue; + } + if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; @@ -535,87 +540,84 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) i = 0; // sensible default + // Check to see if it is audible, and if not, modify the params + if (origin && !itsUs) { - // Check to see if it is audible, and if not, modify the params - if (origin && !itsUs) + boolean audible = false; + + if (splitscreen > 0) { - boolean audible = false; - if (splitscreen > 0) - { - fixed_t recdist = INT32_MAX; - UINT8 j = 0; + fixed_t recdist = INT32_MAX; + UINT8 j = 0; - for (; j <= splitscreen; j++) + for (; j <= splitscreen; j++) + { + fixed_t thisdist = INT32_MAX; + + if (!listenmobj[j]) { - fixed_t thisdist = INT32_MAX; - - if (!listenmobj[j]) - { - continue; - } - - thisdist = P_AproxDistance(listener[j].x - origin->x, listener[j].y - origin->y); - - if (thisdist >= recdist) - { - continue; - } - - recdist = thisdist; - i = j; + continue; } - } - if (listenmobj[i]) - { - audible = S_AdjustSoundParams(listenmobj[i], origin, &volume, &sep, sfx); - } + thisdist = P_AproxDistance(listener[j].x - origin->x, listener[j].y - origin->y); - if (!audible) - { - return; + if (thisdist >= recdist) + { + continue; + } + + recdist = thisdist; + i = j; } } - // This is supposed to handle the loading/caching. - // For some odd reason, the caching is done nearly - // each time the sound is needed? + if (listenmobj[i]) + { + audible = S_AdjustSoundParams(listenmobj[i], origin, &volume, &sep, sfx); + } + + if (!audible) + { + return; + } + } + + // This is supposed to handle the loading/caching. + // For some odd reason, the caching is done nearly + // each time the sound is needed? + + // cache data if necessary + // NOTE: set sfx->data NULL sfx->lump -1 to force a reload + if (!sfx->data) + { + sfx->data = I_GetSfx(sfx); - // cache data if necessary - // NOTE: set sfx->data NULL sfx->lump -1 to force a reload if (!sfx->data) { - sfx->data = I_GetSfx(sfx); - - if (!sfx->data) - { - CONS_Alert(CONS_WARNING, - "Tried to load invalid sfx_%s\n", - sfx->name); - return;/* don't play it */ - } + CONS_Alert(CONS_WARNING, "Tried to load invalid sfx_%s\n", sfx->name); + return; /* don't play it */ } - - // Avoid channel reverse if surround - if (reverse) - { - sep = (~sep) & 255; - } - - // At this point it is determined that a sound can and should be played, so find a free channel to play it on - cnum = S_getChannel(origin, sfx); - - if (cnum < 0) - { - return; // If there's no free channels, there won't be any for anymore players either - } - - // Now that we know we are going to play a sound, fill out this info - channels[cnum].sfxinfo = sfx; - channels[cnum].origin = origin; - channels[cnum].volume = initial_volume; - channels[cnum].handle = I_StartSound(sfx_id, volume, sep, cnum); } + + // Avoid channel reverse if surround + if (reverse) + { + sep = (~sep) & 255; + } + + // At this point it is determined that a sound can and should be played, so find a free channel to play it on + cnum = S_getChannel(origin, sfx); + + if (cnum < 0) + { + return; // If there's no free channels, there won't be any for anymore players either + } + + // Now that we know we are going to play a sound, fill out this info + channels[cnum].sfxinfo = sfx; + channels[cnum].origin = origin; + channels[cnum].volume = initial_volume; + channels[cnum].handle = I_StartSound(sfx_id, volume, sep, cnum); } void S_StartSound(const void *origin, sfxenum_t sfx_id) @@ -736,6 +738,11 @@ void S_UpdateSounds(void) { player_t *player = &players[displayplayers[i]]; + if (!player) + { + continue; + } + if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; @@ -769,84 +776,83 @@ void S_UpdateSounds(void) { c = &channels[cnum]; - if (c->sfxinfo) + if (c->sfxinfo == NULL) + continue; + + // if channel is allocated but sound has stopped, free it + if (!I_SoundIsPlaying(c->handle)) { - if (I_SoundIsPlaying(c->handle)) + S_StopChannel(cnum); + continue; + } + + if (c->origin == NULL) + continue; + + // initialize parameters + volume = c->volume; // 8 bits internal volume precision + sep = NORM_SEP; + + // check non-local sounds for distance clipping + // or modify their params + boolean itsUs = false; + + for (i = splitscreen; i >= 0; i--) + { + if (camera[i].freecam) + continue; + + if (c->origin != listenmobj[i]) + continue; + + itsUs = true; + } + + if (itsUs == false) + { + const mobj_t *origin = c->origin; + + i = 0; + + if (splitscreen > 0) { - // initialize parameters - volume = c->volume; // 8 bits internal volume precision - sep = NORM_SEP; + fixed_t recdist = INT32_MAX; + UINT8 j = 0; - // check non-local sounds for distance clipping - // or modify their params - if (c->origin) + for (; j <= splitscreen; j++) { - boolean itsUs = false; + fixed_t thisdist = INT32_MAX; - for (i = splitscreen; i >= 0; i--) + if (!listenmobj[j]) { - if (camera[i].freecam) - continue; - - if (c->origin != listenmobj[i]) - continue; - - itsUs = true; + continue; } - if (itsUs == false) + thisdist = P_AproxDistance(listener[j].x - origin->x, listener[j].y - origin->y); + + if (thisdist >= recdist) { - const mobj_t *origin = c->origin; - - i = 0; - - if (splitscreen > 0) - { - fixed_t recdist = INT32_MAX; - UINT8 j = 0; - - for (; j <= splitscreen; j++) - { - fixed_t thisdist = INT32_MAX; - - if (!listenmobj[j]) - { - continue; - } - - thisdist = P_AproxDistance(listener[j].x - origin->x, listener[j].y - origin->y); - - if (thisdist >= recdist) - { - continue; - } - - recdist = thisdist; - i = j; - } - } - - if (listenmobj[i]) - { - audible = S_AdjustSoundParams( - listenmobj[i], c->origin, - &volume, &sep, - c->sfxinfo - ); - } - - if (audible) - I_UpdateSoundParams(c->handle, volume, sep); - else - S_StopChannel(cnum); + continue; } + + recdist = thisdist; + i = j; } } - else + + if (listenmobj[i]) { - // if channel is allocated but sound has stopped, free it - S_StopChannel(cnum); + audible = S_AdjustSoundParams( + listenmobj[i], c->origin, + &volume, &sep, + c->sfxinfo + ); } + + if (audible) + I_UpdateSoundParams(c->handle, volume, sep); + else + S_StopChannel(cnum); } } @@ -874,7 +880,6 @@ void S_ClearSfx(void) static void S_StopChannel(INT32 cnum) { - INT32 i; channel_t *c = &channels[cnum]; if (c->sfxinfo) @@ -883,12 +888,6 @@ static void S_StopChannel(INT32 cnum) if (I_SoundIsPlaying(c->handle)) I_StopSound(c->handle); - // check to see - // if other channels are playing the sound - for (i = 0; i < numofchannels; i++) - if (cnum != i && c->sfxinfo == channels[i].sfxinfo) - break; - c->sfxinfo = NULL; } @@ -1054,12 +1053,14 @@ static boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 S_OriginPlaying(void *origin) { INT32 cnum; + if (!origin) return false; for (cnum = 0; cnum < numofchannels; cnum++) if (channels[cnum].origin == origin) return 1; + return 0; } @@ -1072,6 +1073,7 @@ INT32 S_IdPlaying(sfxenum_t id) for (cnum = 0; cnum < numofchannels; cnum++) if ((size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)id) return 1; + return 0; } @@ -1080,6 +1082,7 @@ INT32 S_IdPlaying(sfxenum_t id) INT32 S_SoundPlaying(void *origin, sfxenum_t id) { INT32 cnum; + if (!origin) return 0; @@ -1089,6 +1092,7 @@ INT32 S_SoundPlaying(void *origin, sfxenum_t id) && (size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)id) return 1; } + return 0; } @@ -1101,6 +1105,7 @@ static sfxenum_t newsounds[MAXNEWSOUNDS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; void S_StartSoundName(void *mo, const char *soundname) { INT32 i, soundnum = 0; + // Search existing sounds... for (i = sfx_None + 1; i < NUMSFX; i++) { From fa899d39705c1a658f473754b6ce6efc2b64364a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 7 Jun 2026 07:07:56 +0200 Subject: [PATCH 09/30] fix a few more style issues --- src/d_netfil.c | 16 +++- src/hardware/hw_main.cpp | 193 +++++++++++++++++++-------------------- src/p_spec.c | 49 +++++----- src/p_user.c | 2 +- src/r_bsp.cpp | 21 ++++- src/r_fps.cpp | 8 +- src/r_things.cpp | 3 + 7 files changed, 159 insertions(+), 133 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 61852b436..944d9560b 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -259,9 +259,10 @@ void CL_PrepareDownloadSaveGame(const char *tmpsave) */ boolean CL_CheckDownloadable(void) { - UINT8 i,dlstatus = 0; + UINT8 i, dlstatus = 0; for (i = 0; i < fileneedednum; i++) + { if (fileneeded[i].status != FS_FOUND && fileneeded[i].status != FS_OPEN) { if (fileneeded[i].willsend == 1) @@ -272,6 +273,7 @@ boolean CL_CheckDownloadable(void) else //if (fileneeded[i].willsend == 2) dlstatus = 2; } + } // Downloading locally disabled if (!dlstatus && M_CheckParm("-nodownload")) @@ -282,15 +284,17 @@ boolean CL_CheckDownloadable(void) // not downloadable, put reason in console CONS_Alert(CONS_NOTICE, M_GetText("You need additional files to connect to this server:\n")); + for (i = 0; i < fileneedednum; i++) + { if (fileneeded[i].status != FS_FOUND && fileneeded[i].status != FS_OPEN) { CONS_Printf(" * \"%s\" (%dK)", fileneeded[i].filename, fileneeded[i].totalsize >> 10); - if (fileneeded[i].status == FS_MD5SUMBAD) - CONS_Printf(M_GetText(" wrong version, md5: ")); - else - CONS_Printf(M_GetText(" not found, md5: ")); + if (fileneeded[i].status == FS_MD5SUMBAD) + CONS_Printf(M_GetText(" wrong version, md5: ")); + else + CONS_Printf(M_GetText(" not found, md5: ")); { INT32 j; @@ -301,6 +305,7 @@ boolean CL_CheckDownloadable(void) } CONS_Printf("\n"); } + } switch (dlstatus) { @@ -314,6 +319,7 @@ boolean CL_CheckDownloadable(void) CONS_Printf(M_GetText("All files downloadable, but you have chosen to disable downloading locally.\n")); break; } + return false; } diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index c200d6682..cf5d0fda7 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1222,7 +1222,7 @@ static void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) wallVerts[0].s = wallVerts[3].s = 0; wallVerts[2].s = wallVerts[1].s = 0; - if (UNLIKELY(gl_collect_skywalls)) + if (gl_collect_skywalls) { HWR_SkyWallList_Add(wallVerts); } @@ -2323,7 +2323,7 @@ static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2) } } else - return;// dont do anything with the other side i guess? + return; // dont do anything with the other side i guess? } doaddline: @@ -2829,21 +2829,21 @@ static void HWR_Subsector(size_t num) if (anyMoved == false) { - for (rover = gl_frontsector->ffloors; rover; rover = rover->next) + if (sub->validcount != validcount) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) - continue; + for (rover = gl_frontsector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + continue; - if (sub->validcount == validcount) - continue; + const sector_t *controlSec = §ors[rover->secnum]; - const sector_t *controlSec = §ors[rover->secnum]; + if (controlSec->moved != true) + continue; - if (controlSec->moved != true) - continue; - - anyMoved = true; - break; + anyMoved = true; + break; + } } } @@ -2900,106 +2900,103 @@ static void HWR_Subsector(size_t num) PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum, NULL, 255, ceilingcolormap); } } - } - if (gl_frontsector->ffloors) - { - /// \todo fix light, xoffs, yoffs, extracolormap ? - for (rover = gl_frontsector->ffloors; rover; rover = rover->next) + if (gl_frontsector->ffloors) { - fixed_t bottomCullHeight, topCullHeight, centerHeight; - - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) - continue; - - if (sub->validcount == validcount) - continue; - - if (gl_frontsector->cullheight) + /// \todo fix light, xoffs, yoffs, extracolormap ? + for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { - if (HWR_DoCulling(gl_frontsector->cullheight, viewsector->cullheight, gl_viewz, FixedToFloat(*rover->bottomheight), FixedToFloat(*rover->topheight))) + fixed_t bottomCullHeight, topCullHeight, centerHeight; + + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) continue; - } - auto render_plane = [&](boolean bottom, fixed_t cullheight) FUNCINLINE - { - fixed_t roverheight; - lumpnum_t flatlump; - - if (bottom) + if (gl_frontsector->cullheight) { - roverheight = *rover->bottomheight; - flatlump = levelflats[*rover->bottompic].lumpnum; - } - else - { - roverheight = *rover->topheight; - flatlump = levelflats[*rover->toppic].lumpnum; + if (HWR_DoCulling(gl_frontsector->cullheight, viewsector->cullheight, gl_viewz, FixedToFloat(*rover->bottomheight), FixedToFloat(*rover->topheight))) + continue; } - if (rover->flags & FF_FOG) + auto render_fof_plane = [&](boolean bottom, boolean underside) FUNCINLINE { - UINT8 alpha; + fixed_t roverheight; + lumpnum_t flatlump; - light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < cullheight)); + if (bottom) + { + roverheight = *rover->bottomheight; + flatlump = levelflats[*rover->bottompic].lumpnum; + } + else + { + roverheight = *rover->topheight; + flatlump = levelflats[*rover->toppic].lumpnum; + } - alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + if (rover->flags & FF_FOG) + { + UINT8 alpha; - HWR_AddTransparentFloor(0, - &extrasubsectors[num], - !bottom, - roverheight, - *gl_frontsector->lightlist[light].lightlevel, - alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, - true, rover->master->frontsector->extra_colormap); + light = R_GetPlaneLight(gl_frontsector, centerHeight, underside); + + alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + + HWR_AddTransparentFloor(0, + &extrasubsectors[num], + !bottom, + roverheight, + *gl_frontsector->lightlist[light].lightlevel, + alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, + true, rover->master->frontsector->extra_colormap); + } + else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient + { + light = R_GetPlaneLight(gl_frontsector, centerHeight, underside); + + HWR_AddTransparentFloor(flatlump, + &extrasubsectors[num], + !bottom, + roverheight, + *gl_frontsector->lightlist[light].lightlevel, + CLAMP(rover->alpha, 0, 255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast(PF_Translucent)), + false, gl_frontsector->lightlist[light].extra_colormap); + } + else + { + HWR_GetFlat(flatlump, R_NoEncore(gl_frontsector, !bottom)); + light = R_GetPlaneLight(gl_frontsector, centerHeight, underside); + + HWR_RenderPlane(sub, &extrasubsectors[num], !bottom, roverheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, flatlump, + rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); + } + }; + + // bottom plane + centerHeight = P_GetFFloorBottomZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); + + if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight) + { + bottomCullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); + + if ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) + { + render_fof_plane(true, (viewz < bottomCullHeight)); + } } - else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient + + // top plane + centerHeight = P_GetFFloorTopZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); + + if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight) { - light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < cullheight)); + topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); - HWR_AddTransparentFloor(flatlump, - &extrasubsectors[num], - !bottom, - roverheight, - *gl_frontsector->lightlist[light].lightlevel, - CLAMP(rover->alpha, 0, 255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast(PF_Translucent)), - false, gl_frontsector->lightlist[light].extra_colormap); - } - else - { - HWR_GetFlat(flatlump, R_NoEncore(gl_frontsector, !bottom)); - light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < cullheight)); - - HWR_RenderPlane(sub, &extrasubsectors[num], !bottom, roverheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, flatlump, - rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); - } - }; - - // bottom plane - centerHeight = P_GetFFloorBottomZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); - - if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight) - { - bottomCullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); - - if ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) - { - render_plane(true, bottomCullHeight); - } - } - - // top plane - centerHeight = P_GetFFloorTopZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); - - if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight) - { - topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); - - if ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) - { - render_plane(false, topCullHeight); + if ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) + { + render_fof_plane(false, (viewz < topCullHeight)); + } } } } diff --git a/src/p_spec.c b/src/p_spec.c index 265ff4afb..ca86f8ee4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -881,7 +881,7 @@ static boolean PolyDoor(line_t *line) pdd.polyObjNum = line->tag; // polyobject id - switch(line->special) + switch (line->special) { case 480: // Polyobj_DoorSlide pdd.doorType = POLY_DOOR_SLIDE; @@ -1597,19 +1597,21 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller) if (lines[masterline].tag != tag) continue; + const INT16 specialtype = lines[masterline].special; + // "No More Enemies" and "Level Load" take care of themselves. - if (lines[masterline].special == 313 - || lines[masterline].special == 399 - || lines[masterline].special == 328 - || lines[masterline].special == 323 + if (specialtype == 313 + || specialtype == 399 + || specialtype == 328 + || specialtype == 323 // Each-time executors handle themselves, too - || lines[masterline].special == 301 // Each time - || lines[masterline].special == 306 // Character ability - Each time - || lines[masterline].special == 310 // CTF Red team - Each time - || lines[masterline].special == 312 // CTF Blue team - Each time - || lines[masterline].special == 322 // Trigger on X calls - Each Time - || lines[masterline].special < 300 - || lines[masterline].special > 399) + || specialtype == 301 // Each time + || specialtype == 306 // Character ability - Each time + || specialtype == 310 // CTF Red team - Each time + || specialtype == 312 // CTF Blue team - Each time + || specialtype == 322 // Trigger on X calls - Each Time + || specialtype < 300 + || specialtype > 399) continue; if (!P_RunTriggerLinedef(&lines[masterline], actor, caller)) @@ -4736,7 +4738,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f P_AddSpikeThinker(sec, (INT32)sec2num); } // Should this FOF have friction? - else if(th->function == (actionf_p1)T_Friction) + else if (th->function == (actionf_p1)T_Friction) { f = (friction_t *)th; @@ -4744,7 +4746,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f Add_Friction(f->friction, f->movefactor, (INT32)(sec-sectors), f->affectee); } // Should this FOF have wind/current/pusher? - else if(th->function == (actionf_p1)T_Pusher) + else if (th->function == (actionf_p1)T_Pusher) { p = (pusher_t *)th; @@ -6946,6 +6948,7 @@ static void P_SpawnFriction(void) INT32 movefactor; // applied to each player move to simulate inertia for (i = 0; i < numlines; i++, l++) + { if (l->special == 540) { //length = P_AproxDistance(l->dx, l->dy)>>FRACBITS; @@ -6979,6 +6982,7 @@ static void P_SpawnFriction(void) for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) Add_Friction(friction, movefactor, s, -1); } + } } /* @@ -7293,13 +7297,16 @@ void T_Pusher(pusher_t *p) if (thing->flags2 & MF2_PUSHED) continue; - if (thing->player && thing->player->pflags & PF_ROPEHANG) - continue; + if (thing->player) + { + if (thing->player->pflags & PF_ROPEHANG) + continue; - if (thing->player && (thing->state == &states[thing->info->painstate]) - && (thing->player->powers[pw_flashing] > (K_GetKartFlashing(thing->player)/4)*3 - && thing->player->powers[pw_flashing] <= K_GetKartFlashing(thing->player))) - continue; + if ((thing->state == &states[thing->info->painstate]) + && (thing->player->powers[pw_flashing] > (K_GetKartFlashing(thing->player)/4)*3 + && thing->player->powers[pw_flashing] <= K_GetKartFlashing(thing->player))) + continue; + } inFOF = touching = moved = false; @@ -7429,7 +7436,7 @@ void T_Pusher(pusher_t *p) if (p->slider && thing->player) { boolean jumped = (thing->player->pflags & PF_JUMPED); - P_ResetPlayer (thing->player); + P_ResetPlayer(thing->player); if (jumped) thing->player->pflags |= PF_JUMPED; diff --git a/src/p_user.c b/src/p_user.c index 26e358cc8..11c5e0b81 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2361,7 +2361,7 @@ static void P_MovePlayer(player_t *player) if (onground && leveltime % 50 == 0 && player->kartstuff[k_drift] != 0) S_StartSound(player->mo, sfx_drift); // Leveltime being 50 might take a while at times. We'll start it up once, isntantly. - else if (onground && !S_SoundPlaying(player->mo, sfx_drift) && player->kartstuff[k_drift] != 0) + else if (onground && player->kartstuff[k_drift] != 0 && !S_SoundPlaying(player->mo, sfx_drift)) S_StartSound(player->mo, sfx_drift); // Ok, we'll stop now. else if (player->kartstuff[k_drift] == 0 || !onground) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 8fd66299c..68de16478 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -321,12 +321,19 @@ static void R_AddLine(seg_t *line) angle_t angle1, angle2, span, tspan; static sector_t tempsec; boolean bothfloorssky = false; + fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t g_portal = NULL; + v1x = line->v1->x; + v1y = line->v1->y; + + v2x = line->v2->x; + v2y = line->v2->y; + // big room fix - angle1 = R_PointToAngle64(line->v1->x, line->v1->y); - angle2 = R_PointToAngle64(line->v2->x, line->v2->y); + angle1 = R_PointToAngle64(v1x, v1y); + angle2 = R_PointToAngle64(v2x, v2y); curline = line; @@ -519,6 +526,7 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) angle_t angle1, angle2; INT32 sx1, sx2; const INT32* check; + fixed_t x1, y1, x2, y2; // Find the corners of the box // that define the edges from current viewpoint. @@ -532,9 +540,14 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) check = checkcoord[boxpos]; + x1 = bspcoord[check[0]]; + y1 = bspcoord[check[1]]; + x2 = bspcoord[check[2]]; + y2 = bspcoord[check[3]]; + // big room fix - angle1 = R_PointToAngle64(bspcoord[check[0]], bspcoord[check[1]]) - viewangle; - angle2 = R_PointToAngle64(bspcoord[check[2]], bspcoord[check[3]]) - viewangle; + angle1 = R_PointToAngle64(x1, y1) - viewangle; + angle2 = R_PointToAngle64(x2, y2) - viewangle; // cph - replaced old code, which was unclear and badly commented // Much more efficient code now diff --git a/src/r_fps.cpp b/src/r_fps.cpp index 7ccebf8e5..8372fa30f 100644 --- a/src/r_fps.cpp +++ b/src/r_fps.cpp @@ -387,10 +387,10 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst return; } - out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); - out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); - out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); - out->scale = mapobjectscale; + out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); + out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); + out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); + out->scale = mapobjectscale; } static levelinterpolator_t *CreateInterpolator(levelinterpolator_type_e type, thinker_t *thinker) diff --git a/src/r_things.cpp b/src/r_things.cpp index 52f8be112..875cb7290 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -773,6 +773,7 @@ static void R_DrawVisSprite(vissprite_t *vis) R_SetColumnFunc(BASEDRAWFUNC); // hack: this isn't resetting properly somewhere. dc.colormap = vis->colormap; + if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" { R_SetColumnFunc(COLDRAWFUNC_TRANS); // translate certain pixels to white @@ -825,6 +826,7 @@ static void R_DrawVisSprite(vissprite_t *vis) else dc.colormap = &vis->extra_colormap->colormap[dc.colormap - colormaps]; } + if (!dc.colormap) dc.colormap = colormaps; @@ -849,6 +851,7 @@ static void R_DrawVisSprite(vissprite_t *vis) vis->xiscale = FixedDiv(vis->xiscale, this_scale); vis->isScaled = true; } + dc.texturemid = FixedDiv(dc.texturemid, this_scale); } From b4cad08ad330aa2162b87193c4bc7d9b72a2d681 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 8 Jun 2026 09:44:19 +0200 Subject: [PATCH 10/30] cleanup p_spec/p_setup a bit --- src/p_setup.c | 26 ++++++------ src/p_spec.c | 114 ++++++++++++++++++++++++++++++++++---------------- src/sounds.c | 2 +- 3 files changed, 91 insertions(+), 51 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index afc53234b..a1b1fb3cb 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1215,14 +1215,14 @@ static void P_LoadSideChangeMusic(boolean firstside, mapsidedef_t *msd, side_t * if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') { - memcpy(process,msd->bottomtexture,8); + memcpy(process, msd->bottomtexture, 8); process[8] = '\0'; sd->bottomtexture = get_number(process); } if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0') { - memcpy(process,msd->midtexture,8); + memcpy(process, msd->midtexture, 8); process[8] = '\0'; sd->midtexture = get_number(process); } @@ -1232,7 +1232,7 @@ static void P_LoadSideChangeMusic(boolean firstside, mapsidedef_t *msd, side_t * if (firstside || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') { - memcpy(process,msd->toptexture,8); + memcpy(process, msd->toptexture, 8); process[8] = '\0'; // If they type in O_ or D_ and their music name, just shrug, @@ -1272,7 +1272,7 @@ static void P_LoadSidedefs(void *data) // Colormaps! switch (sd->special) { - case 63: // variable colormap via 242 linedef + case 63: // variable colormap via 242 linedef case 606: //SoM: 4/4/2000: Just colormap transfer // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. @@ -1288,21 +1288,21 @@ static void P_LoadSidedefs(void *data) if (msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') { char process[8+1]; - memcpy(process,msd->toptexture,8); + memcpy(process, msd->toptexture, 8); process[8] = '\0'; sd->toptexture = get_number(process); } break; } - case 9: // Mace parameters - case 14: // Bustable block parameters - case 15: // Fan particle spawner parameters + case 9: // Mace parameters + case 14: // Bustable block parameters + case 15: // Fan particle spawner parameters case 425: // Calls P_SetMobjState on calling mobj case 434: // Custom Power case 442: // Calls P_SetMobjState on mobjs of a given type in the tagged sectors { char process[8*3+1]; - memset(process,0,8*3+1); + memset(process, 0, 8*3+1); sd->toptexture = sd->midtexture = sd->bottomtexture = 0; if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0') break; @@ -1319,7 +1319,7 @@ static void P_LoadSidedefs(void *data) case 443: // Calls a named Lua function { char process[8*3+1]; - memset(process,0,8*3+1); + memset(process, 0, 8*3+1); sd->toptexture = sd->midtexture = sd->bottomtexture = 0; if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0') break; @@ -2927,7 +2927,7 @@ static size_t sreplaces = 0, mreplaces = 0, digmreplaces = 0; static boolean P_CheckSoundReplacements(UINT16 wadnum, char *name, size_t i) { size_t j; - lumpnum_t lumpnum = (i|(wadnum<<16)); + lumpnum_t lumpnum = (i | (wadnum<<16)); if (name[0] == 'D') { @@ -2935,8 +2935,8 @@ static boolean P_CheckSoundReplacements(UINT16 wadnum, char *name, size_t i) { for (j = 1; j < NUMSFX; j++) { - if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6) - && (S_sfx[j].lumpnum != lumpnum) && (S_sfx[j].lumpnum != LUMPERROR)) + if ((S_sfx[j].lumpnum != lumpnum) && (S_sfx[j].lumpnum != LUMPERROR) && + S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6)) { // the sound will be reloaded when needed, // since sfx->data will be NULL diff --git a/src/p_spec.c b/src/p_spec.c index ca86f8ee4..63a0ceaea 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1338,6 +1338,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller else if (secspecial == 7) // SRB2Kart: reusing for Race Lap executor { UINT8 lap; + INT32 targlap; if (actor && actor->player && triggerline->flags & ML_EFFECT4) { @@ -1348,19 +1349,21 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller lap = P_FindLowestLap(); } + targlap = (INT32)(sides[triggerline->sidenum[0]].textureoffset >> FRACBITS); + if (triggerline->flags & ML_NOCLIMB) // Need higher than or equal to { - if (lap < (sides[triggerline->sidenum[0]].textureoffset >> FRACBITS)) + if (lap < targlap) return false; } else if (triggerline->flags & ML_BLOCKMONSTERS) // Need lower than or equal to { - if (lap > (sides[triggerline->sidenum[0]].textureoffset >> FRACBITS)) + if (lap > targlap) return false; } else // Need equal to { - if (lap != (sides[triggerline->sidenum[0]].textureoffset >> FRACBITS)) + if (lap != targlap) return false; } @@ -1452,6 +1455,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller if (triggerline->flags & ML_EFFECT5) // disregard order for efficiency { for (i = 0; i < linecnt; i++) + { if (ctlsector->lines[i]->special >= 400 && ctlsector->lines[i]->special < 500) { @@ -1460,6 +1464,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller else P_ProcessLineSpecial(ctlsector->lines[i], actor, caller); } + } } else // walk around the sector in a defined order { @@ -1467,11 +1472,13 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller size_t j, masterlineindex = (size_t)-1; for (i = 0; i < linecnt; i++) + { if (ctlsector->lines[i] == triggerline) { masterlineindex = i; break; } + } #ifdef PARANOIA if (masterlineindex == (size_t)-1) @@ -1490,11 +1497,13 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller { if (i == j) continue; + if (ctlsector->lines[i]->v1 == ctlsector->lines[j]->v2) { i = j; break; } + if (ctlsector->lines[i]->v1 == ctlsector->lines[j]->v1) { i = j; @@ -1502,6 +1511,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller break; } } + if (j == linecnt) { const size_t vertexei = (size_t)(ctlsector->lines[i]->v1 - vertexes); @@ -1516,11 +1526,13 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller { if (i == j) continue; + if (ctlsector->lines[i]->v2 == ctlsector->lines[j]->v1) { i = j; break; } + if (ctlsector->lines[i]->v2 == ctlsector->lines[j]->v2) { i = j; @@ -2423,7 +2435,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_SetPlayerMobjState(mo, S_KART_STND1); // SRB2kart - was S_PLAY_STND // Reset bot too. - if (bot) { + if (bot) + { if (line->flags & ML_NOCLIMB) P_SetOrigin(bot, mo->x, mo->y, mo->z); bot->momx = bot->momy = bot->momz = 1; @@ -2506,6 +2519,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_SetTarget(&dummy->target, bot); A_CustomPower(dummy); } + P_RemoveMobj(dummy); } break; @@ -2569,11 +2583,15 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (mo && mo->player) { UINT16 fractime = (UINT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); + if (fractime < 1) fractime = 1; //instantly wears off upon leaving + if (line->flags & ML_NOCLIMB) fractime |= 1<<15; //more crazy &ing, as if music stuff wasn't enough + mo->player->powers[pw_nocontrol] = fractime; + if (bot) bot->player->powers[pw_nocontrol] = fractime; } @@ -2583,8 +2601,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (mo) { mo->destscale = FixedDiv(P_AproxDistance(line->dx, line->dy), 100<destscale < FRACUNIT/100) mo->destscale = FRACUNIT/100; + if (mo->player && bot) bot->destscale = mo->destscale; } @@ -2669,9 +2689,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { boolean tryagain; sec = sectors + secnum; + do { tryagain = false; for (thing = sec->thinglist; thing; thing = thing->snext) + { if (thing->type == type) { if (state != NUMSTATES) @@ -2688,6 +2710,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; } } + } } while (tryagain); } break; @@ -3263,6 +3286,7 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers case 3: // Linedef executor requires all players present // Trigger Linedef Exec (Floor Touch, All Players) /// \todo check continues for proper splitscreen support? for (i = 0; i < MAXPLAYERS; i++) + { if (playeringame[i] && !players[i].bot && players[i].mo && (gametype != GT_COOP || players[i].lives > 0)) { if (roversector) @@ -3316,6 +3340,7 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers goto DoneSection2; } } + } /* FALLTHRU */ case 4: // Linedef executor that doesn't require touching floor // Trigger Linedef Exec (Anywhere in Sector) case 5: // Linedef executor // Trigger Linedef Exec (Floor Touch) @@ -3451,8 +3476,10 @@ DoneSection2: angle_t lineangle; fixed_t linespeed; - lineangle = lines[i].angle; - linespeed = P_AproxDistance(lines[i].v2->x-lines[i].v1->x, lines[i].v2->y-lines[i].v1->y); + const line_t *line = &lines[i]; + + lineangle = line->angle; + linespeed = P_AproxDistance(line->v2->x-line->v1->x, line->v2->y-line->v1->y); player->mo->angle = lineangle; @@ -3466,7 +3493,7 @@ DoneSection2: P_ForceLocalAngle(player, player->mo->angle); } - if (!(lines[i].flags & ML_EFFECT4)) + if (!(line->flags & ML_EFFECT4)) { P_UnsetThingPosition(player->mo); if (roversector) // make FOF speed pads work @@ -3537,21 +3564,25 @@ DoneSection2: P_DoPlayerExit(player); P_SetupSignExit(player); - // important: use sector->tag on next line instead of player->mo->subsector->tag - // this part is different from in P_PlayerThink, this is what was causing - // FOF custom exits not to work. - lineindex = P_FindSpecialLineFromTag(2, sector->tag, -1); - if (gametype == GT_COOP && lineindex != -1) // Custom exit! + if (gametype == GT_COOP) { - // Special goodies with the block monsters flag depending on emeralds collected - if ((lines[lineindex].flags & ML_BLOCKMONSTERS) && ALL7EMERALDS(emeralds)) - nextmapoverride = (INT16)(lines[lineindex].frontsector->ceilingheight>>FRACBITS); - else - nextmapoverride = (INT16)(lines[lineindex].frontsector->floorheight>>FRACBITS); + // important: use sector->tag on next line instead of player->mo->subsector->tag + // this part is different from in P_PlayerThink, this is what was causing + // FOF custom exits not to work. + lineindex = P_FindSpecialLineFromTag(2, sector->tag, -1); - if (lines[lineindex].flags & ML_NOCLIMB) - skipstats = true; + if (lineindex != -1) // Custom exit!) + { + // Special goodies with the block monsters flag depending on emeralds collected + if ((lines[lineindex].flags & ML_BLOCKMONSTERS) && ALL7EMERALDS(emeralds)) + nextmapoverride = (INT16)(lines[lineindex].frontsector->ceilingheight>>FRACBITS); + else + nextmapoverride = (INT16)(lines[lineindex].frontsector->floorheight>>FRACBITS); + + if (lines[lineindex].flags & ML_NOCLIMB) + skipstats = true; + } } } break; @@ -3658,7 +3689,6 @@ DoneSection2: mobj_t *waypoint = NULL; mobj_t *mo2; - if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) break; @@ -4523,27 +4553,13 @@ void P_PlayerInSpecialSector(player_t *player) #undef TELEPORTED -/** Animate planes, scroll walls, etc. and keeps track of level timelimit and exits if time is up. - * - * \sa P_CheckTimeLimit, P_CheckPointLimit - */ -void P_UpdateSpecials(void) +static void P_UpdateAnimFlats(void) { anim_t *anim; INT32 i; size_t j; levelflat_t *foundflats; // for flat animation - // LEVEL TIMER - P_CheckTimeLimit(); - - // POINT LIMIT - P_CheckPointLimit(); - - // Dynamic slopeness - if (!midgamejoin) // run here when not joined midgame to prevent any potential issues that may arise - P_RunDynamicSlopes(); - // ANIMATE TEXTURES for (anim = anims; anim < lastanim; anim++) { @@ -4573,15 +4589,38 @@ void P_UpdateSpecials(void) } } +/** Animate planes, scroll walls, etc. and keeps track of level timelimit and exits if time is up. + * + * \sa P_CheckTimeLimit, P_CheckPointLimit + */ +void P_UpdateSpecials(void) +{ + // LEVEL TIMER + P_CheckTimeLimit(); + + // POINT LIMIT + P_CheckPointLimit(); + + // Dynamic slopeness + // we run this here only when not joined midrace + // for vanilla compat reasons :chaosleep: + if (!midgamejoin) + P_RunDynamicSlopes(); + + P_UpdateAnimFlats(); +} + static inline ffloor_t *P_GetFFloorBySec(sector_t *sec, sector_t *sec2) { ffloor_t *rover; if (!sec->ffloors) return NULL; + for (rover = sec->ffloors; rover; rover = rover->next) if (rover->secnum == (size_t)(sec2 - sectors)) return rover; + return NULL; } @@ -4632,6 +4671,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if (sec == sec2) return NULL; //Don't need a fake floor on a control sector. + if ((ffloor = (P_GetFFloorBySec(sec, sec2)))) return ffloor; // If this ffloor already exists, return it @@ -7031,9 +7071,9 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t * // "The right triangle of the square of the length of the hypotenuse is equal to the sum of the squares of the lengths of the other two sides." // "Bah! Stupid brains! Don't you know anything besides the Pythagorean Theorem?" - Earthworm Jim if (type == p_downcurrent || type == p_upcurrent || type == p_upwind || type == p_downwind) - p->magnitude = P_AproxDistance(p->x_mag,p->y_mag)<<(FRACBITS-PUSH_FACTOR); + p->magnitude = P_AproxDistance(p->x_mag, p->y_mag)<<(FRACBITS-PUSH_FACTOR); else - p->magnitude = P_AproxDistance(p->x_mag,p->y_mag); + p->magnitude = P_AproxDistance(p->x_mag, p->y_mag); if (source) // point source exist? { diff --git a/src/sounds.c b/src/sounds.c index 611539abe..3769bf65b 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -975,7 +975,7 @@ sfxinfo_t S_sfx[NUMSFX] = char freeslotnames[sfx_freeslot0 + NUMSFXFREESLOTS + NUMSKINSFXSLOTS][7] = {}; // Prepare free sfx slots to add sfx at run time -void S_InitRuntimeSounds (void) +void S_InitRuntimeSounds(void) { sfxenum_t i; INT32 value; From 8cb321993e93bc33721ea934b24dbc8c53bcc50e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 8 Jun 2026 09:45:29 +0200 Subject: [PATCH 11/30] restore functionality to set zipper/speed pad sounds set using the front side upper texture field like the play sound special per "DSXXXX" the parsing part already was there but not the actual code to make it use the specified sound for some reason lul shouldnt break anything and is vanilla compatible! --- src/p_spec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 63a0ceaea..978c3041e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3473,6 +3473,7 @@ DoneSection2: if (i != -1) { + INT32 sfxnum; angle_t lineangle; fixed_t linespeed; @@ -3515,7 +3516,14 @@ DoneSection2: player->kartstuff[k_drift] = 0; player->kartstuff[k_driftcharge] = 0; player->kartstuff[k_pogospring] = 0; - S_StartSound(player->mo, sfx_spdpad); + + sfxnum = sides[line->sidenum[0]].toptexture; + + // none or invalid sound? + if (sfxnum <= sfx_None || sfxnum >= NUMSFX) + sfxnum = sfx_spdpad; // use the zippy sound then! + + S_StartSound(player->mo, sfxnum); { sfxenum_t pick = P_RandomKey(2); // Gotta roll the RNG every time this is called for sync reasons From 8db399be9bb00706d3fd50269133d7c60d7bb130 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 12 Jun 2026 16:38:25 +0300 Subject: [PATCH 12/30] Allow lookback in replays (currently only works for player 1) --- src/p_tick.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/p_tick.c b/src/p_tick.c index 24142a823..51aa89487 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -611,6 +611,16 @@ void P_Ticker(boolean run) #ifdef DEMO_COMPAT_100 } #endif + + // Lookback is normally handled inside G_BuildTiccmd, which isn't called in replays so we're doing that manually + // idk if this is best place to handle this tho... + // TODO - make it actually work for players other than player 1, other splitscreen players still ignore camspin for some reason + for (INT32 i = 0; i <= splitscreen; ++i) + { + const boolean usejoystick = cv_usejoystick[i].value; + INT32 axis = JoyAxis(AXISLOOKBACK, i); + camspin[i] = (InputDown(gc_lookback, i) || (usejoystick && axis > 0)); + } } ps_lua_mobjhooks.value.i = 0; From 50f839e1ad6a846e5de55fd5304cebc274246c17 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 12 Jun 2026 16:47:55 +0300 Subject: [PATCH 13/30] Fix JoyAxis and InputDown inputs being off by one, this fixes lookback only working for p1 (ty lug <3) --- src/p_tick.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 51aa89487..3692f9205 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -614,12 +614,11 @@ void P_Ticker(boolean run) // Lookback is normally handled inside G_BuildTiccmd, which isn't called in replays so we're doing that manually // idk if this is best place to handle this tho... - // TODO - make it actually work for players other than player 1, other splitscreen players still ignore camspin for some reason - for (INT32 i = 0; i <= splitscreen; ++i) + for (i = 0; i <= splitscreen; ++i) { const boolean usejoystick = cv_usejoystick[i].value; - INT32 axis = JoyAxis(AXISLOOKBACK, i); - camspin[i] = (InputDown(gc_lookback, i) || (usejoystick && axis > 0)); + INT32 axis = JoyAxis(AXISLOOKBACK, i+1); + camspin[i] = (InputDown(gc_lookback, i+1) || (usejoystick && axis > 0)); } } From 3c227ec532592ec91da874ff992a8d330016e10c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 12 Jun 2026 22:06:47 +0200 Subject: [PATCH 14/30] P_CheckSight: fix rare overflow in rejectmatrix check didnt think this could overflow here but well it does wish there was a better way to bounds check heap arrays in C --- src/p_local.h | 8 +++++++- src/p_setup.c | 19 ++++++++++++------- src/p_sight.c | 21 ++++++++++++--------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 383469bcc..eb55f5dd4 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -414,7 +414,13 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object); // // P_SETUP // -extern UINT8 *rejectmatrix; // for fast sight rejection +typedef struct +{ + UINT8* data; + size_t size; +} reject_t; + +extern reject_t rejectmatrix; // for fast sight rejection extern INT32 *blockmaplump; // offsets in blockmap are from here extern INT32 *blockmap; // Big blockmap extern INT32 bmapwidth; diff --git a/src/p_setup.c b/src/p_setup.c index a1b1fb3cb..c8403538a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -145,7 +145,7 @@ precipmobj_t **precipblocklinks = NULL; // Speeds up enemy AI by skipping detailed LineOf Sight calculation. // Without special effect, this could be used as a PVS lookup as well. // -UINT8 *rejectmatrix = NULL; +reject_t rejectmatrix = {}; // Maintain single and multi player starting spots. INT32 numdmstarts = 0, numcoopstarts = 0, numredctfstarts = 0, numbluectfstarts = 0; @@ -1307,7 +1307,7 @@ static void P_LoadSidedefs(void *data) if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0') break; else - memcpy(process,msd->toptexture,8); + memcpy(process, msd->toptexture, 8); if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0') memcpy(process+strlen(process), msd->midtexture, 8); if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') @@ -1324,7 +1324,7 @@ static void P_LoadSidedefs(void *data) if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0') break; else - memcpy(process,msd->toptexture,8); + memcpy(process,msd->toptexture, 8); if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0') memcpy(process+strlen(process), msd->midtexture, 8); if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') @@ -1787,14 +1787,16 @@ static void P_LoadReject(UINT8 *data, size_t count) { if (!count) // zero length, someone probably used ZDBSP { - rejectmatrix = NULL; + rejectmatrix.data = NULL; CONS_Debug(DBG_SETUP, "P_LoadReject: REJECT lump has size 0, will not be loaded\n"); } else { - rejectmatrix = Z_Malloc(count, PU_LEVEL, NULL); // allocate memory for the reject matrix - memcpy(rejectmatrix, data, count); // copy the data into it + rejectmatrix.data = Z_Malloc(count, PU_LEVEL, NULL); // allocate memory for the reject matrix + memcpy(rejectmatrix.data, data, count); // copy the data into it } + + rejectmatrix.size = count; } static void P_LoadMapBSP(const virtres_t* virt) @@ -1833,7 +1835,10 @@ static void P_LoadMapLUT(const virtres_t* virt) if (virtreject) P_LoadReject(virtreject->data, virtreject->size); else - rejectmatrix = NULL; + { + rejectmatrix.data = NULL; + rejectmatrix.size = 0; + } if (!(virtblockmap && P_LoadRawBlockMap(virtblockmap->data, virtblockmap->size))) P_CreateBlockMap(); diff --git a/src/p_sight.c b/src/p_sight.c index 896da76d6..63b87820e 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -31,8 +31,6 @@ typedef struct { fixed_t bbox[4]; } los_t; -static INT32 sightcounts[2]; - typedef INT32 (*divlinefunc)(fixed_t x, fixed_t y, const divline_t *node); typedef INT32 (*divlinecrossfunc)(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node); @@ -366,18 +364,25 @@ boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast) I_Assert(!P_MobjWasRemoved(t2)); if (!t1->subsector || !t2->subsector - || !t1->subsector->sector || !t2->subsector->sector) + || !t1->subsector->sector || !t2->subsector->sector) + { return false; + } s1 = t1->subsector->sector; s2 = t2->subsector->sector; pnum = (s1-sectors)*numsectors + (s2-sectors); - if (rejectmatrix != NULL) + if (rejectmatrix.data != NULL) { + const size_t shiftnum = pnum>>3; + // Check in REJECT table. - if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected + if (shiftnum < rejectmatrix.size && // check for overflow + (rejectmatrix.data[shiftnum] & (1 << (pnum&7)))) // can't possibly be connected + { return false; + } } // killough 11/98: shortcut for melee situations @@ -385,11 +390,9 @@ boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast) // haleyjd 02/23/06: can't do this if there are polyobjects in the subsec if (!t1->subsector->polyList && t1->subsector == t2->subsector) + { return true; - - // An unobstructed LOS is possible. - // Now look from eyes of t1 to any part of t2. - sightcounts[1]++; + } validcount++; From eef1c55549a034eef15f188986eaf1dd893ea14b Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 13 Jun 2026 01:40:08 +0300 Subject: [PATCH 15/30] Add option for item roulette to use 'local' colors instead of player color --- src/k_hud.c | 36 ++++++++++++++++++++---------------- src/k_hud.h | 1 + src/m_menudefs.c | 31 +++++++++++++++++-------------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index a5f184f7b..e3a7f3ec5 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -109,6 +109,8 @@ consvar_t cv_huditemamount = {"showitemamountnumber", "Vanilla", CV_SAVE, hudite consvar_t cv_fancyroulette = {"animatedroulette", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_darkitembox = {"darkitembox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // itembox gets a dark border with specific items consvar_t cv_multiitemicon = {"multiitemicon", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t roulettecolor_cons_t[] = {{0, "Player"}, {1, "Item"}, {0, NULL}}; +consvar_t cv_roulettecolor = {"roulettecolor", "Player", CV_SAVE, roulettecolor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showlaptimes = {"showlaptimes", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -243,6 +245,8 @@ void K_RegisterKartHudStuff(void) CV_RegisterVar(&cv_multiitemicon); CV_RegisterVar(&cv_huditemamount); + CV_RegisterVar(&cv_roulettecolor); + CV_RegisterVar(&cv_highresportrait); CV_RegisterVar(&cv_nametag); @@ -1514,67 +1518,67 @@ static void K_drawKartItem(void) // Each case is handled in threes, to give three frames of in-game time to see the item on the roulette case 0: // Sneaker localpatch = kp_sneaker[offset]; - //localcolor = SKINCOLOR_RASPBERRY; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_RASPBERRY; break; case 1: // Banana localpatch = kp_banana[offset]; - //localcolor = SKINCOLOR_YELLOW; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_YELLOW; break; case 2: // Orbinaut localpatch = kp_orbinaut[3+offset]; - //localcolor = SKINCOLOR_STEEL; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_STEEL; break; case 3: // Mine localpatch = kp_mine[offset]; - //localcolor = SKINCOLOR_JET; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_JET; break; case 4: // Grow localpatch = kp_grow[offset]; - //localcolor = SKINCOLOR_TEAL; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_TEAL; break; case 5: // Hyudoro localpatch = kp_hyudoro[offset]; - //localcolor = SKINCOLOR_STEEL; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_STEEL; break; case 6: // Rocket Sneaker localpatch = kp_rocketsneaker[offset]; - //localcolor = SKINCOLOR_TANGERINE; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_TANGERINE; break; case 7: // Jawz localpatch = kp_jawz[offset]; - //localcolor = SKINCOLOR_JAWZ; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_JAWZ; break; case 8: // Self-Propelled Bomb localpatch = kp_selfpropelledbomb[offset]; - //localcolor = SKINCOLOR_JET; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_JET; break; case 9: // Shrink localpatch = kp_shrink[offset]; - //localcolor = SKINCOLOR_ORANGE; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_ORANGE; break; case 10: // Invincibility localpatch = localinv; - //localcolor = SKINCOLOR_GREY; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_GREY; break; case 11: // Eggman Monitor localpatch = kp_eggman[offset]; - //localcolor = SKINCOLOR_ROSE; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_ROSE; break; case 12: // Ballhog localpatch = kp_ballhog[offset]; - //localcolor = SKINCOLOR_LILAC; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_LILAC; break; case 13: // Thunder Shield localpatch = kp_thundershield[offset]; - //localcolor = SKINCOLOR_CYAN; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_CYAN; break; /*case 14: // Pogo Spring localpatch = kp_pogospring[offset]; - localcolor = SKINCOLOR_TANGERINE; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_TANGERINE; break; case 15: // Kitchen Sink localpatch = kp_kitchensink[offset]; - localcolor = SKINCOLOR_STEEL; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_STEEL; break;*/ default: break; diff --git a/src/k_hud.h b/src/k_hud.h index ca38f43ea..45d5260d6 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -41,6 +41,7 @@ extern consvar_t cv_showlaptimes; extern consvar_t cv_battlespeedo; extern consvar_t cv_multiitemicon; extern consvar_t cv_huditemamount; +extern consvar_t cv_roulettecolor; // for use in timeattack menu extern patch_t *kp_facenum[MAXPLAYERS+1]; diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 3189bbc1a..912ee3dec 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1848,26 +1848,28 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING|IT_CVAR, NULL, "Item Amount Number", &cv_huditemamount, 110}, {IT_STRING|IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 115}, - {IT_STRING|IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 125}, - {IT_STRING|IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 130}, + {IT_STRING|IT_CVAR, NULL, "Item Roulette Color", &cv_roulettecolor, 120}, - {IT_STRING|IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 140}, - {IT_STRING|IT_CVAR, NULL, "Show Finished on Minimap", &cv_showminimapfinished, 145}, - {IT_STRING|IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 150}, - {IT_STRING|IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 155}, - {IT_STRING|IT_CVAR, NULL, "Player Angle Visual", &cv_showminimapangle, 160}, + {IT_STRING|IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 130}, + {IT_STRING|IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 135}, - {IT_STRING|IT_CVAR, NULL, "Music Credits", &cv_songcredits, 170}, - {IT_STRING|IT_CVAR, NULL, "Music Credits on Pause", &cv_pausesongcredits, 175}, + {IT_STRING|IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 145}, + {IT_STRING|IT_CVAR, NULL, "Show Finished on Minimap", &cv_showminimapfinished, 150}, + {IT_STRING|IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 155}, + {IT_STRING|IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 160}, + {IT_STRING|IT_CVAR, NULL, "Player Angle Visual", &cv_showminimapangle, 165}, - {IT_STRING|IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 185}, + {IT_STRING|IT_CVAR, NULL, "Music Credits", &cv_songcredits, 175}, + {IT_STRING|IT_CVAR, NULL, "Music Credits on Pause", &cv_pausesongcredits, 180}, - {IT_STRING|IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 195}, + {IT_STRING|IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 190}, - {IT_STRING|IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 205}, - {IT_STRING|IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 210}, + {IT_STRING|IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 200}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 220}, + {IT_STRING|IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 210}, + {IT_STRING|IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 215}, + + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 225}, }; static const char* OP_SaturnHudTooltips[] = @@ -1888,6 +1890,7 @@ static const char* OP_SaturnHudTooltips[] = "Use extra graphics for multiple sneakers, bananas and jawz.", "Change when the item amount is to be displayed.\nMultiple will always display the number.\nWhen you have multiple of the same Item.\nAlways will always display the number regardless of Item amount.", "Enables an animation while the roulette is active.", + "Changes whether items in roulette have same color as player or an item-specific one.", "Show the big 'LAP' text on a lap change.", "Show the big Cecho Messages.", "Show player names on the minimap.", From 5f559af29c83790cf5637df4312acc9826ff0c6e Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 13 Jun 2026 02:12:23 +0300 Subject: [PATCH 16/30] Add more options to roulettecolor --- src/k_hud.c | 44 +++++++++++++++++++++++++------------------- src/m_menudefs.c | 2 +- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index e3a7f3ec5..a068bb7f8 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -109,8 +109,11 @@ consvar_t cv_huditemamount = {"showitemamountnumber", "Vanilla", CV_SAVE, hudite consvar_t cv_fancyroulette = {"animatedroulette", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_darkitembox = {"darkitembox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // itembox gets a dark border with specific items consvar_t cv_multiitemicon = {"multiitemicon", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t roulettecolor_cons_t[] = {{0, "Player"}, {1, "Item"}, {0, NULL}}; -consvar_t cv_roulettecolor = {"roulettecolor", "Player", CV_SAVE, roulettecolor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +enum { ROULETTECOLOR_NONE = -1, ROULETTECOLOR_HUD, ROULETTECOLOR_PLAYER, ROULETTECOLOR_ITEM }; +static CV_PossibleValue_t roulettecolor_cons_t[] = { + {ROULETTECOLOR_NONE, "None"}, {ROULETTECOLOR_HUD, "Hud"}, {ROULETTECOLOR_PLAYER, "Player"}, {ROULETTECOLOR_ITEM, "Item"}, {0, NULL}}; +consvar_t cv_roulettecolor = {"roulettecolor", "Hud", CV_SAVE, roulettecolor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showlaptimes = {"showlaptimes", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1505,7 +1508,7 @@ static void K_drawKartItem(void) INT32 maxl = 0; // itembar's normal highest value const INT32 barlength = (splitscreen > 1 ? 12 : 26); UINT8 localcolor = SKINCOLOR_NONE; - SINT8 colormode = TC_RAINBOW; + SINT8 colormode = cv_roulettecolor.value == ROULETTECOLOR_NONE ? TC_DEFAULT : TC_RAINBOW; UINT8 *colmap = NULL; UINT8 *colormap = NULL; @@ -1513,72 +1516,75 @@ static void K_drawKartItem(void) { localcolor = K_GetHudColor(); + if (cv_roulettecolor.value == ROULETTECOLOR_PLAYER) + localcolor = stplyr->skincolor; + switch ((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3) { // Each case is handled in threes, to give three frames of in-game time to see the item on the roulette case 0: // Sneaker localpatch = kp_sneaker[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_RASPBERRY; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_RASPBERRY; break; case 1: // Banana localpatch = kp_banana[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_YELLOW; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_YELLOW; break; case 2: // Orbinaut localpatch = kp_orbinaut[3+offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_STEEL; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_STEEL; break; case 3: // Mine localpatch = kp_mine[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_JET; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_JET; break; case 4: // Grow localpatch = kp_grow[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_TEAL; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_TEAL; break; case 5: // Hyudoro localpatch = kp_hyudoro[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_STEEL; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_STEEL; break; case 6: // Rocket Sneaker localpatch = kp_rocketsneaker[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_TANGERINE; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_TANGERINE; break; case 7: // Jawz localpatch = kp_jawz[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_JAWZ; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_JAWZ; break; case 8: // Self-Propelled Bomb localpatch = kp_selfpropelledbomb[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_JET; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_JET; break; case 9: // Shrink localpatch = kp_shrink[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_ORANGE; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_ORANGE; break; case 10: // Invincibility localpatch = localinv; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_GREY; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_GREY; break; case 11: // Eggman Monitor localpatch = kp_eggman[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_ROSE; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_ROSE; break; case 12: // Ballhog localpatch = kp_ballhog[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_LILAC; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_LILAC; break; case 13: // Thunder Shield localpatch = kp_thundershield[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_CYAN; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_CYAN; break; /*case 14: // Pogo Spring localpatch = kp_pogospring[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_TANGERINE; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_TANGERINE; break; case 15: // Kitchen Sink localpatch = kp_kitchensink[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_STEEL; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_STEEL; break;*/ default: break; diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 912ee3dec..0f7b5736d 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1890,7 +1890,7 @@ static const char* OP_SaturnHudTooltips[] = "Use extra graphics for multiple sneakers, bananas and jawz.", "Change when the item amount is to be displayed.\nMultiple will always display the number.\nWhen you have multiple of the same Item.\nAlways will always display the number regardless of Item amount.", "Enables an animation while the roulette is active.", - "Changes whether items in roulette have same color as player or an item-specific one.", + "Changes the way items are colorized in roulette.", "Show the big 'LAP' text on a lap change.", "Show the big Cecho Messages.", "Show player names on the minimap.", From b24f6683b77076f64c01e04209de0f3bc5eb24c1 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 13 Jun 2026 02:25:43 +0300 Subject: [PATCH 17/30] Use SKINCOLOR_NONE for ROULETTECOLOR_NONE instead of TC_DEFAULT --- src/k_hud.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index a068bb7f8..335e97340 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1508,16 +1508,16 @@ static void K_drawKartItem(void) INT32 maxl = 0; // itembar's normal highest value const INT32 barlength = (splitscreen > 1 ? 12 : 26); UINT8 localcolor = SKINCOLOR_NONE; - SINT8 colormode = cv_roulettecolor.value == ROULETTECOLOR_NONE ? TC_DEFAULT : TC_RAINBOW; + SINT8 colormode = TC_RAINBOW; UINT8 *colmap = NULL; UINT8 *colormap = NULL; if (stplyr->kartstuff[k_itemroulette]) { - localcolor = K_GetHudColor(); - if (cv_roulettecolor.value == ROULETTECOLOR_PLAYER) localcolor = stplyr->skincolor; + else if (cv_roulettecolor.value != ROULETTECOLOR_NONE) + localcolor = K_GetHudColor(); switch ((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3) { From cc6437285fa3be85ca439d2477b9bd6702ec753a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jun 2026 12:58:29 +0200 Subject: [PATCH 18/30] =?UTF-8?q?check=20for=20missized=20rejectmatrix?= =?UTF-8?q?=C2=B4s=20on=20load,=20pad=20them=20if=20needed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this is what dsda-doom/prboom does ensures we wont crash from oob reads and makes us print a warning --- src/p_local.h | 8 +------- src/p_setup.c | 29 ++++++++++++++++++----------- src/p_sight.c | 7 ++----- src/y_inter.c | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index eb55f5dd4..383469bcc 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -414,13 +414,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object); // // P_SETUP // -typedef struct -{ - UINT8* data; - size_t size; -} reject_t; - -extern reject_t rejectmatrix; // for fast sight rejection +extern UINT8 *rejectmatrix; // for fast sight rejection extern INT32 *blockmaplump; // offsets in blockmap are from here extern INT32 *blockmap; // Big blockmap extern INT32 bmapwidth; diff --git a/src/p_setup.c b/src/p_setup.c index c8403538a..e8e654c3c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -145,7 +145,7 @@ precipmobj_t **precipblocklinks = NULL; // Speeds up enemy AI by skipping detailed LineOf Sight calculation. // Without special effect, this could be used as a PVS lookup as well. // -reject_t rejectmatrix = {}; +UINT8 *rejectmatrix = NULL; // Maintain single and multi player starting spots. INT32 numdmstarts = 0, numcoopstarts = 0, numredctfstarts = 0, numbluectfstarts = 0; @@ -1780,23 +1780,29 @@ static void P_GroupLines(void) } } - // PK3 version // -- Monster Iestyn 09/01/18 -static void P_LoadReject(UINT8 *data, size_t count) +static void P_LoadReject(UINT8 *data, size_t rejectsize) { - if (!count) // zero length, someone probably used ZDBSP + const size_t neededsize = (numsectors * numsectors + 7) >> 3; + size_t allocsize = rejectsize; + + if (!rejectsize) // zero length, someone probably used ZDBSP { - rejectmatrix.data = NULL; + rejectmatrix = NULL; CONS_Debug(DBG_SETUP, "P_LoadReject: REJECT lump has size 0, will not be loaded\n"); } else { - rejectmatrix.data = Z_Malloc(count, PU_LEVEL, NULL); // allocate memory for the reject matrix - memcpy(rejectmatrix.data, data, count); // copy the data into it - } + if (rejectsize < neededsize) + { + CONS_Alert(CONS_WARNING, "REJECT is %lu byte%s too small. REJECT might be invalid and might crash vanilla clients!\n", (neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); + allocsize = neededsize; + } - rejectmatrix.size = count; + rejectmatrix = Z_Calloc(allocsize, PU_LEVEL, NULL); // allocate memory for the reject matrix + memcpy(rejectmatrix, data, rejectsize); // copy the data into it + } } static void P_LoadMapBSP(const virtres_t* virt) @@ -1833,11 +1839,12 @@ static void P_LoadMapLUT(const virtres_t* virt) // Lookup tables if (virtreject) + { P_LoadReject(virtreject->data, virtreject->size); + } else { - rejectmatrix.data = NULL; - rejectmatrix.size = 0; + rejectmatrix = NULL; } if (!(virtblockmap && P_LoadRawBlockMap(virtblockmap->data, virtblockmap->size))) diff --git a/src/p_sight.c b/src/p_sight.c index 63b87820e..7bde2d737 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -373,13 +373,10 @@ boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast) s2 = t2->subsector->sector; pnum = (s1-sectors)*numsectors + (s2-sectors); - if (rejectmatrix.data != NULL) + if (rejectmatrix != NULL) { - const size_t shiftnum = pnum>>3; - // Check in REJECT table. - if (shiftnum < rejectmatrix.size && // check for overflow - (rejectmatrix.data[shiftnum] & (1 << (pnum&7)))) // can't possibly be connected + if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected { return false; } diff --git a/src/y_inter.c b/src/y_inter.c index 19b696b0e..a92392f39 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -586,7 +586,7 @@ void Y_Ticker(void) if (data.rankingsmode && intertic > sorttic+16+(2*TICRATE)) { - INT32 q=0,r=0; + INT32 q = 0, r = 0; boolean kaching = true; for (q = 0; q < data.numplayers; q++) From 2c1bb6c268cbd754d425b9eb3b2e44658692ff05 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jun 2026 13:06:37 +0200 Subject: [PATCH 19/30] smol optimize fof checks in P_CheckSight check if fof is solid before height comparisons, also split initial height comparisons to save on some height checks in some cases --- src/p_sight.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index 7bde2d737..73c98f8f3 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -432,21 +432,30 @@ boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast) continue; } - topz1 = P_GetFFloorTopZAt (rover, t1->x, t1->y); - topz2 = P_GetFFloorTopZAt (rover, t2->x, t2->y); - bottomz1 = P_GetFFloorBottomZAt(rover, t1->x, t1->y); - bottomz2 = P_GetFFloorBottomZAt(rover, t2->x, t2->y); + if (rover->flags & FF_SOLID) + { + continue; // shortcut since neither mobj can be inside the 3dfloor + } // Check for blocking floors here. - if ((los.sightzstart < bottomz1 && t2->z >= topz2) - || (los.sightzstart >= topz1 && t2->z + t2->height < bottomz2)) + + topz2 = P_GetFFloorTopZAt (rover, t2->x, t2->y); + bottomz1 = P_GetFFloorBottomZAt(rover, t1->x, t1->y); + + if (los.sightzstart < bottomz1 && t2->z >= topz2) { // no way to see through that return false; } - if (rover->flags & FF_SOLID) - continue; // shortcut since neither mobj can be inside the 3dfloor + topz1 = P_GetFFloorTopZAt (rover, t1->x, t1->y); + bottomz2 = P_GetFFloorBottomZAt(rover, t2->x, t2->y); + + if (los.sightzstart >= topz1 && t2->z + t2->height < bottomz2) + { + // no way to see through that + return false; + } if (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES)) { From 14aaba7a879cfb7615af0d423f4bfa2fd4992151 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jun 2026 13:20:43 +0200 Subject: [PATCH 20/30] make reject matrix print an error instead of warning better on 2nd thought as this may crash vanilla clients that use nametags --- src/p_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index e8e654c3c..f0b931d27 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1796,7 +1796,7 @@ static void P_LoadReject(UINT8 *data, size_t rejectsize) { if (rejectsize < neededsize) { - CONS_Alert(CONS_WARNING, "REJECT is %lu byte%s too small. REJECT might be invalid and might crash vanilla clients!\n", (neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); + CONS_Alert(CONS_ERROR, "REJECT is %lu byte%s too small. REJECT might be invalid and might crash vanilla clients!\n", (neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); allocsize = neededsize; } From 8129b89034b84819ef270560526b9f85924ed7cf Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jun 2026 13:34:43 +0200 Subject: [PATCH 21/30] port P_VerifyBlockMap from dsda-doom to check for blockmap issues that might cause crashes --- src/p_setup.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index f0b931d27..95d3144b3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1625,6 +1625,80 @@ static void P_CreateBlockMap(void) } } +// +// P_VerifyBlockMap +// +// haleyjd 03/04/10: do verification on validity of blockmap. +// +static boolean P_VerifyBlockMap(INT32 count) +{ + // FIXME: should any of this shit be unsinged? + INT32 x, y; + INT32 *maxoffs = blockmaplump + count; + + //skipblstart = true; + + for (y = 0; y < bmapheight; y++) + { + for (x = 0; x < bmapwidth; x++) + { + INT32 offset; + INT32 *list, *tmplist; + INT32 *blockoffset; + + offset = y * bmapwidth + x; + blockoffset = blockmaplump + offset + 4; + + // check that block offset is in bounds + if (blockoffset >= maxoffs) + { + CONS_Alert(CONS_ERROR, "P_VerifyBlockMap: block offset overflow\n"); + return false; + } + + offset = *blockoffset; + + // check that list offset is in bounds + if (offset < 4 || offset >= count) + { + CONS_Alert(CONS_ERROR, "P_VerifyBlockMap: list offset overflow\n"); + return false; + } + + list = blockmaplump + offset; + + //if (*list != 0) + //skipblstart = false; + + // scan forward for a -1 terminator before maxoffs + for (tmplist = list; ; tmplist++) + { + // we have overflowed the lump? + if (tmplist >= maxoffs) + { + CONS_Alert(CONS_ERROR, "P_VerifyBlockMap: open blocklist\n"); + return false; + } + + if (*tmplist == -1) // found -1 + break; + } + + // scan the list for out-of-range linedef indicies in list + for (tmplist = list; *tmplist != -1; tmplist++) + { + if (*tmplist < 0 || *tmplist >= (INT32)numlines) + { + CONS_Alert(CONS_ERROR, "P_VerifyBlockMap: index >= numlines\n"); + return false; + } + } + } + } + + return true; +} + // Split from P_LoadBlockMap for convenience // -- Monster Iestyn 08/01/18 static void P_ReadBlockMapLump(INT16 *wadblockmaplump, size_t count) @@ -1669,6 +1743,14 @@ static boolean P_LoadRawBlockMap(UINT8 *data, size_t count) bmapwidth = blockmaplump[2]; bmapheight = blockmaplump[3]; + // haleyjd 03/04/10: check for blockmap problems + // http://www.doomworld.com/idgames/index.php?id=12935 + if (!P_VerifyBlockMap(count)) + { + CONS_Alert(CONS_ERROR, "P_LoadBlockMap: erroneous BLOCKMAP lump may cause crashes.\n"); + //CONS_Alert(CONS_NOTICE, "P_LoadBlockMap: use \"-blockmap\" command line switch for rebuilding\n"); + } + // clear out mobj chains count = sizeof (*blocklinks)* bmapwidth*bmapheight; blocklinks = Z_Calloc(count, PU_LEVEL, NULL); From ab0d071d35e53af3380b73392ea899fc1350a5b0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jun 2026 13:41:00 +0200 Subject: [PATCH 22/30] use sizeu1 instead of %lu windoze....... --- src/p_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 95d3144b3..4423b7d26 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1878,7 +1878,7 @@ static void P_LoadReject(UINT8 *data, size_t rejectsize) { if (rejectsize < neededsize) { - CONS_Alert(CONS_ERROR, "REJECT is %lu byte%s too small. REJECT might be invalid and might crash vanilla clients!\n", (neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); + CONS_Alert(CONS_ERROR, "REJECT is %s byte%s too small. REJECT might be invalid and might crash vanilla clients!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); allocsize = neededsize; } From e1061ab4b4db007518a3fabcf19cbdb4232251aa Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jun 2026 15:11:41 +0200 Subject: [PATCH 23/30] add PARANOIA cases for reject and blockmap stuff also see comment --- src/p_setup.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 4423b7d26..0be23b262 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1740,15 +1740,23 @@ static boolean P_LoadRawBlockMap(UINT8 *data, size_t count) bmaporgx = blockmaplump[0]< Date: Mon, 15 Jun 2026 14:48:21 +0200 Subject: [PATCH 24/30] handle interrupt signals during CONS_Error also move stuff into smol inline function --- src/console.c | 2 ++ src/d_clisrv.c | 5 +---- src/d_main.c | 5 +---- src/f_wipe.c | 5 +---- src/i_system.h | 5 +++++ 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/console.c b/src/console.c index d02f68bb6..8ca29f901 100644 --- a/src/console.c +++ b/src/console.c @@ -1437,6 +1437,8 @@ void CONS_Error(const char *msg) // dirty quick hack, but for the good cause while (I_GetKey() != KEY_ENTER) { + I_HandleInterrupt(); + // Sleep so we don't take too much of cpu usage I_Sleep(1.f/TICRATE*1000); diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d5f10daa3..7113f6ca9 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2858,10 +2858,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic { INT32 key; - if (I_Interrupted()) - { - I_Quit(); - } + I_HandleInterrupt(); I_OsPolling(); diff --git a/src/d_main.c b/src/d_main.c index c9df6e441..be19da2de 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -726,10 +726,7 @@ void D_SRB2Loop(void) enterprecise = I_GetPreciseTime(); - if (I_Interrupted()) - { - I_Quit(); - } + I_HandleInterrupt(); memset(&g_dc, 0, sizeof(g_dc)); Z_Frame_Reset(); diff --git a/src/f_wipe.c b/src/f_wipe.c index 18100da4c..32b385c9e 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -361,10 +361,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu) // on for fade-to-black for (;;) { - if (I_Interrupted()) - { - I_Quit(); - } + I_HandleInterrupt(); // get fademask first so we can tell if it exists or not fmask = F_GetFadeMask(wipetype, wipeframe++); diff --git a/src/i_system.h b/src/i_system.h index 9457e9c6d..9e981cf0f 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -203,6 +203,11 @@ void I_ShutdownSystem(void); /** \brief To check if a Interrupt or Terminate Signal was fired */ boolean I_Interrupted(void); +static inline void I_HandleInterrupt(void) +{ + if (I_Interrupted()) + I_Quit(); +} /** \brief The I_GetDiskFreeSpace function From 96a29abc62e53f9cdd455fae517ad1743e9ca0df Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 15 Jun 2026 14:53:20 +0200 Subject: [PATCH 25/30] move this back might change behavior of this, which may desynch in rare cases --- src/p_sight.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index 73c98f8f3..3eb4788b0 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -432,11 +432,6 @@ boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast) continue; } - if (rover->flags & FF_SOLID) - { - continue; // shortcut since neither mobj can be inside the 3dfloor - } - // Check for blocking floors here. topz2 = P_GetFFloorTopZAt (rover, t2->x, t2->y); @@ -457,6 +452,11 @@ boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast) return false; } + if (rover->flags & FF_SOLID) + { + continue; // shortcut since neither mobj can be inside the 3dfloor + } + if (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES)) { if (los.sightzstart >= topz1 && t2->z + t2->height < topz2) From 51d9aa6197d04efe8ed5764a1b05b1f9f8f738b6 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 16 Jun 2026 12:31:53 +0200 Subject: [PATCH 26/30] add credit to bayer dither shader sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit completely forgot about this (sry!) the original implementation was mostly based on hughsk´s 8x8 bayer shader while the current is mostly adapted from the libretro 4x4 bayer shader --- src/hardware/hw_shaders.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index ff8b229de..baedebf64 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -76,6 +76,11 @@ // // Include GLSL_FLOOR_FUDGES or GLSL_WALL_FUDGES or define the fudges in shaders that use this macro. + +// dither shader based on +// https://github.com/hughsk/glsl-dither/blob/master/8x8.glsl +// https://github.com/libretro/glsl-shaders/blob/master/dithering/shaders/bayer_4x4.glsl +// adapted and messed about to work with srb2 and scale per resolution #define GLSL_DOOM_COLORMAP_DITHER \ "float baseValue = max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ "float patscale = min(scr_resolution.x / 1280.0, scr_resolution.y / 720.0);\n" \ From e94fecf56d2e6b67aaddaa125628c9a73cf310ea Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 16 Jun 2026 19:07:54 +0200 Subject: [PATCH 27/30] cleanup even more style issues also should fix R_InitSprites printing the wrong spritename in some cases --- src/dehacked.c | 137 +++++++++++++++++++++++++-------------- src/g_demo.c | 20 +++--- src/hardware/hw_portal.c | 12 ++-- src/r_patch.cpp | 2 +- src/r_skins.c | 2 +- src/r_things.cpp | 64 ++++++++++-------- 6 files changed, 142 insertions(+), 95 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 323261243..cfac59656 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -337,12 +337,14 @@ static void readfreeslots(MYFILE *f) { if (used_spr[(i-SPR_FIRSTFREESLOT)/8] & (1<<(i%8))) { - if (!sprnames[i][4] && memcmp(sprnames[i],word,4)==0) + if (!sprnames[i][4] && memcmp(sprnames[i], word, 4) == 0) sprnames[i][4] = (char)f->wad; + continue; // Already allocated, next. } + // Found a free slot! - strncpy(sprnames[i],word,4); + strncpy(sprnames[i], word, 4); //sprnames[i][4] = 0; CONS_Printf("Sprite SPR_%s allocated.\n",word); @@ -351,22 +353,26 @@ static void readfreeslots(MYFILE *f) used_spr[(i-SPR_FIRSTFREESLOT)/8] |= 1<<(i%8); // Okay, this sprite slot has been named now. break; } + if (i > SPR_LASTFREESLOT) I_Error("Out of Sprite Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } else if (fastcmp(type, "S")) { for (i = 0; i < NUMSTATEFREESLOTS; i++) - if (!FREE_STATES[i]) { - CONS_Printf("State S_%s allocated.\n",word); + { + if (!FREE_STATES[i]) + { + CONS_Printf("State S_%s allocated.\n", word); LUA_InvalidateMathlibCache(va("S_%s", word)); FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_STATES[i],word); + strcpy(FREE_STATES[i], word); freeslotusage[0][0]++; break; } + } if (i == NUMSTATEFREESLOTS) I_Error("Out of State Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); @@ -374,16 +380,19 @@ static void readfreeslots(MYFILE *f) else if (fastcmp(type, "MT")) { for (i = 0; i < NUMMOBJFREESLOTS; i++) - if (!FREE_MOBJS[i]) { - CONS_Printf("MobjType MT_%s allocated.\n",word); + { + if (!FREE_MOBJS[i]) + { + CONS_Printf("MobjType MT_%s allocated.\n", word); LUA_InvalidateMathlibCache(va("MT_%s", word)); FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_MOBJS[i],word); + strcpy(FREE_MOBJS[i], word); freeslotusage[1][0]++; break; } + } if (i == NUMMOBJFREESLOTS) I_Error("Out of Mobj Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); @@ -426,8 +435,11 @@ static void readthing(MYFILE *f, INT32 num) strupr(word2); else break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + + const size_t word2len = strlen(word2); + + if (word2[word2len-1] == '\n') + word2[word2len-1] = '\0'; if (fastcmp(word, "MAPTHINGNUM") || fastcmp(word, "DOOMEDNUM")) { @@ -734,14 +746,20 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) { UINT16 tol = 0; tmp = strtok(word2,","); + do { for (i = 0; TYPEOFLEVEL[i].name; i++) + { if (fastcmp(tmp, TYPEOFLEVEL[i].name)) break; + } + if (!TYPEOFLEVEL[i].name) deh_warning("Level header %d: unknown typeoflevel flag %s\n", num, tmp); + tol |= TYPEOFLEVEL[i].flag; } while((tmp = strtok(NULL,",")) != NULL); + mapheaderinfo[num-1]->typeoflevel = tol; } } @@ -1037,8 +1055,11 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) else break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + const size_t word2len = strlen(word2); + + if (word2[word2len-1] == '\n') + word2[word2len-1] = '\0'; + i = atoi(word2); usi = (UINT16)i; @@ -1088,12 +1109,14 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) else if (fastcmp(word, "MUSICSLOT")) { i = get_mus(word2, true); + if (i && i <= 1035) snprintf(cutscenes[num]->scene[scenenum].musswitch, 7, "%sM", G_BuildMapName(i)); else if (i && i <= 1050) strncpy(cutscenes[num]->scene[scenenum].musswitch, compat_special_music_slots[i - 1036], 7); else cutscenes[num]->scene[scenenum].musswitch[0] = 0; // becomes empty string + cutscenes[num]->scene[scenenum].musswitch[6] = 0; } #endif @@ -1498,8 +1521,11 @@ static void readframe(MYFILE *f, INT32 num) strupr(word2); else break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + + const size_t word2len = strlen(word2); + + if (word2[word2len-1] == '\n') + word2[word2len-1] = '\0'; if (fastcmp(word1, "SPRITENUMBER") || fastcmp(word1, "SPRITENAME")) { @@ -1828,13 +1854,19 @@ static void readextraemblemdata(MYFILE *f, INT32 num) value = atoi(word2); // used for numerical settings if (fastcmp(word, "NAME")) + { deh_strlcpy(extraemblems[num-1].name, word2, - sizeof (extraemblems[num-1].name), va("Extra emblem %d: name", num)); + sizeof (extraemblems[num-1].name), va("Extra emblem %d: name", num)); + } else if (fastcmp(word, "OBJECTIVE")) + { deh_strlcpy(extraemblems[num-1].description, word2, - sizeof (extraemblems[num-1].description), va("Extra emblem %d: objective", num)); + sizeof (extraemblems[num-1].description), va("Extra emblem %d: objective", num)); + } else if (fastcmp(word, "CONDITIONSET")) + { extraemblems[num-1].conditionset = (UINT8)value; + } else if (fastcmp(word, "SPRITE")) { if (word2[0] >= 'A' && word2[0] <= 'Z') @@ -1906,11 +1938,15 @@ static void readunlockable(MYFILE *f, INT32 num) i = atoi(word2); // used for numerical settings if (fastcmp(word, "NAME")) + { deh_strlcpy(unlockables[num].name, word2, - sizeof (unlockables[num].name), va("Unlockable %d: name", num)); + sizeof (unlockables[num].name), va("Unlockable %d: name", num)); + } else if (fastcmp(word, "OBJECTIVE")) + { deh_strlcpy(unlockables[num].objective, word2, - sizeof (unlockables[num].objective), va("Unlockable %d: objective", num)); + sizeof (unlockables[num].objective), va("Unlockable %d: objective", num)); + } else if (fastcmp(word, "SHOWCONDITIONSET")) unlockables[num].showconditionset = (UINT8)i; else if (fastcmp(word, "CONDITIONSET")) @@ -8102,7 +8138,7 @@ static mobjtype_t get_mobjtype(const char *word) if (*word >= '0' && *word <= '9') return atoi(word); - if (fastncmp("MT_",word,3)) + if (fastncmp("MT_", word, 3)) word += 3; // take off the MT_ for (i = 0; i < NUMMOBJFREESLOTS; i++) @@ -8128,7 +8164,7 @@ static statenum_t get_state(const char *word) if (*word >= '0' && *word <= '9') return atoi(word); - if (fastncmp("S_",word,2)) + if (fastncmp("S_", word, 2)) word += 2; // take off the S_ for (i = 0; i < NUMSTATEFREESLOTS; i++) @@ -8155,11 +8191,11 @@ static spritenum_t get_sprite(const char *word) if (*word >= '0' && *word <= '9') return atoi(word); - if (fastncmp("SPR_",word,4)) + if (fastncmp("SPR_", word, 4)) word += 4; // take off the SPR_ for (i = 0; i < NUMSPRITES; i++) - if (!sprnames[i][4] && memcmp(word,sprnames[i],4) == 0) + if (!sprnames[i][4] && memcmp(word, sprnames[i], 4) == 0) return i; deh_warning("Couldn't find sprite named 'SPR_%s'",word); @@ -8200,14 +8236,15 @@ static UINT16 get_mus(const char *word, UINT8 dehacked_mode) if (!word[2] && toupper(word[0]) >= 'A' && toupper(word[0]) <= 'Z') return (UINT16)M_MapNumber(word[0], word[1]); - if (fastncmp("MUS_",word,4)) + if (fastncmp("MUS_", word, 4)) word += 4; // take off the MUS_ - else if (fastncmp("O_",word,2) || fastncmp("D_",word,2)) + else if (fastncmp("O_", word, 2) || fastncmp("D_", word, 2)) word += 2; // take off the O_ or D_ strncpy(lumptmp, word, 4); lumptmp[3] = 0; - if (fasticmp("MAP",lumptmp)) + + if (fasticmp("MAP", lumptmp)) { word += 3; if (toupper(word[0]) >= 'A' && toupper(word[0]) <= 'Z') @@ -8320,7 +8357,7 @@ static inline int lib_freeslot(lua_State *L) { sfxenum_t sfx; strlwr(word); - CONS_Printf("Sound sfx_%s allocated.\n",word); + CONS_Printf("Sound sfx_%s allocated.\n", word); sfx = S_AddSoundFx(word, false, 0, false); if (sfx != sfx_None) @@ -8344,8 +8381,10 @@ static inline int lib_freeslot(lua_State *L) { if (!sprnames[j][4] && memcmp(sprnames[j], word, 4) == 0) sprnames[j][4] = wad; + continue; // Already allocated, next. } + // Found a free slot! CONS_Printf("Sprite SPR_%s allocated.\n",word); @@ -8353,7 +8392,7 @@ static inline int lib_freeslot(lua_State *L) lua_pushfstring(L, "SPR_%s", word); lua_call(L, 1, 0); - strncpy(sprnames[j],word,4); + strncpy(sprnames[j], word, 4); //sprnames[j][4] = 0; used_spr[(j-SPR_FIRSTFREESLOT)/8] |= 1<<(j%8); // Okay, this sprite slot has been named now. lua_pushinteger(L, j); @@ -8371,7 +8410,7 @@ static inline int lib_freeslot(lua_State *L) { if (!FREE_STATES[i]) { - CONS_Printf("State S_%s allocated.\n",word); + CONS_Printf("State S_%s allocated.\n", word); lua_pushcfunction(L, lua_glib_invalidate_cache); lua_pushfstring(L, "S_%s", word); @@ -8396,14 +8435,14 @@ static inline int lib_freeslot(lua_State *L) { if (!FREE_MOBJS[i]) { - CONS_Printf("MobjType MT_%s allocated.\n",word); + CONS_Printf("MobjType MT_%s allocated.\n", word); lua_pushcfunction(L, lua_glib_invalidate_cache); lua_pushfstring(L, "MT_%s", word); lua_call(L, 1, 0); FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_MOBJS[i],word); + strcpy(FREE_MOBJS[i], word); freeslotusage[1][0]++; lua_pushinteger(L, i); r++; @@ -8590,6 +8629,7 @@ static int lua_enumlib_mobjtype_get(lua_State *L) { if (!FREE_MOBJS[i]) break; + if (fastcmp(s+3, FREE_MOBJS[i])) { lua_pushinteger(L, MT_FIRSTFREESLOT+i); @@ -8678,30 +8718,29 @@ static int lua_enumlib_sfx_get_ds(lua_State *L) } #ifdef MUSICSLOT_COMPATIBILITY +static int lua_enumlib_mus_get(lua_State *L) +{ + const char *name = strchr(lua_tostring(L, 1), '_') + 1; + int mus = get_mus(name, false); - static int lua_enumlib_mus_get(lua_State *L) - { - const char *name = strchr(lua_tostring(L, 1), '_') + 1; - int mus = get_mus(name, false); + if (mus == 0) + return 0; - if (mus == 0) - return 0; + lua_pushinteger(L, mus); + return 1; +} - lua_pushinteger(L, mus); - return 1; - } +static int lua_enumlib_mus_get_mathlib(lua_State *L) +{ + const char *name = strchr(lua_tostring(L, 1), '_') + 1; + int mus = get_mus(name, false); - static int lua_enumlib_mus_get_mathlib(lua_State *L) - { - const char *name = strchr(lua_tostring(L, 1), '_') + 1; - int mus = get_mus(name, false); + if (mus == 0) + return luaL_error(L, "music '%s' could not be found.\n", lua_tostring(L, 1)); - if (mus == 0) - return luaL_error(L, "music '%s' could not be found.\n", lua_tostring(L, 1)); - - lua_pushinteger(L, mus); - return 1; - } + lua_pushinteger(L, mus); + return 1; +} #endif static int lua_enumlib_power_get(lua_State *L) diff --git a/src/g_demo.c b/src/g_demo.c index 850e08048..de6a1bb5d 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -515,49 +515,49 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) if (cmd->forwardmove != oldcmd[playernum].forwardmove) { - WRITEUINT8(demobuf.p,cmd->forwardmove); + WRITEUINT8(demobuf.p, cmd->forwardmove); oldcmd[playernum].forwardmove = cmd->forwardmove; ziptic |= ZT_FWD; } if (cmd->sidemove != oldcmd[playernum].sidemove) { - WRITEUINT8(demobuf.p,cmd->sidemove); + WRITEUINT8(demobuf.p, cmd->sidemove); oldcmd[playernum].sidemove = cmd->sidemove; ziptic |= ZT_SIDE; } if (cmd->angleturn != oldcmd[playernum].angleturn) { - WRITEINT16(demobuf.p,cmd->angleturn); + WRITEINT16(demobuf.p, cmd->angleturn); oldcmd[playernum].angleturn = cmd->angleturn; ziptic |= ZT_ANGLE; } if (cmd->buttons != oldcmd[playernum].buttons) { - WRITEUINT16(demobuf.p,cmd->buttons); + WRITEUINT16(demobuf.p, cmd->buttons); oldcmd[playernum].buttons = cmd->buttons; ziptic |= ZT_BUTTONS; } if (cmd->aiming != oldcmd[playernum].aiming) { - WRITEINT16(demobuf.p,cmd->aiming); + WRITEINT16(demobuf.p, cmd->aiming); oldcmd[playernum].aiming = cmd->aiming; ziptic |= ZT_AIMING; } if (cmd->driftturn != oldcmd[playernum].driftturn) { - WRITEINT16(demobuf.p,cmd->driftturn); + WRITEINT16(demobuf.p, cmd->driftturn); oldcmd[playernum].driftturn = cmd->driftturn; ziptic |= ZT_DRIFT; } if (cmd->latency != oldcmd[playernum].latency) { - WRITEUINT8(demobuf.p,cmd->latency); + WRITEUINT8(demobuf.p, cmd->latency); oldcmd[playernum].latency = cmd->latency; ziptic |= ZT_LATENCY; } @@ -726,8 +726,8 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) // GZT_XYZ is only useful if you've moved 256 FRACUNITS or more in a single tic. if (abs(ghost->x-oldghost[playernum].x) > MAXMOM - || abs(ghost->y-oldghost[playernum].y) > MAXMOM - || abs(ghost->z-oldghost[playernum].z) > MAXMOM + || abs(ghost->y-oldghost[playernum].y) > MAXMOM + || abs(ghost->z-oldghost[playernum].z) > MAXMOM || ((UINT8)(leveltime & 255) > 0 && (UINT8)(leveltime & 255) <= (UINT8)cv_netdemosyncquality.value)) // Hack to enable slightly nicer resyncing { oldghost[playernum].x = ghost->x; @@ -1375,7 +1375,7 @@ fadeghost: UINT16 i, health; UINT16 count = READUINT16(g->p); //UINT32 type; - fixed_t x,y,z; + fixed_t x, y, z; angle_t angle; mobj_t *poof; diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index 117d59725..c64eedad0 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -80,8 +80,8 @@ void HWR_Portal_Add2Lines(const INT32 line1, const INT32 line2, seg_t *seg) gl_portal_t *portal = HWR_Portal_Add(seg); // Offset the portal view by the linedef centers - line_t* start = &lines[line1]; - line_t* dest = &lines[line2]; + line_t* start = &lines[line1]; + line_t* dest = &lines[line2]; angle_t dangle = R_PointToAngle2(0, 0, dest->dx, dest->dy) - R_PointToAngle2(start->dx, start->dy, 0, 0); @@ -99,7 +99,7 @@ void HWR_Portal_Add2Lines(const INT32 line1, const INT32 line2, seg_t *seg) dest_c.y = dest->v1->y/2 + dest->v2->y/2; disttopoint = R_PointToDist2(start_c.x, start_c.y, viewx, viewy); - angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy); + angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy); angtopoint += dangle; portal->viewx = dest_c.x + FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); @@ -220,9 +220,9 @@ boolean HWR_PortalCheckBBox(const fixed_t *bspcoord) if (!portalclipline) return true; - if (HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXTOP]) || - HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]) || - HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXTOP]) || + if (HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXTOP]) || + HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]) || + HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXTOP]) || HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM])) { return true; diff --git a/src/r_patch.cpp b/src/r_patch.cpp index f578a8f32..c7c49b827 100644 --- a/src/r_patch.cpp +++ b/src/r_patch.cpp @@ -289,7 +289,7 @@ void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum) sprinfoLumpLength = W_LumpLengthPwad(wadNum, lumpNum); sprinfoText = (char *)Z_Malloc((sprinfoLumpLength+1)*sizeof(char),PU_STATIC,NULL); // Now move the contents of the lump into this new location. - memmove(sprinfoText,sprinfoLump,sprinfoLumpLength); + memmove(sprinfoText, sprinfoLump, sprinfoLumpLength); // Make damn well sure the last character in our new memory location is \0. sprinfoText[sprinfoLumpLength] = '\0'; // Finally, free up the memory from the first data load, because we really diff --git a/src/r_skins.c b/src/r_skins.c index 9ab6e0fbf..b45dd0d58 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -712,7 +712,7 @@ void R_AddSkins(UINT16 wadnum, boolean local) // skip to end of this skin's frames lastlump = lump; - while (W_CheckNameForNumPwad(wadnum, lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump), csprname,4)==0) + while (W_CheckNameForNumPwad(wadnum, lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump), csprname, 4) == 0) lastlump++; // allocate (or replace) sprite frames, and set spritedef diff --git a/src/r_things.cpp b/src/r_things.cpp index 875cb7290..b4707db6f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -182,15 +182,14 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch UINT8 rightfactor = ((rotation == ROT_R) ? 4 : 0); // the lump should be used for half of all rotations - if (sprtemp[frame].rotate == SRF_SINGLE) + if (sprtemp[frame].rotate == SRF_NONE) + sprtemp[frame].rotate = SRF_SINGLE; + else if (sprtemp[frame].rotate == SRF_SINGLE) CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has L/R rotations and a rot = 0 lump\n", spritename, cn); else if (sprtemp[frame].rotate == SRF_3D) CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has both L/R and 1-8 rotations\n", spritename, cn); // Let's not complain about multiple L/R rotations. It's not worth the effort. - if (sprtemp[frame].rotate == SRF_NONE) - sprtemp[frame].rotate = SRF_SINGLE; - sprtemp[frame].rotate |= ((rotation == ROT_R) ? SRF_RIGHT : SRF_LEFT); if (sprtemp[frame].rotate == (SRF_3D|SRF_2D)) @@ -233,6 +232,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch // when using sprites in pwad : the lumppat points the new graphics sprtemp[frame].lumppat[rotation] = lumppat; sprtemp[frame].lumpid[rotation] = lumpid; + if (flipped) sprtemp[frame].flip |= (1<numframes) // (then spriteframes is not null) @@ -289,7 +291,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 if (frame >= 64 || !(R_ValidSpriteAngle(rotation))) // Give an actual NAME error -_-... { - CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum,l)); + CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum, l)); continue; } @@ -315,6 +317,15 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 { frame = R_Char2Frame(lumpinfo[l].name[6]); rotation = (UINT8)(lumpinfo[l].name[7] - '0'); + + /* + if (frame >= 64 || !(R_ValidSpriteAngle(rotation))) // Give an actual NAME error -_-... + { + CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum, l)); + continue; + } + */ + R_InstallSpriteLump(wadnum, l, numspritelumps, frame, rotation, 1); } @@ -363,30 +374,32 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 switch (sprtemp[frame].rotate) { case SRF_NONE: - // no rotations were found for that frame at all - I_Error("R_AddSingleSpriteDef: No patches found for %.4s frame %c", sprname, R_Frame2Char(frame)); - break; + // no rotations were found for that frame at all + I_Error("R_AddSingleSpriteDef: No patches found for %.4s frame %c", sprname, R_Frame2Char(frame)); + break; case SRF_SINGLE: - // only the first rotation is needed - break; + // only the first rotation is needed + break; case SRF_2D: // both Left and Right rotations // we test to see whether the left and right slots are present if ((sprtemp[frame].lumppat[2] == LUMPERROR) || (sprtemp[frame].lumppat[6] == LUMPERROR)) I_Error("R_AddSingleSpriteDef: Sprite %s frame %c is missing rotations", sprname, R_Frame2Char(frame)); - break; + break; default: - // must have all 8 frames - for (rotation = 0; rotation < 8; rotation++) - // we test the patch lump, or the id lump whatever - // if it was not loaded the two are LUMPERROR - if (sprtemp[frame].lumppat[rotation] == LUMPERROR) - I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations", - sprname, R_Frame2Char(frame)); - break; + // must have all 8 frames + for (rotation = 0; rotation < 8; rotation++) + { + // we test the patch lump, or the id lump whatever + // if it was not loaded the two are LUMPERROR + if (sprtemp[frame].lumppat[rotation] == LUMPERROR) + I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations", + sprname, R_Frame2Char(frame)); + } + break; } } @@ -394,7 +407,6 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 if (spritedef->numframes && // has been allocated spritedef->numframes < maxframe) // more frames are defined ? { - Z_Free(spritedef->spriteframes); spritedef->spriteframes = NULL; } @@ -451,12 +463,10 @@ void R_AddSpriteDefs(UINT16 wadnum) // for (i = 0; i < numsprites; i++) { - spritename = sprnames[i]; - - if (spritename[4] && wadnum >= (UINT16)spritename[4]) + if (sprnames[i][4] && wadnum >= (UINT16)sprnames[i][4]) continue; - if (R_AddSingleSpriteDef(spritename, &sprites[i], wadnum, start, end)) + if (R_AddSingleSpriteDef(sprnames[i], &sprites[i], wadnum, start, end)) { #ifdef HWRENDER if (rendermode == render_opengl) @@ -464,9 +474,7 @@ void R_AddSpriteDefs(UINT16 wadnum) #endif // if a new sprite was added (not just replaced) addsprites++; -#ifndef ZDEBUG - CONS_Debug(DBG_SETUP, "sprite %s set in pwad %d\n", spritename, wadnum); -#endif + CONS_Debug(DBG_SETUP, "sprite %s set in pwad %d\n", sprnames[i], wadnum); } } From 14ac3ca9b0bf3b8e2bd984bbf351b59210094b8a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 16 Jun 2026 20:05:04 +0200 Subject: [PATCH 28/30] ;;... --- src/hardware/r_opengl/r_opengl.c | 2 +- src/p_floor.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index de27795e3..d3136cbfc 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1698,7 +1698,7 @@ static void GL_SetBlendMode(FBITFIELD flags) void GL_SetBlend(FBITFIELD PolyFlags) { - const FBITFIELD Xor = CurrentPolyFlags^PolyFlags;; + const FBITFIELD Xor = CurrentPolyFlags^PolyFlags; if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Skydecal|PF_Invisible)) { diff --git a/src/p_floor.c b/src/p_floor.c index 3c4128777..29f872745 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -845,7 +845,7 @@ void T_BounceCheese(levelspecthink_t *bouncer) T_MovePlane(bouncer->sector, 0, bouncer->sector->ceilingheight, 0, 1, -1); // update things on ceiling T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor bouncer->sector->ceilingdata = NULL; - bouncer->sector->floordata = NULL;; + bouncer->sector->floordata = NULL; bouncer->sector->moved = true; P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives } From cfda853e6f19b6f797c3c000e2b8fb1afc42b759 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 18 Jun 2026 16:35:42 +0300 Subject: [PATCH 29/30] Add console variant for mute command, also fix it applying mute for players that are not in game --- src/hu_stuff.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 65bcf4e94..67bcf6371 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -133,6 +133,7 @@ static void Command_Say_f(void); static void Command_Sayto_f(void); static void Command_Sayteam_f(void); static void Command_CSay_f(void); +static void Command_Mute_f(void); static void Got_Saycmd(const UINT8 **p, INT32 playernum); void HU_LoadGraphics(void) @@ -260,6 +261,8 @@ void HU_Init(void) COM_AddCommand("csay", Command_CSay_f); RegisterNetXCmd(XD_SAY, Got_Saycmd); + COM_AddCommand("muteplayer", Command_Mute_f); + if (dedicated || rendermode == render_none) return; @@ -1022,21 +1025,42 @@ static boolean HU_clearChatSpaces(void) return nothingbutspaces; } -static void DoMute(const char *name) +static void DoMute(const char *name, boolean chat) { INT32 pnum = D_LookupPlayer(name); - if (pnum < 0) + // Shortcut to reuse this function for console and chat command +#define PRINT(msg, sound) do { \ + if (chat) \ + HU_AddChatText((msg), (sound)); \ + else \ + CONS_Printf("%s\n", msg); \ +} while (0) + + if (pnum < 0 || !playeringame[pnum]) { - HU_AddChatText("\x85""ERROR: \x80Player not found.", false); + PRINT("\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); + PRINT(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); + PRINT("Use same command to unmute them.", false); + +#undef PRINT +} + +static void Command_Mute_f(void) +{ + if (COM_Argc() < 2) + { + CONS_Printf(M_GetText("mute : mute/unmute a player\n")); + return; + } + + DoMute(COM_Argv(1), false); } static void HU_SendChatMessage(void) @@ -1070,7 +1094,7 @@ static void HU_SendChatMessage(void) if (msglength >= 5 && strnicmp(msg, "/mute", 5) == 0) // Used /mute { if (msglength > 6) - DoMute(msg+6); + DoMute(msg+6, true); else HU_AddChatText("\x82NOTICE: \x80Usage: /mute ", false); From f9a6702219d27a1f1421670b2510851b05398628 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 18 Jun 2026 17:28:27 +0300 Subject: [PATCH 30/30] Fix player node staying muted when player leaves --- src/d_clisrv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7113f6ca9..cabbc1227 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3497,6 +3497,9 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) while ((doomcom->numslots > 1) && !playeringame[doomcom->numslots-1]) doomcom->numslots--; + // Unmute slot if player was muted + player_muted[playernum] = false; + // Reset the name sprintf(player_names[playernum], "Player %d", playernum+1);