From d9e339cb5636b62b7a613805b305231010583250 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jun 2026 18:13:17 +0200 Subject: [PATCH 01/18] toggable sound effect for stair jank not the biggest fan of it but idk how to make this better on stairs with lots of steps so this will do for now --- src/g_game.h | 1 + src/k_kart.c | 3 ++- src/m_menudefs.c | 35 ++++++++++++++++++++++++----------- src/p_map.c | 8 ++++++-- src/r_main.cpp | 1 + 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index 4f46ef89d..6b2fae46d 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -119,6 +119,7 @@ extern consvar_t cv_gravstretch; extern consvar_t cv_sloperoll; extern consvar_t cv_sliptideroll; extern consvar_t cv_stairjank; +extern consvar_t cv_stairjanksfx; extern consvar_t cv_slamsound; extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; diff --git a/src/k_kart.c b/src/k_kart.c index eb58a7b62..027572458 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -67,7 +67,8 @@ static CV_PossibleValue_t sloperoll_cons_t[] = {{0, "Off"}, {1, "Players"}, {2, consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, sloperoll_cons_t, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_sparkroll = {"sparkroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_stairjank = {"stairjank", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_stairjank = {"stairjank", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_stairjanksfx = {"stairjanksfx", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //hardcode saltyhop mhhm static void saltyhop_onchange(void); diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 7eecdb0f6..72d3ab2f5 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1791,20 +1791,22 @@ static menuitem_t OP_PlayerDistortMenu[] = {IT_STRING | IT_CVAR, NULL, "Rotate Players when Sliptiding", &cv_sliptideroll, 25}, {IT_STRING | IT_CVAR, NULL, "Stair Janking Effect", &cv_stairjank, 30}, - {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 35}, - {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 40}, + {IT_STRING | IT_CVAR, NULL, "Stair Janking Sound Effect", &cv_stairjanksfx, 35}, // idk if that should be here but i dont care atm - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 50}, - {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 55}, + {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 40}, + {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 45}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 65}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 70}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 75}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 80}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 85}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 55}, + {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 60}, - {IT_STRING | IT_CVAR, NULL, "Squishdance", &cv_squishdance, 95}, - {IT_STRING | IT_CVAR, NULL, "Squishdance Speed", &cv_squishdancespeed, 101}, // why is this offset by 6? idk cant remember lulul + {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 70}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 75}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 80}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 85}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 90}, + + {IT_STRING | IT_CVAR, NULL, "Squishdance", &cv_squishdance, 100}, + {IT_STRING | IT_CVAR, NULL, "Squishdance Speed", &cv_squishdancespeed, 106}, // why is this offset by 6? idk cant remember lulul }; static const char* OP_PlayerDistortTooltips[] = @@ -1814,6 +1816,7 @@ static const char* OP_PlayerDistortTooltips[] = "Distance object rotation should be visable.", "Player rotation when sliptiding.", "Slightly tilt the player when driving over stairs or small bumps.", + "Sound effect when driving over stairs or small bumps.", "Rotation of a player's boost trails and drift sparks.", "Should banans rotate when thrown?\nAnd should they stay rotated when on the ground?", "Player squash and stretch.", @@ -1834,6 +1837,7 @@ enum slrotatedist, sliptide, stairjank, + stairjanksfx, sparkrotate, bananrotat, stretchyplayer, @@ -2742,6 +2746,15 @@ void PDistort_menu_Onchange(void) OP_PlayerDistortMenu[slrotatedist].status = IT_GRAYEDOUT; OP_PlayerDistortMenu[saltroll].status = IT_GRAYEDOUT; } + + if (cv_stairjank.value) + { + OP_PlayerDistortMenu[stairjanksfx].status = IT_STRING | IT_CVAR; + } + else + { + OP_PlayerDistortMenu[stairjanksfx].status = IT_GRAYEDOUT; + } } void Bird_menu_Onchange(void) diff --git a/src/p_map.c b/src/p_map.c index ef4997293..ed4698f1b 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2594,10 +2594,14 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) { /* use a shorter sound if not two tics have passed * since the last step */ - //S_ReducedVFXSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268), NULL); - //S_StartSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268)); + //S_ReducedVFXSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268), NULL); + //S_StartSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268)); // sound does not work out all that well for kart maps + // best i can do... + if (cv_stairjanksfx.value) + S_StartSoundAtVolume(thing, (thing->player->stairjank >= 8 ? sfx_s23b : sfx_s268), 192); // dont blast this at full volume lul + // TODO: maybe spawn smol dust effect similar to RR? /*if (!thing->player->stairjank) { diff --git a/src/r_main.cpp b/src/r_main.cpp index c4719e2e5..038fa8a6a 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1601,6 +1601,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_sloperolldist); CV_RegisterVar(&cv_sparkroll); CV_RegisterVar(&cv_stairjank); + CV_RegisterVar(&cv_stairjanksfx); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); From 2413a3503c6436b9233a47e0d10157f401ea534a Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 29 Jun 2026 20:44:30 +0300 Subject: [PATCH 02/18] Add stairjank particle effect using drift dust --- src/p_map.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index ed4698f1b..3206b5c81 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2603,15 +2603,33 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) S_StartSoundAtVolume(thing, (thing->player->stairjank >= 8 ? sfx_s23b : sfx_s268), 192); // dont blast this at full volume lul // TODO: maybe spawn smol dust effect similar to RR? - /*if (!thing->player->stairjank) + //if (!thing->player->stairjank) { - mobj_t * spark = P_SpawnMobjFromMobj(thing, 0, 0, 0, MT_JANKSPARK); - spark->fuse = 9; - spark->cusval = K_StairJankFlip(ANGLE_90); + // 90 degrees to direction you're facing + fixed_t dirx = -FINESINE(thing->angle>>ANGLETOFINESHIFT); + fixed_t diry = FINECOSINE(thing->angle>>ANGLETOFINESHIFT); + fixed_t offset = thing->radius; + + if (leveltime % 8 < 4) + { + dirx = -dirx; + diry = -diry; + } + + mobj_t * spark = P_SpawnMobj(thing->x + FixedMul(dirx, offset), thing->y + FixedMul(diry, offset), thing->z, MT_DRIFTDUST); + spark->momx = FixedMul(dirx, FRACUNIT) + (6 + ((int)leveltime % 5))*(thing->momx)/10; + spark->momy = FixedMul(diry, FRACUNIT) + (6 + ((int)leveltime % 5))*(thing->momy)/10; + spark->momz = 5*FRACUNIT; + spark->scale = mapobjectscale/5; + spark->destscale = mapobjectscale/2; + spark->islocal = true; + //spark->fuse = 9; + spark->color = SKINCOLOR_WHITE; + //spark->cusval = K_StairJankFlip(ANGLE_90); P_SetTarget(&spark->target, thing); - P_SetTarget(&spark->owner, thing); - spark->renderflags |= RF_REDUCEVFX; - }*/ + //P_SetTarget(&spark->owner, thing); + //spark->renderflags |= RF_REDUCEVFX; + } thing->player->stairjank = 9; //thing->player->stairjank = 17; From ec0615043278f1c8c883c7c159393714a83b1253 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 29 Jun 2026 20:45:45 +0300 Subject: [PATCH 03/18] This todo is done :3 --- src/p_map.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 3206b5c81..5b78d9a3d 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2602,7 +2602,6 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (cv_stairjanksfx.value) S_StartSoundAtVolume(thing, (thing->player->stairjank >= 8 ? sfx_s23b : sfx_s268), 192); // dont blast this at full volume lul - // TODO: maybe spawn smol dust effect similar to RR? //if (!thing->player->stairjank) { // 90 degrees to direction you're facing From e2a39927876cebe7b73fc5563ff1d097fbd48bb4 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jun 2026 22:01:54 +0200 Subject: [PATCH 04/18] make online hud / chat menu scrollable yes i checked green res.... it barely fits like this........ --- src/m_menudefs.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 72d3ab2f5..4da3c7ea7 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1408,25 +1408,25 @@ static menuitem_t OP_ChatOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Chat Mode", &cv_consolechat, 5}, // nonetheless... {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Chat Box Width", &cv_chatwidth, 20}, + NULL, "Chat Box Width", &cv_chatwidth, 10}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Chat Box Height", &cv_chatheight, 30}, - {IT_STRING | IT_CVAR, NULL, "Chat Horizontal Offset", &cv_chat_xoffset, 40}, - {IT_STRING | IT_CVAR, NULL, "Chat Vertical Offset", &cv_chat_yoffset, 50}, + NULL, "Chat Box Height", &cv_chatheight, 15}, + {IT_STRING | IT_CVAR, NULL, "Chat Horizontal Offset", &cv_chat_xoffset, 20}, + {IT_STRING | IT_CVAR, NULL, "Chat Vertical Offset", &cv_chat_yoffset, 25}, - {IT_STRING | IT_CVAR, NULL, "Center Text in Chat", &cv_chatcentertext, 70}, - {IT_STRING | IT_CVAR, NULL, "Chat Background Tint", &cv_chatbacktint, 80}, - {IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 90}, - {IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 100}, - {IT_STRING | IT_CVAR, NULL, "Max Chat Messages", &cv_chatlogsize, 110}, - {IT_STRING | IT_CVAR, NULL, "Display Character Limit", &cv_chat_showlimit, 120}, + {IT_STRING | IT_CVAR, NULL, "Center Text in Chat", &cv_chatcentertext, 35}, + {IT_STRING | IT_CVAR, NULL, "Chat Background Tint", &cv_chatbacktint, 40}, + {IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 45}, + {IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 50}, + {IT_STRING | IT_CVAR, NULL, "Max Chat Messages", &cv_chatlogsize, 55}, + {IT_STRING | IT_CVAR, NULL, "Display Character Limit", &cv_chat_showlimit, 60}, - {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 140}, // shows ping above the framerate if we want to. - {IT_STRING | IT_CVAR, NULL, "Ping display style", &cv_pingstyle, 150}, - {IT_STRING | IT_CVAR, NULL, "Ping measurement", &cv_pingmeasurement, 160}, - {IT_STRING | IT_CVAR, NULL, "Ping icon", &cv_pingicon, 170}, + {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 70}, // shows ping above the framerate if we want to. + {IT_STRING | IT_CVAR, NULL, "Ping display style", &cv_pingstyle, 75}, + {IT_STRING | IT_CVAR, NULL, "Ping measurement", &cv_pingmeasurement, 80}, + {IT_STRING | IT_CVAR, NULL, "Ping icon", &cv_pingicon, 85}, - {IT_STRING | IT_CVAR, NULL, "Show IP address in playerlist", &cv_shownodeip, 180}, + {IT_STRING | IT_CVAR, NULL, "Show IP address in playerlist", &cv_shownodeip, 90}, }; static const char* OP_ChatOptionsTooltips[] = @@ -2621,7 +2621,7 @@ menu_t OP_Player2CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player2CamOptionsMenu menu_t OP_Player3CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player3CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); menu_t OP_Player4CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player4CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); -menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 30, OP_ChatOptionsTooltips); +menu_t OP_ChatOptionsDef = DEFAULTSCROLLSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 25, OP_ChatOptionsTooltips); menu_t OP_SoundAdvancedDef = DEFAULTSCROLLSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30, OP_SoundAdvancedTooltips); From 4a06e8a6d172871bd2441b1588d765097d6da79c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 30 Jun 2026 18:36:56 +0200 Subject: [PATCH 05/18] fix map replacement checks for pwads added on startup stuff added per -file or whatever this incorrectly rechecked the iwads again instead of the pwads themselves, which let to the game flagging vanilla maps as replaced, setting the game to be modified --- src/d_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 85e1242ac..2150b1e72 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1353,20 +1353,24 @@ static void IdentifyVersion(void) // // search for maps // -static void D_CheckMapReplacements(boolean checkreplaced) +static void D_CheckMapReplacements(boolean pwad) { INT32 i; char *name; UINT16 wadnum; lumpinfo_t *lumpinfo; + size_t numfiles; - for (wadnum = 0; wadnum < mainwads; wadnum++) + wadnum = pwad ? (mainwads+1) : 0; + numfiles = pwad ? numwadfiles : mainwads; + + for (; wadnum < numfiles; wadnum++) { lumpinfo = wadfiles[wadnum]->lumpinfo; for (i = 0; i < wadfiles[wadnum]->numlumps; i++, lumpinfo++) { name = lumpinfo->name; - P_CheckMapReplacements(name, checkreplaced); + P_CheckMapReplacements(name, pwad); } } } From d638baeda60ea19c325d82e171bea3a9215eef1f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jul 2026 18:08:50 +0200 Subject: [PATCH 06/18] change mobj hook detection again so we can restore the actual correct behavior for the HurtMsg hook, which nothing even uses lol --- src/lua_hooklib.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 6294a5ab7..90d8ec367 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -65,6 +65,8 @@ static stringhook_t stringHooks[STRING_HOOK(MAX)]; bool hook_important = true; +#define NONMOHOOK ((mobjtype_t)-1) + // This will be indexed by hook id, the value of which fetches the registry. static int * hookRefs; static int nextid; @@ -296,7 +298,7 @@ struct Hook_State { INT32 status; /* return status to calling function */ void * userdata; int hook_type; - mobjtype_t mobj_type; /* < NUMMOBJTYPES if mobj hook */ + mobjtype_t mobj_type; /* != NONMOHOOK if mobj hook */ const char * string; /* used to fetch table, ran first if set */ int top; /* index of last argument passed to hook */ int id; /* id to fetch ref */ @@ -364,7 +366,7 @@ FUNCINLINE static ATTRINLINE boolean prepare_hook int hook_type ){ return init_hook_type(hook, default_status, - hook_type, NUMMOBJTYPES, NULL, + hook_type, NONMOHOOK, NULL, hookIds[hook_type].numHooks); } @@ -391,7 +393,7 @@ FUNCINLINE static ATTRINLINE boolean prepare_string_hook const char * string ){ if (init_hook_type(hook, default_status, - hook_type, NUMMOBJTYPES, string, + hook_type, NONMOHOOK, string, stringHooks[hook_type].ref)) { lua_pushstring(gL, string); @@ -407,7 +409,7 @@ FUNCINLINE static ATTRINLINE boolean prepare_hud_hook int hook_type ){ return init_hook_type(hook, 0, - hook_type, NUMMOBJTYPES, NULL, + hook_type, NONMOHOOK, NULL, hudHookIds[hook_type].numHooks); } @@ -547,11 +549,13 @@ static int call_hooks { calls += call_string_hooks(hook); } - else if (hook->mobj_type < NUMMOBJTYPES) + //else if (hook->mobj_type > 0) + else if (hook->mobj_type != NONMOHOOK) { /* call generic mobj hooks first */ calls += call_mobj_type_hooks(hook, MT_NULL); - calls += call_mobj_type_hooks(hook, hook->mobj_type); + if (hook->mobj_type < NUMMOBJTYPES) + calls += call_mobj_type_hooks(hook, hook->mobj_type); ps_lua_mobjhooks.value.i += calls; } else From a2184d2bef7c8d04d13e1ea013939e0b9664d0dd Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jul 2026 18:08:06 +0200 Subject: [PATCH 07/18] move cv_audbuffersize register this stuff kinda grouped some cvars together, makes more sense there --- src/d_netcmd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9d7d697cd..fd08830f0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -930,8 +930,6 @@ void D_RegisterClientCommands(void) COM_AddCommand("displayplayer", Command_Displayplayer_f); - CV_RegisterVar(&cv_audbuffersize); - CV_RegisterVar(&cv_palette); CV_RegisterVar(&cv_palettenum); @@ -1032,6 +1030,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_midimusicvolume); #endif CV_RegisterVar(&cv_numChannels); + CV_RegisterVar(&cv_audbuffersize); #ifdef HAVE_OPENMPT CV_RegisterVar(&cv_modfilter); From 551d7d4d89e070381b974d930b52aef0ca1084d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jul 2026 18:07:31 +0200 Subject: [PATCH 08/18] add V_DrawRightAlignedSmallStringAtFixed idk but might be useful --- src/v_video.c | 14 +++++++++++++- src/v_video.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/v_video.c b/src/v_video.c index 0f4540216..2ac659ba6 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2718,6 +2718,7 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st INT32 charflags = 0; const UINT8 *colormap = NULL; INT32 spacewidth = 2, charwidth = 0; + INT32 lowercase = (option & V_ALLOWLOWERCASE); option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE... @@ -2738,6 +2739,7 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st scrwidth *= vid.dup; charflags = (option & V_CHARCOLORMASK); + colormap = V_GetStringColormap(charflags); switch (option & V_SPACINGMASK) { @@ -2762,7 +2764,11 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st { // manually set flags override color codes if (!(option & V_CHARCOLORMASK)) + { charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; + colormap = V_GetStringColormap(charflags); + } + continue; } @@ -2806,7 +2812,6 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st continue; } - colormap = V_GetStringColormap(charflags); V_DrawFixedPatch(cx + (center< Date: Wed, 1 Jul 2026 19:21:32 +0200 Subject: [PATCH 09/18] print performance warning for lua scripts using mobj hooks without specific mobjtype thx indev for help <3 these may trash performance quite hard at times and are not visible from just perfstats most of the time --- src/lua_hooklib.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 90d8ec367..b380945ab 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -530,10 +530,48 @@ static int call_string_hooks(Hook_State *hook) return calls; } +FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) +{ + static UINT8 seen = 0; // so we dont have to check all this shit constantly + int numCalls = call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); + + if (!seen && numCalls > 0 && mobj_type == MT_NULL && ( + hook->hook_type == MOBJ_HOOK(MobjThinker ) + || hook->hook_type == MOBJ_HOOK(MobjCollide ) + || hook->hook_type == MOBJ_HOOK(MobjMoveCollide) + || hook->hook_type == MOBJ_HOOK(MobjFuse ) + || hook->hook_type == MOBJ_HOOK(MobjThinker ) + || hook->hook_type == MOBJ_HOOK(BossThinker ) + )) + { + seen = 1; + CONS_Alert( + CONS_WARNING, "%s\n", va( + "%s hooks not attached to a specific mobj type may cause performance issues!", + mobjHookNames[hook->hook_type]) + ); + + // print which script triggered it, ty indev <3 + for (int k = 0; k < mobjHookIds[mobj_type][hook->hook_type].numHooks; ++k) + { + lua_getref(gL, hookRefs[mobjHookIds[mobj_type][hook->hook_type].ids[k].id]); + + lua_Debug ar; + lua_getinfo(gL, ">S", &ar); + + CONS_Printf("%s:%d\n", ar.short_src, ar.linedefined); + } + } + + return numCalls; +} + +/* FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) { return call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); } +*/ static int call_hooks ( From 5775c12b162c06cf3de55c5d7731751cbe0e7f85 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 1 Jul 2026 23:22:56 +0300 Subject: [PATCH 10/18] Disable writing to replay query while replays are loading --- src/m_menu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index 38b5e2875..bc7c47c42 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4247,6 +4247,14 @@ static boolean M_HandleReplayHutQuery(INT32 choice) char tmp[MAXREPLAYQUERY+1]; memcpy(tmp, replayqueryinput_buffer, MAXREPLAYQUERY+1); + Lock_search_state(); + if (!replaynamesloaded) + { + Unlock_search_state(); + return false; + } + Unlock_search_state(); + if (M_TextInputHandle(&replayqueryinput, choice)) { S_StartSound(NULL, sfx_menu1); From 8b6ebfbad4bf69ca0d47494d3c38b0adfd17da28 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jul 2026 22:06:07 +0200 Subject: [PATCH 11/18] promote those null checks again..... sigh...... atleast this should be right this time --- src/w_wad.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 06af7a127..a8bdc0f9b 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2733,7 +2733,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) const char *name = (fileinfo + realentry)->name; I_Assert(name != NULL); - if (CHECKMAPMARKER(name)) + if (!name || CHECKMAPMARKER(name)) { numlumps--; // We skip map marker, so 1 of entries becomes empty continue; // This will skip i++ so we will write to same entry @@ -2764,7 +2764,8 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) const char *name = W_CheckNameForNum(lumppos); I_Assert(name != NULL); - if (CHECKMAPMARKER(name)) + // if no name then theres no lump + if (!name || CHECKMAPMARKER(name)) { break; } @@ -2781,7 +2782,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) const char *name = W_CheckNameForNum(lumpnum); I_Assert(name != NULL); - if (CHECKMAPMARKER(name)) + if (!name || CHECKMAPMARKER(name)) { --i; // Decrement so on next iteration we write on same i, so we don't leave corrupted vlumps entry numlumps--; // Just so we don't try to access the leftover vlumps entry From 7a309bc0b8eac61dccd047e7c3b5d08c4dff5d9b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jul 2026 22:45:17 +0200 Subject: [PATCH 12/18] make this less messy --- src/k_kart.c | 9 +++++---- src/p_map.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 027572458..461041aa8 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6243,11 +6243,12 @@ void K_KartUpdatePosition(player_t *player) if (G_RaceGametype()) { - if ((((players[i].starpostnum) + (numstarposts + 1) * players[i].laps) > - ((player->starpostnum) + (numstarposts + 1) * player->laps))) + const INT32 iplayerlaps = (players[i].starpostnum + (numstarposts + 1) * players[i].laps); + const INT32 pplayerlaps = (player->starpostnum + (numstarposts + 1) * player->laps); + + if (iplayerlaps > pplayerlaps) position++; - else if (((players[i].starpostnum) + (numstarposts+1)*players[i].laps) == - ((player->starpostnum) + (numstarposts+1)*player->laps)) + else if (iplayerlaps == pplayerlaps) { ppcd = pncd = ipcd = incd = 0; diff --git a/src/p_map.c b/src/p_map.c index 5b78d9a3d..51e9af656 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2684,7 +2684,7 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y) if (tmfloorz - thing->z > maxstep) return false; // too big a step up } - } while(tryx != x || tryy != y); + } while (tryx != x || tryy != y); // the move is ok, // so link the thing into its new position From e445669521b8be4a66855e3a7d0df16805c511b1 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 18:17:42 +0200 Subject: [PATCH 13/18] cleanup stuff a bit for unused gametypes wish could just remove all of this but gotta keep it for compat reasons ig --- src/d_clisrv.c | 2 +- src/g_demo.c | 4 ++-- src/g_game.h | 7 +++--- src/m_cheat.c | 6 ++--- src/p_enemy.c | 11 +++++---- src/p_inter.c | 26 ++++++++++---------- src/p_local.h | 8 +++++-- src/p_map.c | 35 +++++++++++++++++---------- src/p_mobj.c | 64 ++++++++++++++++++++++++-------------------------- src/p_spec.c | 6 ++--- src/p_user.c | 28 +++++++++++----------- 11 files changed, 106 insertions(+), 91 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8cb038251..8efc2a1cd 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3449,7 +3449,7 @@ void CL_ClearPlayer(INT32 playernum) if (players[playernum].mo) { // Don't leave a NiGHTS ghost! - if (UNLIKELY((players[playernum].pflags & PF_NIGHTSMODE) && players[playernum].mo->tracer)) + if (nightsplayer(&players[playernum]) && players[playernum].mo->tracer) P_RemoveMobj(players[playernum].mo->tracer); P_RemoveMobj(players[playernum].mo); } diff --git a/src/g_demo.c b/src/g_demo.c index 1123aed69..17ed25d85 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -716,7 +716,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) if (!(demoflags & DF_GHOST)) return; // No ghost data to write. - if (ghost->player && ghost->player->pflags & PF_NIGHTSMODE && ghost->tracer) + if (ghost->player && nightsplayer(ghost->player) && ghost->tracer) { // We're talking about the NiGHTS thing, not the normal platforming thing! ziptic |= GZT_NIGHTS; @@ -979,7 +979,7 @@ void G_ConsGhostTic(INT32 playernum) if (ziptic & GZT_NIGHTS) { - if (!testmo || !testmo->player || !(testmo->player->pflags & PF_NIGHTSMODE) || !testmo->tracer) + if (!testmo || !testmo->player || !nightsplayer(testmo->player) || !testmo->tracer) nightsfail = true; else testmo = testmo->tracer; diff --git a/src/g_game.h b/src/g_game.h index 6b2fae46d..038bc68df 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -228,10 +228,11 @@ void G_SaveGameData(boolean force); void G_SaveGame(UINT32 slot); -#define G_GametypeHasTeams() (G_IsGameType(GT_TEAMMATCH) || G_IsGameType(GT_CTF)) +#define G_RaceGametype() (G_IsGameType(GT_RACE)) #define G_BattleGametype() (G_IsGameType(GT_MATCH)) -#define G_RaceGametype() (G_IsGameType(GT_RACE)) -#define G_TagGametype() (G_IsGameType(GT_TAG) || G_IsGameType(GT_HIDEANDSEEK)) + +#define G_GametypeHasTeams() (UNLIKELY(G_IsGameType(GT_TEAMMATCH) || G_IsGameType(GT_CTF))) +#define G_TagGametype() (UNLIKELY(G_IsGameType(GT_TAG) || G_IsGameType(GT_HIDEANDSEEK))) FUNCINLINE static ATTRINLINE boolean G_IsGameType(int type) { diff --git a/src/m_cheat.c b/src/m_cheat.c index 783ff3bcb..0360ecc56 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -766,7 +766,7 @@ boolean OP_FreezeObjectplace(void) if (!objectplacing) return false; - if ((maptol & TOL_NIGHTS) && (players[consoleplayer].pflags & PF_NIGHTSMODE)) + if (nightsmode && nightsplayer(&players[consoleplayer])) return false; return true; @@ -1049,7 +1049,7 @@ void Command_ObjectPlace_f(void) { objectplacing = true; - if ((players[0].pflags & PF_NIGHTSMODE)) + if (nightsplayer(&players[0])) return; if (!COM_CheckParm("-silent")) @@ -1120,7 +1120,7 @@ void Command_ObjectPlace_f(void) // Don't touch the NiGHTS Objectplace stuff. // ... or if the mo mysteriously vanished. - if (!players[0].mo || (players[0].pflags & PF_NIGHTSMODE)) + if (!players[0].mo || nightsplayer(&players[0])) return; // If still in dummy state, get out of it. diff --git a/src/p_enemy.c b/src/p_enemy.c index 1502f5ff3..f3fb1761c 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -250,7 +250,8 @@ boolean P_Move(mobj_t *actor, fixed_t speed) I_Assert(movedir < NUMDIRS); tryx = actor->x + FixedMul(speed*xspeed[movedir], actor->scale); - if (UNLIKELY(twodlevel || actor->flags2 & MF2_TWOD)) + + if (twodmo(actor)) tryy = actor->y; else tryy = actor->y + FixedMul(speed*yspeed[movedir], actor->scale); @@ -328,7 +329,7 @@ void P_NewChaseDir(mobj_t *actor) else d[1] = DI_NODIR; - if (UNLIKELY(twodlevel || actor->flags2 & MF2_TWOD)) + if (twodmo(actor)) d[2] = DI_NODIR; if (deltay < -FixedMul(10*FRACUNIT, actor->scale)) d[2] = DI_SOUTH; @@ -2762,10 +2763,10 @@ void A_Invincibility(void *thing) { S_StopMusic(); - if (UNLIKELY(mariomode)) + if (mariomode) G_GhostAddColor((INT32) (player - players), GHC_INVINCIBLE); - S_ChangeMusicInternal((UNLIKELY(mariomode)) ? "minvnc" : "invinc", false); + S_ChangeMusicInternal(mariomode ? "minvnc" : "invinc", false); } } @@ -4359,7 +4360,7 @@ void A_MouseThink(void *thing) || (actor->eflags & MFE_VERTICALFLIP && actor->z + actor->height == actor->ceilingz)) && !actor->reactiontime) { - if (UNLIKELY(twodlevel || actor->flags2 & MF2_TWOD)) + if (twodmo(actor)) { if (P_RandomChance(FRACUNIT/2)) actor->angle += ANGLE_180; diff --git a/src/p_inter.c b/src/p_inter.c index a2948d01b..7f533859e 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -589,7 +589,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) special->momx = special->momy = special->momz = 0; P_GivePlayerRings(player, 1); - if (UNLIKELY((maptol & TOL_NIGHTS) && special->type != MT_FLINGRING)) + if (nightsmode && special->type != MT_FLINGRING) P_DoNightsScore(player); break; @@ -601,7 +601,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) special->momx = special->momy = 0; P_GivePlayerRings(player, 1); - if (UNLIKELY((maptol & TOL_NIGHTS) && special->type != MT_FLINGCOIN)) + if (nightsmode && special->type != MT_FLINGCOIN) P_DoNightsScore(player); break; case MT_BLUEBALL: @@ -617,7 +617,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) else special->scalespeed = 4*FRACUNIT/5; - if (UNLIKELY(maptol & TOL_NIGHTS)) + if (nightsmode) P_DoNightsScore(player); break; case MT_AUTOPICKUP: @@ -831,7 +831,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { S_StartSound(toucher, special->info->seesound); - if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(player)) { player->bumpertime = TICRATE/2; if (special->threshold > 0) @@ -1131,7 +1131,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) S_StartSound(toucher, special->info->painsound); return; } - else if (UNLIKELY((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) + else if ((nightsplayer(player) && (player->pflags & PF_DRILLING)) || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? { // Shatter the shield! @@ -2360,11 +2360,11 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (player->exiting) return false; - if (UNLIKELY(!(target->player->pflags & (PF_NIGHTSMODE|PF_NIGHTSFALL)) && (maptol & TOL_NIGHTS))) + if (UNLIKELY(!(target->player->pflags & (PF_NIGHTSMODE|PF_NIGHTSFALL)) && nightsmode)) return false; } - if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) // NiGHTS damage handling + if (nightsplayer(player)) // NiGHTS damage handling { if (!force) { @@ -2609,7 +2609,7 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) ns = FixedMul(((i*FRACUNIT)/16)+2*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) mo->momy = FixedMul(FINESINE(fa),ns); P_SetObjectMomZ(mo, 8*FRACUNIT, false); @@ -2633,7 +2633,7 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) ns = FixedMul(momxy, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) mo->momy = FixedMul(FINESINE(fa),ns); ns = momz; @@ -2740,7 +2740,7 @@ void P_PlayerWeaponPanelBurst(player_t *player) ns = FixedMul(3*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) mo->momy = FixedMul(FINESINE(fa),ns); P_SetObjectMomZ(mo, 4*FRACUNIT, false); @@ -2824,7 +2824,7 @@ void P_PlayerWeaponAmmoBurst(player_t *player) ns = FixedMul(2*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa), ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) mo->momy = FixedMul(FINESINE(fa),ns); P_SetObjectMomZ(mo, 3*FRACUNIT, false); @@ -2940,7 +2940,7 @@ void P_PlayerEmeraldBurst(player_t *player, boolean toss) momx = FixedMul(FINECOSINE(fa), ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) momy = FixedMul(FINESINE(fa),ns); else momy = 0; @@ -2997,7 +2997,7 @@ void P_PlayerFlagBurst(player_t *player, boolean toss) { angle_t fa = P_RandomByte()*FINEANGLES/256; flag->momx = FixedMul(FINECOSINE(fa), FixedMul(6*FRACUNIT, player->mo->scale)); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) flag->momy = FixedMul(FINESINE(fa), FixedMul(6*FRACUNIT, player->mo->scale)); } diff --git a/src/p_local.h b/src/p_local.h index 383469bcc..142e896da 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -59,8 +59,12 @@ extern "C" { #define AIMINGTOSLOPE(aiming) FINESINE((aiming>>ANGLETOFINESHIFT) & FINEMASK) -#define mariomode (maptol & TOL_MARIO) -#define twodlevel (maptol & TOL_2D) +// unused modes, kept for compat +#define nightsmode (UNLIKELY(maptol & TOL_NIGHTS)) +#define nightsplayer(player) (UNLIKELY((player)->pflags & PF_NIGHTSMODE)) +#define mariomode (UNLIKELY(maptol & TOL_MARIO)) +#define twodlevel (UNLIKELY(maptol & TOL_2D)) +#define twodmo(mobj) (UNLIKELY(twodlevel || ((mobj)->flags2 & MF2_TWOD))) // // P_TICK diff --git a/src/p_map.c b/src/p_map.c index 51e9af656..82dba1274 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -136,14 +136,17 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (object->eflags & MFE_SPRUNG) // Object was already sprung this tic return false; - // Spectators don't trigger springs. - if (object->player && object->player->spectator) - return false; - - if (UNLIKELY(object->player && (object->player->pflags & PF_NIGHTSMODE))) + if (object->player) { - /*Someone want to make these work like bumpers?*/ - return false; + // Spectators don't trigger springs. + if (object->player->spectator) + return false; + + if (nightsplayer(object->player)) + { + /*Someone want to make these work like bumpers?*/ + return false; + } } object->standingslope = NULL; // Okay, now we can't return - no launching off at silly angles for you. @@ -160,10 +163,15 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (spring->eflags & MFE_VERTICALFLIP) vertispeed *= -1; + // Vertical springs teleport you on TOP of them. if (vertispeed > 0) + { object->z = spring->z + spring->height + 1; + } else if (vertispeed < 0) + { object->z = spring->z - object->height - 1; + } else { // Horizontal springs teleport you in FRONT of them. @@ -215,7 +223,9 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (object->player) { if (spring->flags & MF_ENEMY) // Spring shells + { P_SetTarget(&spring->target, object); + } if (horizspeed && object->player->cmd.forwardmove == 0 && object->player->cmd.sidemove == 0) { @@ -350,12 +360,13 @@ static boolean PIT_CheckThing(mobj_t *thing) } #endif - if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE)) || (thing->flags & MF_NOCLIPTHING)) + if ((thing->flags & MF_NOCLIPTHING) || !(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE))) return true; // Don't collide with your buddies while NiGHTS-flying. - if (UNLIKELY(tmthing->player && thing->player && (maptol & TOL_NIGHTS) - && ((tmthing->player->pflags & PF_NIGHTSMODE) || (thing->player->pflags & PF_NIGHTSMODE)))) + if (nightsmode && + tmthing->player && thing->player && + (nightsplayer(tmthing->player) || nightsplayer(thing->player))) return true; blockdist = thing->radius + tmthing->radius; @@ -3294,7 +3305,7 @@ stairstep: if (bestslideline != NULL) P_HitSlideLine(bestslideline); // clip the moves - if (UNLIKELY((twodlevel || (mo->flags2 & MF2_TWOD)) && mo->player)) + if (twodmo(mo) && mo->player) { mo->momx = tmxmove; tmymove = 0; @@ -4200,7 +4211,7 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) * Must clear tmthing at tic end, as it might contain a pointer to a removed thinker, or the level might have ended/been ended and we clear the objects it was pointing too. Hopefully we don't need to carry this between tics for sync. */ void P_MapStart(void) { - if (UNLIKELY(tmthing)) + if (tmthing) I_Error("P_MapStart: tmthing set!"); } diff --git a/src/p_mobj.c b/src/p_mobj.c index 49916eb50..007f3d108 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -172,7 +172,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) do { - if (UNLIKELY(state == S_NULL)) + if (state == S_NULL) { // Bad SOC! CONS_Alert(CONS_ERROR, "Cannot remove player mobj by setting its state to S_NULL.\n"); //P_RemoveMobj(mobj); @@ -905,7 +905,7 @@ static void P_PlayerFlip(mobj_t *mo) G_GhostAddFlip((INT32) (mo->player - players)); // Flip aiming to match! - if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) // NiGHTS doesn't use flipcam + if (nightsplayer(mo->player)) // NiGHTS doesn't use flipcam { if (mo->tracer) mo->tracer->eflags ^= MFE_VERTICALFLIP; @@ -998,7 +998,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (mo->player) { - if (UNLIKELY(mo->player->climbing || (mo->player->pflags & PF_NIGHTSMODE))) + if (UNLIKELY(mo->player->climbing || nightsplayer(mo->player))) return 0; if (!(mo->flags2 & MF2_OBJECTFLIP) != !(mo->player->powers[pw_gravityboots])) // negated to turn numeric into bool - would be double negated, but not needed if both would be @@ -1177,7 +1177,7 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) } else if (abs(player->rmomx) < mo->scale && abs(player->rmomy) < mo->scale - && (!(player->cmd.forwardmove && !(twodlevel || mo->flags2 & MF2_TWOD)) && !player->cmd.sidemove && !(player->pflags & PF_SPINNING)) + && (!(player->cmd.forwardmove && !twodmo(mo)) && !player->cmd.sidemove && !(player->pflags & PF_SPINNING)) && !(player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && (abs(player->mo->standingslope->zdelta) >= FRACUNIT/2)) ) { @@ -1619,7 +1619,7 @@ void P_XYMovement(mobj_t *mo) // Check the gravity status. P_CheckGravity(mo, false); - if (UNLIKELY(player && !moved && player->pflags & PF_NIGHTSMODE && mo->target)) + if (player && !moved && nightsplayer(player) && mo->target) { angle_t fa; @@ -1669,11 +1669,14 @@ void P_XYMovement(mobj_t *mo) if (mo->flags & MF_MISSILE || mo->flags2 & MF2_SKULLFLY || mo->type == MT_SHELL || mo->type == MT_VULTURE) return; // no friction for missiles ever - if (player && player->homing) // no friction for homing - return; + if (player) + { + if (player->homing) // no friction for homing + return; - if (UNLIKELY(player && player->pflags & PF_NIGHTSMODE)) - return; // no friction for NiGHTS players + if (nightsplayer(player)) + return; // no friction for NiGHTS players + } if ((mo->type == MT_BIGTUMBLEWEED || mo->type == MT_LITTLETUMBLEWEED) && (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8)) // Special exception for tumbleweeds on slopes @@ -2221,7 +2224,7 @@ static boolean P_ZMovement(mobj_t *mo) || mo->type == MT_CANNONBALLDECOR || mo->type == MT_FALLINGROCK) { - if (UNLIKELY(maptol & TOL_NIGHTS)) + if (nightsmode) mom.z = -FixedDiv(mom.z, 10*FRACUNIT); else mom.z = -FixedMul(mom.z, FixedDiv(17*FRACUNIT,20*FRACUNIT)); @@ -2359,11 +2362,9 @@ static boolean P_ZMovement(mobj_t *mo) { if (mo->flags2 & MF2_SKULLFLY) // the skull slammed into something mo->momz = -mo->momz; - else - // Flags bounce - if (UNLIKELY(mo->type == MT_REDFLAG || mo->type == MT_BLUEFLAG)) + else if (UNLIKELY(mo->type == MT_REDFLAG || mo->type == MT_BLUEFLAG)) // Flags bounce { - if (UNLIKELY(maptol & TOL_NIGHTS)) + if (nightsmode) mo->momz = -FixedDiv(mo->momz, 10*FRACUNIT); else mo->momz = -FixedMul(mo->momz, FixedDiv(17*FRACUNIT,20*FRACUNIT)); @@ -2429,7 +2430,7 @@ static void P_PlayerZMovement(mobj_t *mo) else mo->z = mo->floorz; - if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(mo->player)) { // bounce off floor if you were flying towards it if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 0 && mo->player->flyangle < 180) @@ -2620,7 +2621,7 @@ nightsdone: else mo->z = mo->ceilingz - mo->height; - if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(mo->player)) { // bounce off ceiling if you were flying towards it if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 180 && mo->player->flyangle <= 359) @@ -2665,7 +2666,7 @@ nightsdone: } // hit the ceiling - if (UNLIKELY(mariomode)) + if (mariomode) S_StartSound(mo, sfx_mario1); if (!mo->player->climbing) @@ -3223,7 +3224,7 @@ void P_CalcChasePostImg(player_t *player, camera_t *thiscam) player_flipcam = cv_flipcam[pnum].value; } - const boolean flipcam = (player_flipcam && player->mo->eflags & MFE_VERTICALFLIP && LIKELY(!(player->pflags & PF_NIGHTSMODE))); + const boolean flipcam = (player_flipcam && player->mo->eflags & MFE_VERTICALFLIP && !nightsplayer(player)); UINT8 postimgtype = 0; if (encoremode) @@ -3406,7 +3407,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) P_CheckPosition(mobj, mobj->x, mobj->y); goto animonly; } - else if (UNLIKELY(mobj->player->pflags & PF_MACESPIN)) + else if (mobj->player->pflags & PF_MACESPIN) { P_CheckPosition(mobj, mobj->x, mobj->y); goto animonly; @@ -3520,7 +3521,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) } else { - if (LIKELY(!(mobj->player->pflags & PF_NIGHTSMODE))) // "jumping" is used for drilling + if (!nightsplayer(mobj->player)) // "jumping" is used for drilling mobj->player->jumping = 0; mobj->player->pflags &= ~PF_JUMPED; @@ -8552,7 +8553,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (mobj->tracer && mobj->tracer->player) { - if (LIKELY(!(mobj->tracer->player->pflags & PF_NIGHTSMODE))) + if (!nightsplayer(mobj->tracer->player)) { mobj->flags &= ~MF_NOGRAVITY; mobj->flags2 &= ~MF2_DONTDRAW; @@ -8576,7 +8577,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_SetTarget(&mobj->target, NULL); } - if (UNLIKELY(mobj->tracer->player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(mobj->tracer->player)) { if (mobj->tracer->player->bonustime) { @@ -9078,7 +9079,7 @@ void P_MobjThinker(mobj_t *mobj) const sector_t *sec1 = mobj->subsector ? mobj->subsector->sector : NULL; // 970 allows ANY mobj to trigger a linedef exec - if (UNLIKELY(!mobj->islocal && sec1 && GETSECSPECIAL(sec1->special, 2) == 8)) // BEWARE: islocal does not exist in vanilla + if (!mobj->islocal && sec1 && GETSECSPECIAL(sec1->special, 2) == 8) // BEWARE: islocal does not exist in vanilla { sector_t *sec2; sec2 = P_ThingOnSpecial3DFloor(mobj); @@ -9144,7 +9145,7 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->flags2 & MF2_FIRING && mobj->target && mobj->health > 0) P_FiringThink(mobj); - if (UNLIKELY(mobj->flags & MF_AMBIENT)) + if (mobj->flags & MF_AMBIENT) { if (leveltime % mobj->health) return; @@ -9208,8 +9209,8 @@ void P_MobjThinker(mobj_t *mobj) P_ButteredSlope(mobj); } - if (UNLIKELY(mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health - && P_CheckDeathPitCollide(mobj))) // extra pit check in case these didn't have momz + if (mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health + && P_CheckDeathPitCollide(mobj)) // extra pit check in case these didn't have momz { P_KillMobj(mobj, NULL, NULL); return; @@ -9218,10 +9219,7 @@ void P_MobjThinker(mobj_t *mobj) // Crush enemies! if (mobj->ceilingz - mobj->floorz < mobj->height) { - if (UNLIKELY(( - (mobj->flags & (MF_ENEMY|MF_BOSS) - && mobj->flags & MF_SHOOTABLE) - || mobj->type == MT_EGGSHIELD)) + if (((mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->flags & MF_SHOOTABLE) || mobj->type == MT_EGGSHIELD) && !(mobj->flags & MF_NOCLIPHEIGHT) && mobj->health > 0) { @@ -9243,7 +9241,7 @@ void P_MobjThinker(mobj_t *mobj) if (P_MobjWasRemoved(mobj)) return; - if (UNLIKELY(P_WeaponOrPanel(mobj->type))) + if (P_WeaponOrPanel(mobj->type)) { if (mobj->health == 0) // Fading tile { @@ -10131,14 +10129,14 @@ void P_RemoveMobj(mobj_t *mobj) } } // Rings only, please! - else if (UNLIKELY(mobj->spawnpoint && + else if (mobj->spawnpoint && !(mobj->flags2 & MF2_DONTRESPAWN) && (mobj->type == MT_RING || mobj->type == MT_COIN || mobj->type == MT_BLUEBALL || mobj->type == MT_REDTEAMRING || mobj->type == MT_BLUETEAMRING - || P_WeaponOrPanel(mobj->type)))) + || P_WeaponOrPanel(mobj->type))) { itemrespawnque[iquehead] = mobj->spawnpoint; itemrespawntime[iquehead] = leveltime; diff --git a/src/p_spec.c b/src/p_spec.c index 9aff26b3c..35efaa857 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3880,7 +3880,7 @@ DoneSection2: player->kartstuff[k_lapanimation] = 80; - if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(player)) player->drillmeter += 48*20; if (netgame && player->laps >= (UINT8)cv_numlaps.value) @@ -7126,7 +7126,7 @@ static inline boolean PIT_PushThing(mobj_t *thing) return false; // Allow this to affect pushable objects at some point? - if (thing->player && (!(thing->flags & (MF_NOGRAVITY | MF_NOCLIP)) || UNLIKELY(thing->player->pflags & PF_NIGHTSMODE))) + if (thing->player && (!(thing->flags & (MF_NOGRAVITY | MF_NOCLIP)) || nightsplayer(thing->player))) { INT32 dist; INT32 speed; @@ -7156,7 +7156,7 @@ static inline boolean PIT_PushThing(mobj_t *thing) // Written with bits and pieces of P_HomingAttack if ((speed > 0) && (P_CheckSight(thing, tmpusher->source))) { - if (LIKELY(!(thing->player->pflags & PF_NIGHTSMODE))) + if (!nightsplayer(thing->player)) { // only push wrt Z if health & 1 (mapthing has ambush flag) if (tmpusher->source->health & 1) diff --git a/src/p_user.c b/src/p_user.c index 90bca6cff..8480b0e60 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -74,7 +74,7 @@ void P_Thrust(mobj_t *mo, angle_t angle, fixed_t move) mo->momx += FixedMul(move, FINECOSINE(angle)); - if (LIKELY(!(twodlevel || (mo->flags2 & MF2_TWOD)))) + if (!twodmo(mo)) mo->momy += FixedMul(move, FINESINE(angle)); } @@ -90,7 +90,7 @@ void P_InstaThrust(mobj_t *mo, angle_t angle, fixed_t move) mo->momx = FixedMul(move, FINECOSINE(angle)); - if (LIKELY(!(twodlevel || (mo->flags2 & MF2_TWOD)))) + if (!twodmo(mo)) mo->momy = FixedMul(move,FINESINE(angle)); } @@ -475,7 +475,7 @@ void P_PlayLivesJingle(player_t *player) if (UNLIKELY(use1upSound)) S_StartSound(NULL, sfx_oneup); - else if (UNLIKELY(mariomode)) + else if (mariomode) S_StartSound(NULL, sfx_marioa); else { @@ -503,7 +503,7 @@ void P_PlayRinglossSound(mobj_t *source, mobj_t *damager) S_StartSound(NULL, sfx); } else - S_StartSound(source, UNLIKELY(mariomode) ? sfx_mario8 : sfx_khurt1 + key); + S_StartSound(source, mariomode ? sfx_mario8 : sfx_khurt1 + key); } else S_StartSound(source, sfx_slip); @@ -1725,7 +1725,7 @@ static void P_DoBubbleBreath(player_t *player) else zh = player->mo->z + FixedDiv(player->mo->height,5*(FRACUNIT/4)); - if (!(player->mo->eflags & MFE_UNDERWATER) || player->spectator || ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL && !(player->pflags & PF_NIGHTSMODE))) + if (!(player->mo->eflags & MFE_UNDERWATER) || player->spectator || ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL && !nightsplayer(player))) return; if (P_RandomChance(FRACUNIT/16)) @@ -2298,7 +2298,7 @@ static void P_MovePlayer(player_t *player) P_3dMovement(player); } - if (UNLIKELY(maptol & TOL_2D)) // psure this doesent even work at all + if (twodlevel) // psure this doesent even work at all runspd = FixedMul(runspd, 2*FRACUNIT/3); ///////////////////////// @@ -2748,8 +2748,8 @@ boolean P_LookForEnemies(player_t *player) if (modist > FixedMul(RING_DIST, player->mo->scale)) continue; // out of range - if (UNLIKELY((twodlevel || player->mo->flags2 & MF2_TWOD) - && abs(player->mo->y-mo->y) > player->mo->radius)) + + if (twodmo(player->mo) && abs(player->mo->y-mo->y) > player->mo->radius) continue; // not in your 2d plane if (closestmo && modist > P_AproxDistance(P_AproxDistance(player->mo->x-closestmo->x, @@ -3508,7 +3508,7 @@ static boolean P_CheckNoclipCameraPosition(player_t *player, camera_t *thiscam, boolean cameranoclip; mobj_t *mo = player->mo; - cameranoclip = ((player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) + cameranoclip = (nightsplayer(player) || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)) // Noclipping player camera noclips too!! || (leveltime < introtime)); // Kart intro cam @@ -4097,7 +4097,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall angle -= (angle - thiscam->pitch)/2; } - if (player->playerstate != PST_DEAD && LIKELY(!((player->pflags & PF_NIGHTSMODE) && player->exiting))) + if (player->playerstate != PST_DEAD && !(nightsplayer(player) && player->exiting)) angle += (focusaiming < ANGLE_180 ? focusaiming/2 : InvAngle(InvAngle(focusaiming)/2)); // overcomplicated version of '((signed)focusaiming)/2;' if (!camstill && !timeover) // Keep the view still... @@ -4174,7 +4174,7 @@ boolean P_SpectatorJoinGame(player_t *player) // Team changing in Team Match and CTF // Pressing fire assigns you to a team that needs players if allowed. // Partial code reproduction from p_tick.c autobalance code. - else if (UNLIKELY(G_GametypeHasTeams())) + else if (G_GametypeHasTeams()) { INT32 changeto = 0; INT32 z, numplayersred = 0, numplayersblue = 0; @@ -4871,7 +4871,7 @@ void P_PlayerThink(player_t *player) // Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot. if (UNLIKELY(!objectplacing && !((netgame || multiplayer) && player->spectator) - && maptol & TOL_NIGHTS && (!(player->pflags & PF_NIGHTSMODE) || player->powers[pw_nights_helper]))) + && nightsmode && (!nightsplayer(player) || player->powers[pw_nights_helper]))) { thinker_t *th; mobj_t *mo2; @@ -4973,7 +4973,7 @@ void P_PlayerThink(player_t *player) #endif // check for use - if (LIKELY(!(player->pflags & PF_NIGHTSMODE))) + if (!nightsplayer(player)) { if (cmd->buttons & BT_BRAKE) player->pflags |= PF_USEDOWN; @@ -5164,7 +5164,7 @@ void P_PlayerAfterThink(player_t *player) } } - if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(player)) { player->powers[pw_gravityboots] = 0; } From 56c2178bde9374d119747c1dc7c3f5a6f4f0b073 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 18:34:19 +0200 Subject: [PATCH 14/18] cleanup COMPAT_VANILLA mobj checks move stuff into a helper func, which just returns if mo != NULL in vanilla compat mode, otherwise returns P_MobjWasRemoved reasoning for this crap is in the comment above said helper --- src/k_kart.c | 20 ++++++-------------- src/p_inter.c | 20 ++++---------------- src/p_local.h | 11 +++++++++++ src/p_map.c | 17 ++++++++++------- src/p_mobj.c | 44 ++++++++++---------------------------------- 5 files changed, 41 insertions(+), 71 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 461041aa8..d7759a3f7 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4725,11 +4725,7 @@ void K_RepairOrbitChain(mobj_t *orbit) } // Then recount to make sure item amount is correct -#ifndef COMPAT_VANILLA - if (!P_MobjWasRemoved(orbit->target) && orbit->target->player) -#else - if (orbit->target && orbit->target->player) -#endif + if (!P_MobjWasRemovedCompat(orbit->target) && orbit->target->player) { INT32 num = 0; @@ -4746,11 +4742,7 @@ void K_RepairOrbitChain(mobj_t *orbit) prev->movedir = num; } -#ifndef COMPAT_VANILLA - if (!P_MobjWasRemoved(orbit->target)) -#else - if (orbit->target) -#endif + if (!P_MobjWasRemovedCompat(orbit->target)) orbit->target->player->kartstuff[k_itemamount] = num; } } @@ -4897,7 +4889,7 @@ static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z // Move the hnext chain! static void K_MoveHeldObjects(player_t *player) { - if (!player->mo) + if (P_MobjWasRemovedCompat(player->mo)) return; if (!player->mo->hnext) @@ -6600,7 +6592,7 @@ static void K_PlayerItemThink(player_t *player, boolean onground, boolean oldatt { mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_BANANA_SHIELD); - if (!mo) + if (P_MobjWasRemovedCompat(mo)) { player->kartstuff[k_itemamount] = moloop; break; @@ -6661,7 +6653,7 @@ static void K_PlayerItemThink(player_t *player, boolean onground, boolean oldatt newangle = (player->mo->angle + ANGLE_157h) + FixedAngle(((360 / player->kartstuff[k_itemamount]) * moloop) << FRACBITS) + ANGLE_90; mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_ORBINAUT_SHIELD); - if (!mo) + if (P_MobjWasRemovedCompat(mo)) { player->kartstuff[k_itemamount] = moloop; break; @@ -6704,7 +6696,7 @@ static void K_PlayerItemThink(player_t *player, boolean onground, boolean oldatt newangle = (player->mo->angle + ANGLE_157h) + FixedAngle(((360 / player->kartstuff[k_itemamount]) * moloop) << FRACBITS) + ANGLE_90; mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_JAWZ_SHIELD); - if (!mo) + if (P_MobjWasRemovedCompat(mo)) { player->kartstuff[k_itemamount] = moloop; break; diff --git a/src/p_inter.c b/src/p_inter.c index 7f533859e..856050959 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1466,11 +1466,7 @@ static void P_UpdateRemovedOrbital(mobj_t *target, mobj_t *inflictor, mobj_t *so { // SRB2kart // I wish I knew a better way to do this -#ifndef COMPAT_VANILLA - if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) -#else - if (target->target && target->target->player && target->target->player->mo) -#endif + if (!P_MobjWasRemovedCompat(target->target) && target->target->player && !P_MobjWasRemovedCompat(target->target->player->mo)) { if (target->target->player->kartstuff[k_eggmanheld] && target->type == MT_EGGMANITEM_SHIELD) target->target->player->kartstuff[k_eggmanheld] = 0; @@ -1483,11 +1479,7 @@ static void P_UpdateRemovedOrbital(mobj_t *target, mobj_t *inflictor, mobj_t *so { if (target->movedir != 0 && target->movedir < (UINT16)target->target->player->kartstuff[k_itemamount]) { -#ifndef COMPAT_VANILLA - if (!P_MobjWasRemoved(target->target->hnext)) -#else - if (target->target->hnext) -#endif + if (!P_MobjWasRemovedCompat(target->target->hnext)) K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; @@ -2245,11 +2237,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; // well no clue but this may happen ig -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(target)) -#else - if (!target) -#endif + if (P_MobjWasRemovedCompat(target)) return false; if (target->health <= 0) @@ -2266,7 +2254,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; } - if (source && source->player && source->player->spectator) + if (!P_MobjWasRemovedCompat(source) && source->player && source->player->spectator) return false; } diff --git a/src/p_local.h b/src/p_local.h index 142e896da..1198335ec 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -291,6 +291,17 @@ FUNCINLINE static ATTRINLINE boolean P_MobjWasRemoved(const mobj_t *mobj) return (!mobj || mobj->thinker.function != (actionf_p1)P_MobjThinker); } +// stupid, but kart allows mobjs that are marked to be removed to be accessed and modified in many cases +// so can only check if its not NULL in vanilla compat mode +FUNCINLINE static ATTRINLINE boolean P_MobjWasRemovedCompat(const mobj_t *mobj) +{ +#ifdef COMPAT_VANILLA + return (!mobj); +#else + return P_MobjWasRemoved(mobj); +#endif +} + fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect); fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect); #define P_GetFloorZ(mobj, sector, x, y, line) P_MobjFloorZ(mobj, sector, NULL, x, y, line, false, false) diff --git a/src/p_map.c b/src/p_map.c index 82dba1274..01ab5c0e8 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -322,13 +322,13 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing == tmthing) return true; - // Ignore... things. - if (!tmthing || P_MobjWasRemoved(thing)) - return true; - I_Assert(!P_MobjWasRemoved(tmthing)); I_Assert(!P_MobjWasRemoved(thing)); + // Ignore... things. + if (P_MobjWasRemovedCompat(tmthing) || P_MobjWasRemoved(thing)) + return true; + // Ignore spectators if ((tmthing->player && tmthing->player->spectator) || (thing->player && thing->player->spectator)) @@ -3371,12 +3371,15 @@ void P_BouncePlayerMove(mobj_t *mo) { fixed_t leadx, leady; fixed_t trailx, traily; - fixed_t mmomx = 0, mmomy = 0; - fixed_t oldmomx = mo->momx, oldmomy = mo->momy; + fixed_t mmomx, mmomy; + fixed_t oldmomx, oldmomy; - if (!mo->player) + if (mo->player == NULL) return; + oldmomx = mo->momx; + oldmomy = mo->momy; + if (mo->player->spectator) { P_SlideMove(mo, true); diff --git a/src/p_mobj.c b/src/p_mobj.c index 007f3d108..02e1e1bc6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -347,7 +347,7 @@ void P_ExplodeMissile(mobj_t *mo) explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - if (explodemo) + if (!P_MobjWasRemovedCompat(explodemo)) { P_SetScale(explodemo, mo->scale); explodemo->destscale = mo->destscale; @@ -358,7 +358,7 @@ void P_ExplodeMissile(mobj_t *mo) explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - if (explodemo) + if (!P_MobjWasRemovedCompat(explodemo)) { P_SetScale(explodemo, mo->scale); explodemo->destscale = mo->destscale; @@ -369,7 +369,7 @@ void P_ExplodeMissile(mobj_t *mo) explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - if (explodemo) + if (!P_MobjWasRemovedCompat(explodemo)) { P_SetScale(explodemo, mo->scale); explodemo->destscale = mo->destscale; @@ -380,7 +380,7 @@ void P_ExplodeMissile(mobj_t *mo) explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - if (explodemo) + if (!P_MobjWasRemovedCompat(explodemo)) { P_SetScale(explodemo, mo->scale); explodemo->destscale = mo->destscale; @@ -3380,11 +3380,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return; P_MobjCheckWater(mobj); @@ -5634,11 +5630,7 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale) player_t *player; fixed_t oldscale; -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return; oldscale = mobj->scale; //keep for adjusting stuff below @@ -8989,11 +8981,7 @@ static boolean P_FuseThink(mobj_t *mobj) static boolean P_MobjPushableThink(mobj_t *mobj) { // would be cool if we could use P_MobjWasRemoved Zzz... -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return false; P_MobjCheckWater(mobj); @@ -9199,11 +9187,7 @@ void P_MobjThinker(mobj_t *mobj) { P_TryMove(mobj, mobj->x, mobj->y, true); // Sets mo->standingslope correctly -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) // anything that calls checkposition can be lethal -#else - if (!mobj) // anything that calls checkposition can be lethal -#endif + if (P_MobjWasRemovedCompat(mobj)) // anything that calls checkposition can be lethal return; P_ButteredSlope(mobj); @@ -9228,11 +9212,7 @@ void P_MobjThinker(mobj_t *mobj) } } -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return; // obligatory paranoia check // Can end up here if a player dies. @@ -9292,11 +9272,7 @@ void P_PushableThinker(mobj_t *mobj) I_Assert(!P_MobjWasRemoved(mobj)); -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return; sec = mobj->subsector->sector; From 1dee3060dd9f9729a83d3c09069af00d30027a4f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 18:31:02 +0200 Subject: [PATCH 15/18] add some more mobj checks to p_map cross-checked against srb2 next branch --- src/p_map.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 01ab5c0e8..ce43c2235 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3190,6 +3190,9 @@ void P_SlideMove(mobj_t *mo, boolean forceslide) INT16 hitcount = 0; boolean success = false; + if (P_MobjWasRemovedCompat(mo)) + return; + if (tmhitthing && mo->z + mo->height > tmhitthing->z && mo->z < tmhitthing->z + tmhitthing->height) { // Don't mess with your momentum if it's a pushable object. Pushables do their own crazy things already. @@ -3226,6 +3229,9 @@ void P_SlideMove(mobj_t *mo, boolean forceslide) bestslideline = NULL; retry: + if (P_MobjWasRemovedCompat(mo)) + return; + if (++hitcount == 3) goto stairstep; // don't loop forever @@ -3274,7 +3280,13 @@ retry: // the move must have hit the middle, so stairstep stairstep: if (!P_TryMove(mo, mo->x, mo->y + mo->momy, true)) //Allow things to drop off. + { + if (P_MobjWasRemovedCompat(mo)) + return; + P_TryMove(mo, mo->x + mo->momx, mo->y, true); + } + return; } @@ -3286,7 +3298,12 @@ stairstep: newy = FixedMul(mo->momy, bestslidefrac); if (!P_TryMove(mo, mo->x + newx, mo->y + newy, true)) + { goto stairstep; + } + + if (P_MobjWasRemovedCompat(mo)) + return; } // Now continue along the wall. @@ -3357,8 +3374,11 @@ stairstep: goto retry; } + if (P_MobjWasRemovedCompat(mo)) + return; + success = true; - } while(tmxmove || tmymove); + } while (tmxmove || tmymove); } // @@ -3374,6 +3394,9 @@ void P_BouncePlayerMove(mobj_t *mo) fixed_t mmomx, mmomy; fixed_t oldmomx, oldmomy; + if (P_MobjWasRemovedCompat(mo)) + return; + if (mo->player == NULL) return; @@ -3468,6 +3491,9 @@ void P_BouncePlayerMove(mobj_t *mo) if (!P_TryMove(mo, mo->x + tmxmove, mo->y + tmymove, true)) { + if (P_MobjWasRemovedCompat(mo)) + return; + P_TryMove(mo, mo->x - oldmomx, mo->y - oldmomy, true); } } @@ -3485,6 +3511,9 @@ void P_BounceMove(mobj_t *mo) INT32 hitcount; fixed_t mmomx = 0, mmomy = 0; + if (P_MobjWasRemovedCompat(mo)) + return; + if (mo->player) { P_BouncePlayerMove(mo); @@ -3501,6 +3530,9 @@ void P_BounceMove(mobj_t *mo) hitcount = 0; retry: + if (P_MobjWasRemovedCompat(mo)) + return; + if (++hitcount == 3) goto bounceback; // don't loop forever @@ -3559,7 +3591,12 @@ bounceback: newy = FixedMul(mmomy, bestslidefrac); if (!P_TryMove(mo, mo->x + newx, mo->y + newy, true)) + { + if (P_MobjWasRemovedCompat(mo)) + return; + goto bounceback; + } } // Now continue along the wall. From bba86fe4af56d35188c0ec13cbabde92bf3932ed Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 18:10:07 +0200 Subject: [PATCH 16/18] fix DRAWONLYFORX sprite visability handling this effectively didnt do anything and had a typo for the player 3 case anyways --- src/r_things.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index d891d40ce..bc01c4cc8 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2941,16 +2941,16 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) /* Check if thing may be drawn from our current view. */ boolean R_ThingVisible(mobj_t *thing) { - if (UNLIKELY((thing->sprite == SPR_NULL) || (thing->flags2 & MF2_DONTDRAW))) + if ((thing->sprite == SPR_NULL) || (thing->flags2 & MF2_DONTDRAW)) return false; - if (UNLIKELY(splitscreen)) + if (splitscreen) { - if ((viewssnum == 0 && (thing->eflags & MFE_DRAWONLYFORP1)) - || (viewssnum == 1 && (thing->eflags & MFE_DRAWONLYFORP2)) - || (viewssnum == 2 && (thing->eflags & MFE_DRAWONLYFORP2)) - || (viewssnum == 3 && (thing->eflags & MFE_DRAWONLYFORP4))) - return true; + if (((thing->eflags & MFE_DRAWONLYFORP1) && viewssnum != 0) + || ((thing->eflags & MFE_DRAWONLYFORP2) && viewssnum != 1) + || ((thing->eflags & MFE_DRAWONLYFORP3) && viewssnum != 2) + || ((thing->eflags & MFE_DRAWONLYFORP4) && viewssnum != 3)) + return false; } return true; From 63e4c5a63ddb168687513679d8585d29ec7da5fd Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 18:09:20 +0200 Subject: [PATCH 17/18] use viewsin and viewcos for spherefrustum checks in gl dont need all those yaw vars, since they effectively map to gl_viewsin and -gl_viewcos respectively while those are less accurate due to being fixed point, there appears to be no visual issues from this and seems to even slightly improve performance in some cases --- src/hardware/hw_batching.c | 1 + src/hardware/hw_main.cpp | 30 +++++++++--------------------- src/hardware/r_opengl/r_opengl.c | 6 +++--- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 8bf7f7375..9b1699029 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -183,6 +183,7 @@ static int comparePolygons(const void *p1, const void *p2) UINT32 downloaded1 = poly1->texture ? poly1->texture->downloaded : 0; // there should be a opengl texture name here, usable for comparisons UINT32 downloaded2 = poly2->texture ? poly2->texture->downloaded : 0; + diff64 = downloaded1 - downloaded2; if (diff64 != 0) return diff64; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 642fdfec7..c01c59afc 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -84,11 +84,6 @@ float gl_viewsin = 0.0f, gl_viewcos = 0.0f; static float gl_viewludsin, gl_viewludcos; static angle_t gl_aimingangle; -static float yaw = 0.0f; -static float inv_yaw = 0.0f; -static float cos_inv_yaw = 0.0f; -static float sin_inv_yaw = 0.0f; - static constexpr float deg2radians = (M_PIf / 180.0f); seg_t *gl_curline = NULL; @@ -4764,9 +4759,9 @@ static void HWR_ProjectSprite(mobj_t *thing) // if the sprite is out of our view, dont need to draw it X) if (!gld_SphereInFrustum( - (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, + (FixedToFloat(interp.x)) + gl_viewsin * (x1 + x2) / 2.0f, FixedToFloat(interp.z) + (y1 + y2) / 2.0f, - FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + FixedToFloat(interp.y) - (-gl_viewcos) * (x1 + x2) / 2.0f, //1.5 == sqrt(2) + small delta for MF_FOREGROUND std::max(FixedToFloat(spr_width) * spritexscale, FixedToFloat(spr_height) * spriteyscale) / 2.0f * 1.5f)) @@ -4984,9 +4979,9 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) y2 *= thing_scale; if (!gld_SphereInFrustum( - (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, + (FixedToFloat(interp.x)) + gl_viewsin * (x1 + x2) / 2.0f, FixedToFloat(interp.z) + (y1 + y2) / 2.0f, - FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + FixedToFloat(interp.y) - (-gl_viewcos) * (x1 + x2) / 2.0f, //1.5 == sqrt(2) + small delta for MF_FOREGROUND std::max(FixedToFloat(spr_width) * thing_scale, FixedToFloat(spr_height) * thing_scale) / 2.0f * 1.5f)) @@ -5116,24 +5111,22 @@ void HWR_BuildSkyDome(void) int c, r; signed char yflip; static constexpr int row_count = 4; - int col_count = 4; + static constexpr int col_count = (4 * 16); float delta; gl_sky_t *sky = &gl_sky; gl_skyvertex_t *vertex_p; const texture_t *texture = textures[texturetranslation[skytexture]]; - col_count *= 16; - if ((sky->columns != col_count) || (sky->rows != row_count)) HWR_ClearSkyDome(); sky->columns = col_count; sky->rows = row_count; - sky->vertex_count = 2 * sky->rows * (sky->columns * 2 + 2) + sky->columns * 2; + sky->vertex_count = 2 * row_count * (col_count * 2 + 2) + col_count * 2; if (!sky->loops) - sky->loops = static_cast(malloc((sky->rows * 2 + 2) * sizeof(sky->loops[0]))); + sky->loops = static_cast(malloc((row_count * 2 + 2) * sizeof(sky->loops[0]))); // create vertex array if (!sky->data) @@ -5397,12 +5390,6 @@ void HWR_SetTransform(float fpov) HWR_SetTransformAiming(&atransform); atransform.angley = static_cast(viewangle >> ANGLETOFINESHIFT)*(FINEDEGREE); - yaw = 270.0f - atransform.angley; - inv_yaw = 180.0f - yaw; - const float inv_yaw_radians = inv_yaw * deg2radians; - cos_inv_yaw = cosf(inv_yaw_radians); - sin_inv_yaw = sinf(inv_yaw_radians); - // only needed for sprite billboarding if (cv_glspritebillboarding.value && !cv_glshearing.value) { @@ -5540,7 +5527,8 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool if constexpr (Type == RenderViewpointType::kPortal) { - gl_collect_skywalls = (allow_portals && !rootportal && portallist.base && (!skyboxmo[0] || !cv_skybox.value)); // if portals have been drawn in the main view, then render skywalls differently + // if portals have been drawn in the main view, then render skywalls differently + gl_collect_skywalls = (allow_portals && !rootportal && portallist.base && (!skyboxmo[0] || !cv_skybox.value)); // HAYA: Save the old portal state, and turn portals off while normally rendering the BSP tree. // This fixes specific effects not working, such as horizon lines. diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 071e67f03..aff722773 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2490,7 +2490,7 @@ void GL_RenderSkyDome(gl_sky_t *sky) GL_Shader_SetUniforms(NULL, NULL, NULL, NULL); // Build the sky dome! Yes! - if (sky->rebuild) + if (sky->rebuild || !sky->vbo) { // delete VBO when already exists if (sky->vbo) @@ -3208,8 +3208,8 @@ void GL_SetTransform(FTransform *stransform) { float dy = stransform->viewaiming * 2; - if (stransform->fliptype == TRANSFORM_FLIP - || stransform->fliptype == TRANSFORM_MIRRORFLIP) + if (stransform->fliptype == TRANSFORM_FLIP || + stransform->fliptype == TRANSFORM_MIRRORFLIP) dy *= -1.0f; pglTranslatef(0.0f, -dy/BASEVIDHEIGHT, 0.0f); From 41cbce3ed3b108427deddd233eaf9cc907388428 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 19:42:58 +0200 Subject: [PATCH 18/18] hack for kartdebugcheckpoint display see comment --- src/k_hud.c | 6 ++++- src/k_kart.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/k_kart.h | 2 ++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/src/k_hud.c b/src/k_hud.c index 0deb8f0f5..3dd36c95d 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4576,7 +4576,11 @@ static void K_drawCheckpointDebugger(void) else V_DrawString(8, 184, 0, va("Checkpoint: %d / %d (Skip: %d)", stplyr->starpostnum, numstarposts, ((numstarposts/2) + stplyr->starpostnum))); - V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", stplyr->kartstuff[k_prevcheck], stplyr->kartstuff[k_nextcheck])); + // really gnarly hack + const INT32 prevcheck = (stprevnextchecks[0] != INT32_MAX) ? stprevnextchecks[0]: stplyr->kartstuff[k_prevcheck]; + const INT32 nextcheck = (stprevnextchecks[1] != INT32_MAX) ? stprevnextchecks[1]: stplyr->kartstuff[k_nextcheck]; + + V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", prevcheck, nextcheck)); } // determines if gametype info (laps/bumpers) should be hidden diff --git a/src/k_kart.c b/src/k_kart.c index d7759a3f7..39961c1a9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6212,6 +6212,64 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_brakedrift] = 0; } +INT32 stprevnextchecks[2] = {INT32_MAX, INT32_MAX}; // there wont be any map this big, wont there?..... + +// K_KartUpdatePosition has a bug where whatever player comes last in the players array +// gets its distance calculations applied twice +// since we cannot fix this due to compat concerns (kartstuff is exposed after all) +// we gotta do this shit hack to atleast fix the debugcheckpoint display +static void K_KartUpdatePositionDebugHack(player_t *player, player_t *otherplayer) +{ + mobj_t *mo; + fixed_t pmo; + fixed_t ppcd, pncd; + + // dont need this crap + if (!cv_kartdebugcheckpoint.value) + return; + + // not checking against ourselves + if (player != otherplayer) + return; + + // dont care if its not first displayplayer + // since this is only used for the debug display + if (player != &players[displayplayers[0]]) + return; + + ppcd = pncd = 0; + stprevnextchecks[0] = stprevnextchecks[1] = 0; + + // This checks every thing on the map, and looks for MT_BOSS3WAYPOINT (the thing we're using for checkpoint wp's, for now) + for (mo = waypointcap; mo != NULL; mo = mo->tracer) + { + const boolean isprevcheckpointp = mo->health == player->starpostnum; + const boolean isnextcheckpointp = mo->health == (player->starpostnum + 1); + + if ((isprevcheckpointp || isnextcheckpointp) && (!mo->movecount || mo->movecount == player->laps+1)) + { + pmo = P_AproxDistance(P_AproxDistance( mo->x - player->mo->x, + mo->y - player->mo->y), + mo->z - player->mo->z) / FRACUNIT; + + if (isprevcheckpointp) + { + stprevnextchecks[0] += pmo; + ppcd++; + } + + if (isnextcheckpointp) + { + stprevnextchecks[1] += pmo; + pncd++; + } + } + } + + if (ppcd > 1) stprevnextchecks[0] /= ppcd; + if (pncd > 1) stprevnextchecks[1] /= pncd; +} + // // K_KartUpdatePosition // @@ -6223,6 +6281,9 @@ void K_KartUpdatePosition(player_t *player) fixed_t pmo, imo; mobj_t *mo; + // always reset this + stprevnextchecks[0] = stprevnextchecks[1] = INT32_MAX; + if (player->spectator || !player->mo) return; @@ -6323,6 +6384,9 @@ void K_KartUpdatePosition(player_t *player) if (players[i].starposttime < player->starposttime) position++; } + + // stupid hack + K_KartUpdatePositionDebugHack(player, &players[i]); } } else if (G_BattleGametype()) diff --git a/src/k_kart.h b/src/k_kart.h index 9307ce273..4d81375cd 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -32,6 +32,8 @@ extern consvar_t cv_bananajitter; extern consvar_t cv_bananthrowroll; extern consvar_t cv_airsparks; +extern INT32 stprevnextchecks[2]; + boolean K_IsPlayerLosing(player_t *player); boolean K_IsPlayerWanted(player_t *player); INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean spbrush);