From b575c288fa6c7a77459daf87d594b5b9db5a5e7d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 18 Jun 2026 16:34:51 +0200 Subject: [PATCH 01/39] allow page up/down to scroll through chat like in console --- src/hu_stuff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 67bcf6371..51f9a7dad 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1281,13 +1281,15 @@ boolean HU_Responder(event_t *ev) chat_on = false; I_SetTextInput(false); } - else if ((c == KEY_UPARROW || c == KEY_MOUSEWHEELUP) && chat_scroll > 0 && !OLDCHAT) // CHAT SCROLLING YAYS! + else if ((c == KEY_UPARROW || c == KEY_PGUP || c == KEY_MOUSEWHEELUP) && + ((chat_scroll > 0) && !OLDCHAT)) // CHAT SCROLLING YAYS! { chat_scroll--; justscrolledup = true; chat_scrolltime = 4; } - else if ((c == KEY_DOWNARROW || c == KEY_MOUSEWHEELDOWN) && chat_scroll < chat_maxscroll && chat_maxscroll > 0 && !OLDCHAT) + else if ((c == KEY_DOWNARROW || c == KEY_PGDN || c == KEY_MOUSEWHEELDOWN) && + ((chat_scroll < chat_maxscroll) && (chat_maxscroll > 0) && !OLDCHAT)) { chat_scroll++; justscrolleddown = true; From 17093e80227fa50cdd138ee3e2c877c238e837c6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 18:03:40 +0200 Subject: [PATCH 02/39] add command to list unused map slots less pain for server owners hope this is sufficient --- src/d_netcmd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8fbac60a6..61ba54002 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -150,6 +150,7 @@ static void Command_ListWADS_f(void); static void Command_LocateLump_f(void); static void Command_ListDoomednums_f(void); static void Command_ListUnusedSprites_f(void); +static void Command_ListUnusedMapSlots_f(void); static void Command_RunSOC(void); static void Command_Pause(void); static void Command_Respawn(void); @@ -645,6 +646,7 @@ void D_RegisterServerCommands(void) COM_AddCommand("locatelump", Command_LocateLump_f); COM_AddCommand("listmapthings", Command_ListDoomednums_f); COM_AddCommand("listunusedsprites", Command_ListUnusedSprites_f); + COM_AddCommand("listunusedmapslots", Command_ListUnusedMapSlots_f); COM_AddCommand("runsoc", Command_RunSOC); COM_AddCommand("pause", Command_Pause); @@ -4591,6 +4593,23 @@ void Command_ListUnusedSprites_f(void) } } +void Command_ListUnusedMapSlots_f(void) +{ + INT32 i; + + CONS_Printf("\x82Printing map slot non-usage...\n"); + + for (i = 0; i < NUMMAPS; i++) + { + // is checking this enough? + if (mapheaderinfo[i]) + continue; + + CONS_Printf("%s\n", G_BuildMapName(i+1)); + } +} + + // ========================================================================= // MISC. COMMANDS // ========================================================================= From fc588f8046f0c42a7b71ca5aac71efebe2bc5d94 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Sun, 20 Nov 2022 11:50:57 +0100 Subject: [PATCH 03/39] Make con_height adjustable on the fly --- src/console.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index 8ca29f901..c155bd745 100644 --- a/src/console.c +++ b/src/console.c @@ -103,6 +103,8 @@ static void CON_InputInit(void); static void CON_RecalcSize(void); static void CON_ChangeHeight(void); +static void CON_DrawBackpic(void); +static void CONS_height_Change(void); static void CONS_hudlines_Change(void); static void CONS_backcolor_Change(void); @@ -131,7 +133,7 @@ static CV_PossibleValue_t speed_cons_t[] = {{0, "MIN"}, {64, "MAX"}, {0, NULL}}; static consvar_t cons_speed = {"con_speed", "8", CV_SAVE, speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // percentage of screen height to use for console -static consvar_t cons_height = {"con_height", "50", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cons_height = {"con_height", "50", CV_CALL|CV_SAVE, CV_Unsigned, CONS_height_Change, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t backpic_cons_t[] = {{0, "translucent"}, {1, "picture"}, {0, NULL}}; // whether to use console background picture, or translucent mode @@ -173,6 +175,18 @@ consvar_t cons_consoleprintinmenu = {"consoleprintinmenu", "Off", CV_SAVE, CV_On static void CON_Print(char *msg); +// Change the console height on demand +// +static void CONS_height_Change(void) +{ + Lock_state(); + + if (con_destlines > 0 && !con_startup) // If the console is open (as in, not using "bind")... + CON_ChangeHeight(); // ...update its height now, not only when it's closed and re-opened + + Unlock_state(); +} + // // static void CONS_hudlines_Change(void) From c275555678edf16413de1c70e8c50d2fb3910a1b Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Sun, 20 Nov 2022 11:51:40 +0100 Subject: [PATCH 04/39] Draw the input prompt while the console is moving --- src/console.c | 77 ++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/src/console.c b/src/console.c index c155bd745..517ab9f58 100644 --- a/src/console.c +++ b/src/console.c @@ -62,7 +62,7 @@ static boolean con_started = false; // console has been initialised static boolean con_forcepic = true; // at startup toggle console translucency when first off boolean con_recalc = false; // set true when screen size has changed -static tic_t con_tick; // console ticker for anim or blinking prompt cursor +static tic_t con_tick; // console ticker for blinking prompt cursor // con_scrollup should use time (currenttime - lasttime).. static boolean consoletoggle; // true when console key pushed, ticker will handle @@ -1651,53 +1651,54 @@ static void CON_DrawConsole(void) } // draw console text lines from top to bottom - if (con_curlines < minheight) - return; - - i = con_cy - con_scrollup; - - // skip the last empty line due to the cursor being at the start of a new line - i--; - - i -= (con_curlines - minheight) / charheight; - - if (rendermode == render_none) return; - - for (y = (con_curlines-minheight) % charheight; y <= con_curlines-minheight; y += charheight, i++) + if (con_curlines >= minheight) { - INT32 x; - size_t c; + i = con_cy - con_scrollup; - p = (UINT8 *)&con_buffer[((i > 0 ? i : 0)%con_totallines)*con_width]; + // skip the last empty line due to the cursor being at the start of a new line + i--; - for (c = 0, x = charwidth; c < con_width; c++, x += charwidth, p++) + i -= (con_curlines - minheight) / charheight; + + if (rendermode == render_none) + return; + + for (y = (con_curlines-minheight) % charheight; y <= con_curlines-minheight; y += charheight, i++) { - while (*p & 0x80) + INT32 x; + size_t c; + + p = (UINT8 *)&con_buffer[((i > 0 ? i : 0)%con_totallines)*con_width]; + + for (c = 0, x = charwidth; c < con_width; c++, x += charwidth, p++) { - charflags = (*p & 0x7f) << V_CHARCOLORSHIFT; - p++; - c++; + while (*p & 0x80) + { + charflags = (*p & 0x7f) << V_CHARCOLORSHIFT; + p++; + c++; + } + + if (c >= con_width) + break; + + int emotelen; + emote_t *emote; + + if ((emote = M_VerifyEmote((const char *)p, &emotelen))) + { + M_DrawScaledEmote(x<= con_width) - break; - - int emotelen; - emote_t *emote; - - if ((emote = M_VerifyEmote((const char *)p, &emotelen))) - { - M_DrawScaledEmote(x<= minheight) && !con_startup) + if ((con_curlines >= (minheight-charheight)) && !con_startup) CON_DrawInput(); } From 3b6a09da9b5178dd316b01d483d9d7998667951c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 19:04:42 +0200 Subject: [PATCH 05/39] oops --- src/console.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/console.c b/src/console.c index 517ab9f58..40a3d1700 100644 --- a/src/console.c +++ b/src/console.c @@ -103,7 +103,6 @@ static void CON_InputInit(void); static void CON_RecalcSize(void); static void CON_ChangeHeight(void); -static void CON_DrawBackpic(void); static void CONS_height_Change(void); static void CONS_hudlines_Change(void); static void CONS_backcolor_Change(void); From 9bdda66a0ca8d2c9cd4898fdd3ad4e646485e1be Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 19:14:15 +0200 Subject: [PATCH 06/39] rename this to D_CheckMapReplacements --- src/d_main.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index be19da2de..e821de566 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1353,7 +1353,7 @@ static void IdentifyVersion(void) // // search for maps // -static void D_CheckMaps(boolean checkreplaced) +static void D_CheckMapReplacements(boolean checkreplaced) { INT32 i; char *name; @@ -1829,17 +1829,19 @@ void D_SRB2Main(void) // conversion sometimes needs the palette V_ReloadPalette(); - D_CheckMaps(false); + D_CheckMapReplacements(false); - W_InitMultipleFiles(startuppwads, startuppwadcount, true); - - // Only search for pwad maps if we actually have a pwad added if (startuppwadcount > 0) { - D_CheckMaps(true); + CONS_Printf("W_InitMultipleFiles(): Adding extra PWADs.\n"); + W_InitMultipleFiles(startuppwads, startuppwadcount, true); + + // Only search for pwad maps if we actually have a pwad added + D_CheckMapReplacements(true); + + D_CleanFile(startuppwads, startuppwadcount); } - D_CleanFile(startuppwads, startuppwadcount); startuppwadcount = 0; cht_Init(); @@ -1926,7 +1928,7 @@ void D_SRB2Main(void) CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n"); R_Init(); -#if SOUND==SOUND_DUMMY +#if SOUND == SOUND_DUMMY sound_disabled = true; music_disabled = true; #else From 0cff3c23f3fc8bb7d9ef7c9746a69af7643560f8 Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Tue, 6 Feb 2024 06:00:59 -0700 Subject: [PATCH 07/39] Don't attempt itemamount correction after orbitals self-destruct --- src/k_kart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index ac1a3a8fd..4c41735d1 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4686,7 +4686,6 @@ void K_RepairOrbitChain(mobj_t *orbit) // Then recount to make sure item amount is correct if (orbit->target && orbit->target->player) { - player_t *player = orbit->target->player; INT32 num = 0; mobj_t *cur = orbit->target->hnext; @@ -4696,13 +4695,14 @@ void K_RepairOrbitChain(mobj_t *orbit) { prev = cur; cur = cur->hnext; - if (++num > player->kartstuff[k_itemamount]) + if (++num > orbit->target->player->kartstuff[k_itemamount]) P_RemoveMobj(prev); else prev->movedir = num; } - player->kartstuff[k_itemamount] = num; + if (orbit->target) // !P_MobjWasRemoved(orbit->target) + orbit->target->player->kartstuff[k_itemamount] = num; } } From 40537eca811629344027ae43520be0a8725838d3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 22:53:49 +0200 Subject: [PATCH 08/39] cleanup P_KillMobj a little --- src/k_kart.c | 2 +- src/p_inter.c | 148 ++++++++++++++++++++++++++++---------------------- 2 files changed, 83 insertions(+), 67 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 4c41735d1..dbe13ebd7 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4684,7 +4684,7 @@ void K_RepairOrbitChain(mobj_t *orbit) } // Then recount to make sure item amount is correct - if (orbit->target && orbit->target->player) + if (orbit->target && orbit->target->player) // !P_MobjWasRemoved(orbit->target) { INT32 num = 0; diff --git a/src/p_inter.c b/src/p_inter.c index 0a35cab3c..76e4d2e8b 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1462,48 +1462,11 @@ boolean P_CheckRacers(void) return false; } -/** Kills an object. - * - * \param target The victim. - * \param inflictor The attack weapon. May be NULL (environmental damage). - * \param source The attacker. May be NULL. - * \todo Cleanup, refactor, split up. - * \sa P_DamageMobj - */ -void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) +static void P_UpdateRemovedOrbital(mobj_t *target, mobj_t *inflictor, mobj_t *source) { - mobjtype_t item; - mobj_t *mo; - int ms; - - if (target->flags & (MF_ENEMY|MF_BOSS)) - target->momx = target->momy = target->momz = 0; - - // SRB2kart - if (target->type != MT_PLAYER && !(target->flags & MF_MONITOR) - && !(target->type == MT_ORBINAUT || target->type == MT_ORBINAUT_SHIELD - || target->type == MT_JAWZ || target->type == MT_JAWZ_DUD || target->type == MT_JAWZ_SHIELD - || target->type == MT_BANANA || target->type == MT_BANANA_SHIELD - || target->type == MT_EGGMANITEM || target->type == MT_EGGMANITEM_SHIELD - || target->type == MT_BALLHOG || target->type == MT_SPB)) // kart dead items - target->flags |= MF_NOGRAVITY; // Don't drop Tails 03-08-2000 - else - target->flags &= ~MF_NOGRAVITY; // lose it if you for whatever reason have it, I'm looking at you shields - // - - if (target->flags2 & MF2_NIGHTSPULL) - P_SetTarget(&target->tracer, NULL); - - // dead target is no more shootable - target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SPECIAL); - target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL); - target->health = 0; // This makes it easy to check if something's dead elsewhere. - - if (LUA_HookMobjDeath(target, inflictor, source) || P_MobjWasRemoved(target)) - return; - // SRB2kart // I wish I knew a better way to do this + //if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) if (target->target && target->target->player && target->target->player->mo) { if (target->target->player->kartstuff[k_eggmanheld] && target->type == MT_EGGMANITEM_SHIELD) @@ -1517,7 +1480,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { if (target->movedir != 0 && target->movedir < (UINT16)target->target->player->kartstuff[k_itemamount]) { - if (target->target->hnext) + if (target->target->hnext) // !P_MobjWasRemoved(target->target->hnext)) K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; @@ -1546,14 +1509,60 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) P_SetTarget(&target->target->hnext, NULL); } } - // Above block does not clean up rocket sneakers when a player dies, so we need to do it here target->target is null when using rocket sneakers +} + + +/** Kills an object. + * + * \param target The victim. + * \param inflictor The attack weapon. May be NULL (environmental damage). + * \param source The attacker. May be NULL. + * \todo Cleanup, refactor, split up. + * \sa P_DamageMobj + */ +void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) +{ + mobjtype_t item; + mobj_t *mo; + int ms; + + if (target->flags & (MF_ENEMY|MF_BOSS)) + target->momx = target->momy = target->momz = 0; + + // SRB2kart + if (target->type != MT_PLAYER + && !(target->flags & MF_MONITOR) + && !(target->type == MT_ORBINAUT || target->type == MT_ORBINAUT_SHIELD + || target->type == MT_JAWZ || target->type == MT_JAWZ_DUD || target->type == MT_JAWZ_SHIELD + || target->type == MT_BANANA || target->type == MT_BANANA_SHIELD + || target->type == MT_EGGMANITEM || target->type == MT_EGGMANITEM_SHIELD + || target->type == MT_BALLHOG || target->type == MT_SPB)) // kart dead items + target->flags |= MF_NOGRAVITY; // Don't drop Tails 03-08-2000 + else + target->flags &= ~MF_NOGRAVITY; // lose it if you for whatever reason have it, I'm looking at you shields + // + + if (target->flags2 & MF2_NIGHTSPULL) + P_SetTarget(&target->tracer, NULL); + + // dead target is no more shootable + target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SPECIAL); + target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL); + target->health = 0; // This makes it easy to check if something's dead elsewhere. + + if (LUA_HookMobjDeath(target, inflictor, source) || P_MobjWasRemoved(target)) + return; + + P_UpdateRemovedOrbital(target, inflictor, source); + if (target->player) + { + // Above block does not clean up rocket sneakers when a player dies, so we need to do it here target->target is null when using rocket sneakers K_DropRocketSneaker(target->player); - // Let EVERYONE know what happened to a player! 01-29-2002 Tails - if (target->player && !target->player->spectator) - { - target->flags2 &= ~MF2_DONTDRAW; + // Let EVERYONE know what happened to a player! 01-29-2002 Tails + if (!target->player->spectator) + target->flags2 &= ~MF2_DONTDRAW; } // if killed by a player @@ -1563,6 +1572,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { P_SetTarget(&target->target, source); source->player->numboxes++; + if (cv_itemrespawn.value && (netgame || multiplayer)) { target->fuse = cv_itemrespawntime.value*TICRATE + 2; // Random box generation @@ -1580,35 +1590,41 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) target->player->playerstate = PST_DEAD; - if (cv_fading.value && P_IsLocalPlayer(target->player)) + if (P_IsLocalPlayer(target->player)) { - if (netgame || multiplayer) - ms = cv_respawntime.value * 1000; - else - ms = 1000; + if (cv_fading.value) + { + if (netgame || multiplayer) + ms = cv_respawntime.value * 1000; + else + ms = 1000; - /* - If the time spent with the music paused is less than half - a second, continue playing the song (just mute it). - */ - if ((ms - cv_respawnfademusicout.value) < 500) - S_FadeMusic(0, cv_respawnfademusicout.value); - else - S_FadeOutStopMusic(cv_respawnfademusicout.value); - } + /* + * If the time spent with the music paused is less than half + * a second, continue playing the song (just mute it). + */ + if ((ms - cv_respawnfademusicout.value) < 500) + S_FadeMusic(0, cv_respawnfademusicout.value); + else + S_FadeOutStopMusic(cv_respawnfademusicout.value); + } - for (UINT8 i = 0; i <= splitscreen; i++) - { - if (target->player == P_GetLocalPlayerForNum(i)) + if (target->player == &players[consoleplayer]) { // don't die in auto map, // switch view prior to dying - if (i == 0 && automapactive) + if (automapactive) AM_Stop(); + } - // added : 22-02-98: recenter view for next life... - localaiming[i] = 0; - break; + for (UINT8 i = 0; i <= splitscreen; i++) + { + if (target->player == P_GetLocalPlayerForNum(i)) + { + // added : 22-02-98: recenter view for next life... + localaiming[i] = 0; + break; + } } } From 0f1ad8a086334d806604ed8b9320c72148f0c919 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:07:12 +0200 Subject: [PATCH 09/39] few more smaller cleanups --- src/g_game.c | 5 +++-- src/hu_stuff.c | 1 + src/p_map.c | 4 ++-- src/p_maputl.cpp | 3 +++ src/p_setup.c | 16 +++++++++++----- src/r_segs.cpp | 31 ++++++++++++++++++------------- src/s_sound.c | 1 + 7 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index f6941a911..22f811bc8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -857,7 +857,8 @@ static void G_HandleLocalDriftturn(ticcmd_t *cmd, UINT8 ssplayer) static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) { INT32 axis = 0; - const boolean usejoystick = cv_usejoystick[(ssplayer-1)].value; + const UINT8 forplayer = (ssplayer-1); + const boolean usejoystick = cv_usejoystick[forplayer].value; // check for inputs and return button commands // for stuff like joining with item button, saltyhop, honking, etc. @@ -893,7 +894,7 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) #undef CHECKINPUT axis = JoyAxis(AXISLOOKBACK, ssplayer); - camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); + camspin[forplayer] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); // Reset to our spec player if we watch someone else. if ((cmd->driftturn || cmd->buttons) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 51f9a7dad..2c509080b 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1135,6 +1135,7 @@ static void HU_SendChatMessage(void) return; } } + // I'm very bad at C, I swear I am, additional checks eww! if (spc != 0) { diff --git a/src/p_map.c b/src/p_map.c index ee013a2ab..e4a7323ca 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1575,13 +1575,13 @@ static boolean PIT_CheckLine(line_t *ld) tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - return true; + return true; // didn't hit it if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return true; if (P_BoxOnLineSide(tmbbox, ld) != -1) - return true; + return true; // didn't hit it if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag. { diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 592f57e92..38e350409 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -1000,11 +1000,13 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) for (mobj = blocklinks[y*bmapwidth + x]; mobj; mobj = bnext) { P_SetTarget(&bnext, mobj->bnext); // We want to note our reference to bnext here incase it is MF_NOTHINK and gets removed! + if (!func(mobj)) { P_SetTarget(&bnext, NULL); return false; } + if (P_MobjWasRemoved(tmthing) // func just popped our tmthing, cannot continue. || (bnext && P_MobjWasRemoved(bnext))) // func just broke blockmap chain, cannot continue. { @@ -1012,6 +1014,7 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) return true; } } + P_SetTarget(&bnext, NULL); return true; } diff --git a/src/p_setup.c b/src/p_setup.c index 0be23b262..aee747626 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1025,6 +1025,7 @@ static void P_InitializeLinedef(line_t *ld) CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has two-sided flag set, but no second sidedef\n", sizeu1((size_t)(ld - lines))); } + // killough 4/4/98: support special sidedef interpretation below if (ld->sidenum[0] != 0xffff && ld->special) sides[ld->sidenum[0]].special = ld->special; if (ld->sidenum[1] != 0xffff && ld->special) @@ -2329,7 +2330,9 @@ static void P_LoadRecordGhosts(void) if (!gpath) return; - sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); + const char *mapname = G_BuildMapName(gamemap); + + sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, mapname); // Best Time ghost if (cv_ghost_besttime.value) @@ -2379,9 +2382,10 @@ static void P_LoadRecordGhosts(void) { lumpnum_t l; UINT8 j = 1; - while (j <= 99 && (l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(gamemap),j))) != LUMPERROR) + + while (j <= 99 && (l = W_CheckNumForName(va("%sS%02u", mapname, j))) != LUMPERROR) { - G_AddGhost(va("%sS%02u",G_BuildMapName(gamemap),j)); + G_AddGhost(va("%sS%02u", mapname, j)); j++; } } @@ -2423,10 +2427,12 @@ static void P_InitMinimapInfo(void) Patch_Free(minimapinfo.minimap_pic); minimapinfo.minimap_pic = NULL; - lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap))); + const char *mapname = G_BuildMapName(gamemap); + + lumpnum = W_CheckNumForName(va("%sR", mapname)); if (lumpnum != LUMPERROR) - minimapinfo.minimap_pic = W_CachePatchName(va("%sR", G_BuildMapName(gamemap)), PU_PATCH); + minimapinfo.minimap_pic = W_CachePatchName(va("%sR", mapname), PU_PATCH); minimapinfo.min_x = bsp->bbox[0][BOXLEFT]; minimapinfo.max_x = bsp->bbox[0][BOXRIGHT]; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index f94e72b4c..26e5a582b 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -311,6 +311,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 { rw_scalestep = drawseg->scalestep; spryscale = drawseg->scale1 + (x1 - drawseg->x1)*rw_scalestep; + if (dc->numlights) { // reset all lights to their starting heights for (i = 0; i < dc->numlights; i++) @@ -435,6 +436,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 windowtop = windowbottom + 1; set_colormap_below_light(); } + windowbottom = realbot; if (windowtop < windowbottom) colfunc_2s(dc, col); @@ -2615,8 +2617,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) auto set_topstep_normal = [&] { - topstep = -FixedMul (rw_scalestep, worldtop); - topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); + topstep = -FixedMul(rw_scalestep, worldtop); + topfrac = (centeryfrac>>4) - FixedMul(worldtop, rw_scale); }; // untextured seg @@ -2625,7 +2627,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) const bool tophigh = (worldhigh <= worldtop && worldhighslope <= worldtopslope); // if we cant see the goddamn skyplane, well there wont be any skybox - // we could kill skyVisible instead, but i want to keep the performance improvemnts it yields + // we could kill skyVisible instead, but i want to keep the performance improvements it yields // so we do this absolute trash if ((tophigh && (frontsector->floorpic != skyflatnum && frontsector->ceilingpic != skyflatnum)) // try to guess if its a "window" @@ -2637,14 +2639,16 @@ void R_StoreWallRange(INT32 start, INT32 stop) // this is an attempt to fix issues with textureless single sided lines drawing nothing where they should just draw sky instead if (tophigh && !backsector && frontsector->ceilingpic == skyflatnum) { - topstep = -FixedMul (rw_scalestep, worldbottom); - topfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); - // account for slopes to try and get rid of sharp edges from the black void if (frontsector->f_slope || (backsector && backsector->f_slope)) { - topstep = -FixedMul (rw_scalestep, worldbottomslope); - topfrac = (centeryfrac>>4) - FixedMul (worldbottomslope, rw_scale); + topstep = -FixedMul(rw_scalestep, worldbottomslope); + topfrac = (centeryfrac>>4) - FixedMul(worldbottomslope, rw_scale); + } + else + { + topstep = -FixedMul(rw_scalestep, worldbottom); + topfrac = (centeryfrac>>4) - FixedMul(worldbottom, rw_scale); } } else @@ -2653,18 +2657,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) else set_topstep_normal(); - bottomstep = -FixedMul (rw_scalestep, worldbottom); - bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); + bottomstep = -FixedMul(rw_scalestep, worldbottom); + bottomfrac = (centeryfrac>>4) - FixedMul(worldbottom, rw_scale); if (frontsector->c_slope) { - fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2); + fixed_t topfracend = (centeryfrac>>4) - FixedMul(worldtopslope, ds_p->scale2); topstep = (topfracend-topfrac)/(range); } if (frontsector->f_slope) { - fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2); + fixed_t bottomfracend = (centeryfrac>>4) - FixedMul(worldbottomslope, ds_p->scale2); bottomstep = (bottomfracend-bottomfrac)/(range); } } @@ -2782,7 +2786,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (bottomtexture) { - fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2); + fixed_t bottomfracend = (centeryfrac>>4) - FixedMul(worldlowslope, ds_p->scale2); pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); pixlowstep = (bottomfracend-pixlow)/(range); @@ -3045,6 +3049,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->silhouette |= SIL_BOTTOM; ds_p->bsilheight = backsector->f_slope ? INT32_MAX : backsector->floorheight; } + if (!(ds_p->silhouette & SIL_TOP)) { ds_p->silhouette |= SIL_TOP; diff --git a/src/s_sound.c b/src/s_sound.c index 5d3c43a3c..a95fc39c0 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -937,6 +937,7 @@ static boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, listener_t listensource; INT32 i; + // e6y if (!listener) return false; From 066adb972e585e8e21bc85875edff37a7a3bb920 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:05:53 +0200 Subject: [PATCH 10/39] add some more mobj null checks to P_MobjThinker from srb2 ig --- src/p_mobj.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index 96a8e11d5..5e33a9803 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9167,6 +9167,11 @@ void P_MobjThinker(mobj_t *mobj) || P_WeaponOrPanel(mobj->type)) { P_TryMove(mobj, mobj->x, mobj->y, true); // Sets mo->standingslope correctly + + //if (P_MobjWasRemoved(mobj)) + if (!mobj) // anything that calls checkposition can be lethal + return; + P_ButteredSlope(mobj); } @@ -9192,6 +9197,10 @@ void P_MobjThinker(mobj_t *mobj) } } + //if (P_MobjWasRemoved(mobj)) + if (!mobj) + return; // obligatory paranoia check + // Can end up here if a player dies. P_CycleMobjState(mobj); From 9cc74d8b17e2b194d29bed6c7cc749320782829d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:04:36 +0200 Subject: [PATCH 11/39] use P_MobjWasRemoved for P_MoveChaseCamera dont need to care about synch safety here.... --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 11c5e0b81..d952e296d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3739,7 +3739,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall fixed_t f1, f2; // We probably shouldn't move the camera if there is no player or player mobj somehow - if (!player || !player->mo) + if (!player || P_MobjWasRemoved(player->mo)) return true; // This can happen when joining From 4b2a13defbf0a9f7d1ec4c40fd000bcf4cb436ef Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:29:59 +0200 Subject: [PATCH 12/39] cleanup K_DropItems a bit move "paperitem" spawn to its separate function like RR --- src/k_kart.c | 73 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index dbe13ebd7..cb4641849 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4559,50 +4559,59 @@ void K_DropHnextList(player_t *player) P_RemoveMobj(work); } - { - // we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic... - P_SetTarget(&player->mo->hnext, NULL); - player->kartstuff[k_bananadrag] = 0; + // we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic... + P_SetTarget(&player->mo->hnext, NULL); + player->kartstuff[k_bananadrag] = 0; - if (player->kartstuff[k_eggmanheld]) - player->kartstuff[k_eggmanheld] = 0; - else if (player->kartstuff[k_itemheld] - && (dropall || (--player->kartstuff[k_itemamount] <= 0))) - { - player->kartstuff[k_itemamount] = player->kartstuff[k_itemheld] = 0; - player->kartstuff[k_itemtype] = KITEM_NONE; - } + if (player->kartstuff[k_eggmanheld]) + player->kartstuff[k_eggmanheld] = 0; + else if (player->kartstuff[k_itemheld] + && (dropall || (--player->kartstuff[k_itemamount] <= 0))) + { + player->kartstuff[k_itemamount] = player->kartstuff[k_itemheld] = 0; + player->kartstuff[k_itemtype] = KITEM_NONE; } } +static void K_DropPaperItem(player_t *player, boolean thunderhack, INT32 itemamount) +{ + const mobj_t *pmo = player->mo; + + if (P_MobjWasRemoved(pmo)) + { + return; + } + + mobj_t *drop = P_SpawnMobj(pmo->x, pmo->y, (pmo->z + pmo->height/2), MT_FLOATINGITEM); + P_SetScale(drop, drop->scale>>4); + + drop->destscale = (3*drop->destscale)/2; + + drop->angle = pmo->angle + ANGLE_90; + P_Thrust(drop, FixedAngle(P_RandomFixed()*180) + pmo->angle + ANGLE_90, 16*mapobjectscale); + drop->momz = P_MobjFlip(pmo)*3*mapobjectscale; + if (drop->eflags & MFE_UNDERWATER) + drop->momz = (117 * drop->momz) / 200; + + drop->threshold = (thunderhack ? KITEM_THUNDERSHIELD : player->kartstuff[k_itemtype]); + drop->movecount = itemamount; + + drop->flags |= MF_NOCLIPTHING; +} + // For getting EXTRA hit! void K_DropItems(player_t *player) { - boolean thunderhack = (player->kartstuff[k_curshield] && player->kartstuff[k_itemtype] == KITEM_THUNDERSHIELD); + const boolean thunderhack = (player->kartstuff[k_curshield] && player->kartstuff[k_itemtype] == KITEM_THUNDERSHIELD); if (thunderhack) player->kartstuff[k_itemtype] = KITEM_NONE; K_DropHnextList(player); - if (!P_MobjWasRemoved(player->mo) && player->kartstuff[k_itemamount]) + if (player->kartstuff[k_itemamount]) { - mobj_t *drop = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height/2, MT_FLOATINGITEM); - P_SetScale(drop, drop->scale>>4); - drop->destscale = (3*drop->destscale)/2; - - drop->angle = player->mo->angle + ANGLE_90; - P_Thrust(drop, - FixedAngle(P_RandomFixed()*180) + player->mo->angle + ANGLE_90, - 16*mapobjectscale); - drop->momz = P_MobjFlip(player->mo)*3*mapobjectscale; - if (drop->eflags & MFE_UNDERWATER) - drop->momz = (117 * drop->momz) / 200; - - drop->threshold = (thunderhack ? KITEM_THUNDERSHIELD : player->kartstuff[k_itemtype]); - drop->movecount = player->kartstuff[k_itemamount]; - - drop->flags |= MF_NOCLIPTHING; + K_DropPaperItem(player, thunderhack, player->kartstuff[k_itemamount]); } K_StripItems(player); @@ -4658,7 +4667,7 @@ void K_DropKitchenSink(player_t *player) return; if (player->mo->hnext->type != MT_SINK_SHIELD) - return; //so we can just call this function regardless of what is being held + return; // so we can just call this function regardless of what is being held P_KillMobj(player->mo->hnext, NULL, NULL); @@ -4934,8 +4943,10 @@ static void K_MoveHeldObjects(player_t *player) cur->momx = FixedMul(FINECOSINE(cur->angle>>ANGLETOFINESHIFT), cur->extravalue1); cur->momy = FixedMul(FINESINE(cur->angle>>ANGLETOFINESHIFT), cur->extravalue1); cur->flags &= ~MF_NOCLIPTHING; + if (!P_TryMove(cur, player->mo->x + cur->momx, player->mo->y + cur->momy, true)) P_SlideMove(cur, true); + if (P_IsObjectOnGround(player->mo)) { if (P_MobjFlip(cur) > 0) From d8ffffd86eca133c575af291ba08f86aeaaec576 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jun 2026 20:52:11 +0200 Subject: [PATCH 13/39] replace non valid sidenum magic number with what dsda-doom uses --- src/doomdata.h | 4 +++- src/hardware/hw_bsp.c | 2 +- src/hardware/hw_cache.c | 2 +- src/lua_maplib.c | 2 +- src/p_maputl.cpp | 4 ++-- src/p_saveg.c | 10 ++++++---- src/p_setup.c | 20 ++++++++++---------- src/p_spec.c | 18 +++++++++--------- src/r_defs.h | 2 +- src/r_segs.cpp | 2 +- src/r_splats.c | 2 +- 11 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/doomdata.h b/src/doomdata.h index 2f5e014c7..77dd84c50 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -81,10 +81,12 @@ typedef struct INT16 flags; INT16 special; INT16 tag; - // sidenum[1] will be 0xffff if one sided + // sidenum[1] will be NO_INDEX if one sided UINT16 sidenum[2]; } ATTRPACK maplinedef_t; +#define NO_INDEX 0xffff + // // LineDef attributes. // diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 79069857c..77f66d308 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -373,7 +373,7 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) if (!gl_maphashorizonlines && line->special == HORIZONSPECIAL) gl_maphashorizonlines = true; - if (line->sidenum[1] != 0xffff) + if (line->sidenum[1] != NO_INDEX) { if (sides[line->sidenum[0]].sector == sides[line->sidenum[1]].sector) { diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index d7c25bf3d..9300cbe81 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -729,7 +729,7 @@ static void HWR_PrecacheLevelTextures(void) for (j = 0; j < 2; j++) { // check if single-sided linedef - if (line->sidenum[j] == 0xffff) + if (line->sidenum[j] == NO_INDEX) continue; const side_t *side = &sides[line->sidenum[j]]; diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 279b02883..87639b77b 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -652,7 +652,7 @@ static int line_get(lua_State *L) LUA_PushUserdata(L, &sides[line->sidenum[0]], META_SIDE); return 1; case line_backside: // backside - if (line->sidenum[1] == 0xffff) + if (line->sidenum[1] == NO_INDEX) return 0; LUA_PushUserdata(L, &sides[line->sidenum[1]], META_SIDE); return 1; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 38e350409..d9f22c28a 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -242,7 +242,7 @@ void P_CameraLineOpening(line_t *linedef) sector_t *back; fixed_t frontfloor, frontceiling, backfloor, backceiling; - if (linedef->sidenum[1] == 0xffff) + if (linedef->sidenum[1] == NO_INDEX) { // single sided line openrange = 0; @@ -398,7 +398,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) { sector_t *front, *back; - if (linedef->sidenum[1] == 0xffff) + if (linedef->sidenum[1] == NO_INDEX) { // single sided line openrange = 0; diff --git a/src/p_saveg.c b/src/p_saveg.c index 667ee5c47..0d8ebd713 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -691,7 +691,7 @@ static void ArchiveLines(savebuffer_t *save) if (spawnli->special == 321 || spawnli->special == 322) // only reason li->callcount would be non-zero is if either of these are involved diff |= LD_CLLCOUNT; - if (li->sidenum[0] != 0xffff) + if (li->sidenum[0] != NO_INDEX) { si = &sides[li->sidenum[0]]; spawnsi = &spawnsides[li->sidenum[0]]; @@ -706,7 +706,8 @@ static void ArchiveLines(savebuffer_t *save) if (si->midtexture != spawnsi->midtexture) diff |= LD_S1MIDTEX; } - if (li->sidenum[1] != 0xffff) + + if (li->sidenum[1] != NO_INDEX) { si = &sides[li->sidenum[1]]; spawnsi = &spawnsides[li->sidenum[1]]; @@ -786,6 +787,7 @@ static void UnArchiveFFloors(savebuffer_t *save, const sector_t *ss) I_Error("Sector does not have any ffloors!"); fflr_i = READUINT16(save->p); // get first modified ffloor's number ready + for (;;) // for some reason the usual for (rover = x; ...) thing doesn't work here? { if (fflr_i == 0xffff) // end of modified ffloors list, let's stop already @@ -3510,7 +3512,7 @@ static void P_ReloadSaveLevelData(void) li->firsttag = spawnli->firsttag; li->nexttag = spawnli->nexttag; - if (li->sidenum[0] != 0xffff) + if (li->sidenum[0] != NO_INDEX) { si = &sides[li->sidenum[0]]; spawnsi = &spawnsides[li->sidenum[0]]; @@ -3521,7 +3523,7 @@ static void P_ReloadSaveLevelData(void) si->midtexture = spawnsi->midtexture; } - if (li->sidenum[1] != 0xffff) + if (li->sidenum[1] != NO_INDEX) { si = &sides[li->sidenum[1]]; spawnsi = &spawnsides[li->sidenum[1]]; diff --git a/src/p_setup.c b/src/p_setup.c index aee747626..3af2324a3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1001,9 +1001,9 @@ static void P_InitializeLinedef(line_t *ld) // cph 2002/07/20 - these errors are fatal if not fixed, so apply them for (j = 0; j < 2; j++) { - if (ld->sidenum[j] != 0xffff && ld->sidenum[j] >= (UINT16)numsides) + if (ld->sidenum[j] != NO_INDEX && ld->sidenum[j] >= (UINT16)numsides) { - ld->sidenum[j] = 0xffff; + ld->sidenum[j] = NO_INDEX; CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has out-of-range sidedef number\n", sizeu1((size_t)(ld - lines))); } } @@ -1011,14 +1011,14 @@ static void P_InitializeLinedef(line_t *ld) ld->firsttag = ld->nexttag = -1; // killough 11/98: fix common wad errors (missing sidedefs): - if (ld->sidenum[0] == 0xffff) + if (ld->sidenum[0] == NO_INDEX) { ld->sidenum[0] = 0; // Substitute dummy sidedef for missing right side // cph - print a warning about the bug CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s missing first sidedef\n", sizeu1((size_t)(ld - lines))); } - if ((ld->sidenum[1] == 0xffff) && (ld->flags & ML_TWOSIDED)) + if ((ld->sidenum[1] == NO_INDEX) && (ld->flags & ML_TWOSIDED)) { ld->flags &= ~ML_TWOSIDED; // Clear 2s flag for missing left side // cph - print a warning about the bug @@ -1026,9 +1026,9 @@ static void P_InitializeLinedef(line_t *ld) } // killough 4/4/98: support special sidedef interpretation below - if (ld->sidenum[0] != 0xffff && ld->special) + if (ld->sidenum[0] != NO_INDEX && ld->special) sides[ld->sidenum[0]].special = ld->special; - if (ld->sidenum[1] != 0xffff && ld->special) + if (ld->sidenum[1] != NO_INDEX && ld->special) sides[ld->sidenum[1]].special = ld->special; } @@ -1061,10 +1061,10 @@ static void P_LoadLineDefs2(void) for (; i--; ld++) { ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here - ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : NULL; + ld->backsector = ld->sidenum[1] != NO_INDEX ? sides[ld->sidenum[1]].sector : NULL; // Repeat count for midtexture - if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff)) + if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != NO_INDEX)) { sides[ld->sidenum[0]].repeatcnt = (INT16)(((unsigned)sides[ld->sidenum[0]].textureoffset >> FRACBITS) >> 12); sides[ld->sidenum[0]].textureoffset = (((unsigned)sides[ld->sidenum[0]].textureoffset >> FRACBITS) & 2047) << FRACBITS; @@ -1080,13 +1080,13 @@ static void P_LoadLineDefs2(void) { size_t len = strlen(sides[ld->sidenum[0]].text)+1; - if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text) + if (ld->sidenum[1] != NO_INDEX && sides[ld->sidenum[1]].text) len += strlen(sides[ld->sidenum[1]].text); ld->text = Z_Malloc(len, PU_LEVEL, NULL); memcpy(ld->text, sides[ld->sidenum[0]].text, strlen(sides[ld->sidenum[0]].text)+1); - if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text) + if (ld->sidenum[1] != NO_INDEX && sides[ld->sidenum[1]].text) memcpy(ld->text+strlen(ld->text)+1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text)+1); } break; diff --git a/src/p_spec.c b/src/p_spec.c index 978c3041e..032fdbfbd 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -889,7 +889,7 @@ static boolean PolyDoor(line_t *line) pdd.angle = line->angle; // angle of motion pdd.distance = sides[line->sidenum[0]].rowoffset; - if (line->sidenum[1] != 0xffff) + if (line->sidenum[1] != NO_INDEX) pdd.delay = sides[line->sidenum[1]].textureoffset >> FRACBITS; // delay in tics else pdd.delay = 0; @@ -899,7 +899,7 @@ static boolean PolyDoor(line_t *line) pdd.speed = sides[line->sidenum[0]].textureoffset >> FRACBITS; // angular speed pdd.distance = sides[line->sidenum[0]].rowoffset >> FRACBITS; // angular distance - if (line->sidenum[1] != 0xffff) + if (line->sidenum[1] != NO_INDEX) pdd.delay = sides[line->sidenum[1]].textureoffset >> FRACBITS; // delay in tics else pdd.delay = 0; @@ -1989,8 +1989,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT32 position = (INT32)max(sides[line->sidenum[0]].midtexture, 0); UINT32 prefadems = (UINT32)max(sides[line->sidenum[0]].textureoffset >> FRACBITS, 0); UINT32 postfadems = (UINT32)max(sides[line->sidenum[0]].rowoffset >> FRACBITS, 0); - UINT8 fadetarget = (UINT8)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].textureoffset >> FRACBITS : 0, 0); - INT16 fadesource = (INT16)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].rowoffset >> FRACBITS : -1, -1); + UINT8 fadetarget = (UINT8)max((line->sidenum[1] != NO_INDEX) ? sides[line->sidenum[1]].textureoffset >> FRACBITS : 0, 0); + INT16 fadesource = (INT16)max((line->sidenum[1] != NO_INDEX) ? sides[line->sidenum[1]].rowoffset >> FRACBITS : -1, -1); // Seek offset from current song position if (line->flags & ML_EFFECT1) @@ -2504,7 +2504,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) var1 = sides[line->sidenum[0]].toptexture; //(line->dx>>FRACBITS)-1; - if (line->sidenum[1] != 0xffff && line->flags & ML_BLOCKMONSTERS) // read power from back sidedef + if (line->sidenum[1] != NO_INDEX && line->flags & ML_BLOCKMONSTERS) // read power from back sidedef var2 = sides[line->sidenum[1]].toptexture; else if (line->flags & ML_NOCLIMB) // 'Infinite' var2 = UINT16_MAX; @@ -2633,7 +2633,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (always || this->bottomtexture) this->bottomtexture = set->bottomtexture; - if (lines[linenum].sidenum[1] == 0xffff) + if (lines[linenum].sidenum[1] == NO_INDEX) continue; // One-sided stops here. // Back side @@ -2682,7 +2682,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) sector_t *sec; mobj_t *thing; - if (line->sidenum[1] != 0xffff) + if (line->sidenum[1] != NO_INDEX) state = (statenum_t)sides[line->sidenum[1]].toptexture; while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) @@ -6056,7 +6056,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) break; case 259: // Make-Your-Own FOF! - if (lines[i].sidenum[1] != 0xffff) + if (lines[i].sidenum[1] != NO_INDEX) { UINT8 *data; UINT16 b; @@ -6785,7 +6785,7 @@ static void P_SpawnScrollers(void) case 506: s = lines[i].sidenum[1]; - if (s != 0xffff) + if (s != NO_INDEX) Add_Scroller(sc_side, -sides[s].textureoffset, sides[s].rowoffset, -1, lines[i].sidenum[0], accel, 0); else CONS_Debug(DBG_GAMELOGIC, "Line special 506 (line #%s) missing 2nd side!\n", sizeu1(i)); diff --git a/src/r_defs.h b/src/r_defs.h index 217314028..680a8a9cc 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -430,7 +430,7 @@ typedef struct line_s INT16 tag; // Visual appearance: sidedefs. - UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided + UINT16 sidenum[2]; // sidenum[1] will be NO_INDEX if one-sided fixed_t alpha; // translucency UINT8 blendmode; // blendmode diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 26e5a582b..8460d4679 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -2206,7 +2206,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) topremap = (encoremap && !(curline->linedef->flags & ML_TFERLINE)); if ((linedef->flags & (ML_DONTPEGTOP) && (linedef->flags & ML_DONTPEGBOTTOM)) - && linedef->sidenum[1] != 0xffff) + && linedef->sidenum[1] != NO_INDEX) { // Special case... use offsets from 2nd side but only if it has a texture. side_t *def = &sides[linedef->sidenum[1]]; diff --git a/src/r_splats.c b/src/r_splats.c index bcef8cf24..5560477ba 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -131,7 +131,7 @@ void R_AddWallSplat(line_t *wallline, INT16 sectorside, const char *patchname, f // set the splat splat->patch = W_GetNumForName(patchname); sectorside ^= 1; - if (wallline->sidenum[sectorside] != 0xffff) + if (wallline->sidenum[sectorside] != NO_INDEX) { backsector = sides[wallline->sidenum[sectorside]].sector; From 363612c488a4971efb56832e628b91c91b63db5f Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jun 2026 16:52:33 +0200 Subject: [PATCH 14/39] port more checks from dsda-doom for invalid map data decided to have it i_error for now, not sure what exactly is the best approach here should we just "correct" some of those instead? vanilla probably just crashes anyways --- src/p_setup.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 124 insertions(+), 6 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 3af2324a3..a5769179c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -437,8 +437,41 @@ static void P_LoadSegs(UINT8 *data) for (i = 0; i < numsegs; i++, li++, ml++) { - li->v1 = &vertexes[SHORT(ml->v1)]; - li->v2 = &vertexes[SHORT(ml->v2)]; + INT16 v1, v2; + + v1 = SHORT(ml->v1); + v2 = SHORT(ml->v2); + + // e6y + // check and fix wrong references to non-existent vertexes + // see e1m9 @ NIVELES.WAD + // http://www.doomworld.com/idgames/index.php?id=12647 + if ((unsigned)v1 >= numvertexes || (unsigned)v2 >= numvertexes) + { + if ((unsigned)v1 >= numvertexes) + I_Error("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v1); + if ((unsigned)v2 >= numvertexes) + I_Error("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v2); + + /* + if (li->sidedef == &sides[li->linedef->sidenum[0]]) + { + li->v1 = lines[ml->linedef].v1; + li->v2 = lines[ml->linedef].v2; + } + else + { + li->v1 = lines[ml->linedef].v2; + li->v2 = lines[ml->linedef].v1; + } + */ + } + else + { + li->v1 = &vertexes[v1]; + li->v2 = &vertexes[v2]; + } + #ifdef HWRENDER if (rendermode == render_opengl) { @@ -455,14 +488,60 @@ static void P_LoadSegs(UINT8 *data) li->angle = (SHORT(ml->angle))<offset = (SHORT(ml->offset))<linedef); + + //e6y: check for wrong indexes + if ((unsigned)rawlinedef >= numlines) + { + I_Error("P_LoadSegs: seg %s references a non-existent linedef %d", sizeu1(i), (unsigned)rawlinedef); + } + ldef = &lines[rawlinedef]; li->linedef = ldef; - li->side = rawside = SHORT(ml->side); + rawside = SHORT(ml->side); + + //e6y: fix wrong side index + if (rawside != 0 && rawside != 1) + { + I_Error("P_LoadSegs: seg %s contains wrong side index %d.\n", sizeu1(i), rawside); + //rawside = 1; + } + + //e6y: check for wrong indexes + if (ldef->sidenum[rawside] >= numsides) + { + I_Error("P_LoadSegs: linedef %d for seg %s references a non-existent sidedef %d", rawlinedef, sizeu1(i), ldef->sidenum[rawside]); + } + + li->side = rawside; + li->sidedef = &sides[ldef->sidenum[rawside]]; - li->frontsector = sides[ldef->sidenum[rawside]].sector; + + /* cph 2006/09/30 - our frontsector can be the second side of the + * linedef, so must check for NO_INDEX in case we are incorrectly + * referencing the back of a 1S line */ + if (ldef->sidenum[rawside] == NO_INDEX) + { + I_Error("P_LoadSegs: front of seg %s has no sidedef\n", sizeu1(i)); + //li->frontsector = 0; + } + else + { + li->frontsector = sides[ldef->sidenum[rawside]].sector; + } if (ldef->flags & ML_TWOSIDED) - li->backsector = sides[ldef->sidenum[rawside^1]].sector; + { + if (ldef->sidenum[rawside^1] == NO_INDEX) + { + I_Error("P_LoadSegs: back of seg %s has no sidedef while being marked as double sided\n", sizeu1(i)); + // this is wrong + //li->backsector = GetSectorAtNullAddress(); + } + else + { + li->backsector = sides[ldef->sidenum[rawside^1]].sector; + } + } P_UpdateSegLightOffset(li); } @@ -738,7 +817,33 @@ static void P_LoadNodes(UINT8 *data) for (j = 0; j < 2; j++) { - no->children[j] = SHORT(mn->children[j]); + UINT16 child; + + child = SHORT(mn->children[j]); + + if (child & NF_SUBSECTOR) + { + // Convert to extended type + child &= ~NF_SUBSECTOR; + + // haleyjd 11/06/10: check for invalid subsector reference + if (child >= numsubsectors) + { + I_Error("P_LoadNodes: BSP tree %s references invalid subsector %d\n", sizeu1(i), child); + //child = 0; + } + + child |= NF_SUBSECTOR; + } + else if (child >= numnodes) + { + I_Error("P_LoadNodes: BSP node %s references invalid node.\n", sizeu1(i)); + //I_Error("P_LoadNodes: BSP node %d references invalid node %d.\n", sizeu1(i), Index(((node_t *)no->children[j]))); + //child = 0; + } + + no->children[j] = child; + for (k = 0; k < 4; k++) no->bbox[j][k] = SHORT(mn->bbox[j][k])<firstline >= numsegs) + { CorruptMapError(va("P_GroupLines: ss->firstline invalid " "(subsector %s, firstline refers to %d of %s)", sizeu1(i), ss->firstline, sizeu2(numsegs))); + } + seg = &segs[ss->firstline]; sidei = (size_t)(seg->sidedef - sides); + if (!seg->sidedef) + { CorruptMapError(va("P_GroupLines: seg->sidedef is NULL " "(subsector %s, firstline is %d)", sizeu1(i), ss->firstline)); + } + if (seg->sidedef - sides < 0 || seg->sidedef - sides > (UINT16)numsides) + { CorruptMapError(va("P_GroupLines: seg->sidedef refers to sidedef %s of %s " "(subsector %s, firstline is %d)", sizeu1(sidei), sizeu2(numsides), sizeu3(i), ss->firstline)); + } + if (!seg->sidedef->sector) + { CorruptMapError(va("P_GroupLines: seg->sidedef->sector is NULL " "(subsector %s, firstline is %d, sidedef is %s)", sizeu1(i), ss->firstline, sizeu1(sidei))); + } + ss->sector = seg->sidedef->sector; } From 2dacc333b5ffa4cd601e89b6182e9e0382c84396 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jun 2026 20:52:42 +0200 Subject: [PATCH 15/39] just set backsector to NULL if not in vanilla doom compat mode/overflow emulation GetSectorAtNullAddress will just return NULL, so we can do so aswell --- src/p_setup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index a5769179c..a7435c0c4 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -534,8 +534,7 @@ static void P_LoadSegs(UINT8 *data) if (ldef->sidenum[rawside^1] == NO_INDEX) { I_Error("P_LoadSegs: back of seg %s has no sidedef while being marked as double sided\n", sizeu1(i)); - // this is wrong - //li->backsector = GetSectorAtNullAddress(); + li->backsector = NULL; } else { From 568f29ed1c6fb44204131e1878b1da7d965c9209 Mon Sep 17 00:00:00 2001 From: entryway Date: Sat, 27 Mar 2010 19:34:43 +0000 Subject: [PATCH 16/39] Check for blockmap overflow in P_BlockLinesIterator. Under RANGECHECK define. --- src/p_maputl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index d9f22c28a..041bad1db 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -972,6 +972,10 @@ boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean (*func)(line_t *)) // First index is really empty, so +1 it. for (list = blockmaplump + offset + 1; *list != -1; list++) { +#ifdef RANGECHECK + if (*list < 0 || (UINT32)*list >= numlines) + I_Error("P_BlockLinesIterator: index >= numlines"); +#endif ld = &lines[*list]; if (ld->validcount == validcount) From 029c21eae822953a961a7627ee259de10fa21846 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jun 2026 20:53:49 +0200 Subject: [PATCH 17/39] correct map issues clientside MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit but be loud about it instead of I_Error´ing most of those would be fatal anyways, so screw vanilla desyncing if they crash eitherways --- src/g_game.c | 3 ++ src/p_saveg.c | 3 ++ src/p_setup.c | 103 +++++++++++++++++++++++++++++++++++++------------- src/p_setup.h | 3 ++ 4 files changed, 85 insertions(+), 27 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 22f811bc8..f720f98fd 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1310,6 +1310,7 @@ static void G_DoLoadLevel(boolean resetplayer) { // fail so reset game stuff Command_ExitGame_f(); + P_FreeCorruptMapWarnings(); return; } @@ -1343,6 +1344,8 @@ static void G_DoLoadLevel(boolean resetplayer) // clear hud messages remains (usually from game startup) CON_ClearHUD(); + // print any map errors now due to clearhud above :chaosleep: + P_PrintCorruptMapWarnings(); server_lagless = !cv_gentlemens.value; diff --git a/src/p_saveg.c b/src/p_saveg.c index 0d8ebd713..37fcf4c3e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3590,8 +3590,11 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, bool if (!P_SetupLevel(true, reloading)) { CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); + P_FreeCorruptMapWarnings(); return false; } + + P_PrintCorruptMapWarnings(); } else { diff --git a/src/p_setup.c b/src/p_setup.c index a7435c0c4..c8edf26de 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -188,6 +188,57 @@ FUNCNORETURN static ATTRNORETURN void CorruptMapError(const char *msg) I_Error("Invalid or corrupt map.\nLook in log file or text console for technical details."); } +static char **mapwarnings = NULL; +static size_t nummapwarnings = 0; + +// collect map errors we can fix clientside +// we then can print em when the map finishes loading +// so they actually appear and raise awareness shits fucked +// see G_DoLoadLevel as to why :chaosleep: +static void CorruptMapWarning(const char *msg) +{ +#ifdef PARANOIA + // just error out + I_Error("%sThis WILL crash Vanilla clients!\n", msg); +#endif + nummapwarnings++; + mapwarnings = Z_Realloc(mapwarnings, nummapwarnings * sizeof(*mapwarnings), PU_STATIC, NULL); + mapwarnings[nummapwarnings-1] = Z_StrDup(msg); +} + +void P_PrintCorruptMapWarnings(void) +{ + size_t i; + + if (!nummapwarnings) + return; + + for (i = 0; i < nummapwarnings; i++) + { + CONS_Alert(CONS_ERROR, "%sAttempting to fix... This WILL crash Vanilla clients!\n", mapwarnings[i]); + } + + P_FreeCorruptMapWarnings(); +} + +void P_FreeCorruptMapWarnings(void) +{ + size_t i; + + if (!nummapwarnings) + return; + + for (i = 0; i < nummapwarnings; i++) + { + Z_Free(mapwarnings[i]); + mapwarnings[i] = NULL; + } + + Z_Free(mapwarnings); + mapwarnings = NULL; + nummapwarnings = 0; +} + #define NUMLAPS_DEFAULT 3 static void P_ClearMapHeaderLighting(mapheader_lighting_t *lighting) @@ -449,11 +500,10 @@ static void P_LoadSegs(UINT8 *data) if ((unsigned)v1 >= numvertexes || (unsigned)v2 >= numvertexes) { if ((unsigned)v1 >= numvertexes) - I_Error("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v1); + CorruptMapWarning(va("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v1)); if ((unsigned)v2 >= numvertexes) - I_Error("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v2); + CorruptMapWarning(va("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v2)); - /* if (li->sidedef == &sides[li->linedef->sidenum[0]]) { li->v1 = lines[ml->linedef].v1; @@ -464,7 +514,6 @@ static void P_LoadSegs(UINT8 *data) li->v1 = lines[ml->linedef].v2; li->v2 = lines[ml->linedef].v1; } - */ } else { @@ -502,8 +551,8 @@ static void P_LoadSegs(UINT8 *data) //e6y: fix wrong side index if (rawside != 0 && rawside != 1) { - I_Error("P_LoadSegs: seg %s contains wrong side index %d.\n", sizeu1(i), rawside); - //rawside = 1; + CorruptMapWarning(va("P_LoadSegs: seg %s contains wrong side index %d.\n", sizeu1(i), rawside)); + rawside = 1; } //e6y: check for wrong indexes @@ -521,8 +570,8 @@ static void P_LoadSegs(UINT8 *data) * referencing the back of a 1S line */ if (ldef->sidenum[rawside] == NO_INDEX) { - I_Error("P_LoadSegs: front of seg %s has no sidedef\n", sizeu1(i)); - //li->frontsector = 0; + CorruptMapWarning(va("P_LoadSegs: front of seg %s has no sidedef\n", sizeu1(i))); + li->frontsector = NULL; } else { @@ -533,7 +582,7 @@ static void P_LoadSegs(UINT8 *data) { if (ldef->sidenum[rawside^1] == NO_INDEX) { - I_Error("P_LoadSegs: back of seg %s has no sidedef while being marked as double sided\n", sizeu1(i)); + CorruptMapWarning(va("P_LoadSegs: back of seg %s has no sidedef while being marked as double sided\n", sizeu1(i))); li->backsector = NULL; } else @@ -828,17 +877,17 @@ static void P_LoadNodes(UINT8 *data) // haleyjd 11/06/10: check for invalid subsector reference if (child >= numsubsectors) { - I_Error("P_LoadNodes: BSP tree %s references invalid subsector %d\n", sizeu1(i), child); - //child = 0; + CorruptMapWarning(va("P_LoadNodes: BSP tree %s references invalid subsector %d\n", sizeu1(i), child)); + child = 0; } child |= NF_SUBSECTOR; } else if (child >= numnodes) { - I_Error("P_LoadNodes: BSP node %s references invalid node.\n", sizeu1(i)); + CorruptMapWarning(va("P_LoadNodes: BSP node %s references invalid node.\n", sizeu1(i))); //I_Error("P_LoadNodes: BSP node %d references invalid node %d.\n", sizeu1(i), Index(((node_t *)no->children[j]))); - //child = 0; + child = 0; } no->children[j] = child; @@ -1852,16 +1901,11 @@ static boolean P_LoadRawBlockMap(UINT8 *data, size_t count) // http://www.doomworld.com/idgames/index.php?id=12935 if (!P_VerifyBlockMap(count)) { -#ifdef PARANOIA - I_Error("P_LoadBlockMap: erroneous BLOCKMAP lump may cause crashes.\n"); -#endif - CONS_Alert(CONS_ERROR, "P_LoadBlockMap: erroneous BLOCKMAP lump may cause crashes.\n"); - - //Z_Free(blockmaplump); - //blockmaplump = NULL; - //return false; // ideally we would just let the game rebuild the blockmap - // but this has a chance of desynching vanilla clients - // not sure whats worse honestly and i do not want to decide that :chaosleep: + CorruptMapWarning(va("P_LoadBlockMap: corrupted or invalid BLOCKMAP lump! Check the log for more information.\n")); + // vanilla WILL crash here anyways so just rebuild it ourselves + Z_Free(blockmaplump); + blockmaplump = NULL; + return false; } // clear out mobj chains @@ -2004,11 +2048,16 @@ static void P_LoadReject(UINT8 *data, size_t rejectsize) { if (rejectsize < neededsize) { -#ifdef PARANOIA - I_Error("REJECT is %s byte%s too small. REJECT might be invalid and crash vanilla clients!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); -#endif - CONS_Alert(CONS_ERROR, "REJECT is %s byte%s too small. REJECT might be invalid and crash vanilla clients!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); + CorruptMapWarning(va("P_LoadReject: REJECT is %s byte%s too small. REJECT might be invalid!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s")); +#ifdef COMPAT_VANILLA + // we can pad this and somewhat prevent desyncs + // probs not cool if the reject is from a completely different map + // but whatever allocsize = neededsize; +#else + rejectmatrix = NULL; + return; +#endif } rejectmatrix = Z_Calloc(allocsize, PU_LEVEL, NULL); // allocate memory for the reject matrix diff --git a/src/p_setup.h b/src/p_setup.h index c5ad15d44..1d986d925 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -114,6 +114,9 @@ size_t P_PrecacheLevelFlats(void); void P_AllocMapHeader(INT16 i); +void P_PrintCorruptMapWarnings(void); +void P_FreeCorruptMapWarnings(void); + #ifdef __cplusplus } // extern "C" #endif From 593540a3f9c73731847ce2a3fea5d8ca8db472ec Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jun 2026 20:56:53 +0200 Subject: [PATCH 18/39] add flag "COMPAT_VANILLA" undefine to enable features that are not vanilla compatible --- src/doomdef.h | 11 +++++++++++ src/p_spec.c | 2 ++ src/p_tick.c | 2 ++ 3 files changed, 15 insertions(+) diff --git a/src/doomdef.h b/src/doomdef.h index 69347f05a..69c072827 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -602,6 +602,9 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! +// undefine to enable fixes and features that are not vanilla compatible +#define COMPAT_VANILLA + //-- SATURN __ /// Detect if a client is on Saturn in the clientconfig. /// To seperately allow them to join or block joining from vanilla clients. @@ -666,6 +669,14 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #undef UPDATE_ALERT #endif +// overwrite some of those +// when not compiling in vanilla compat mode +#ifndef COMPAT_VANILLA + #define SATURNJOIN + #define SATURNPAK + #undef SEENAMES +#endif + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/p_spec.c b/src/p_spec.c index 032fdbfbd..38b075feb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4609,11 +4609,13 @@ void P_UpdateSpecials(void) // POINT LIMIT P_CheckPointLimit(); +#ifdef COMPAT_VANILLA // Dynamic slopeness // we run this here only when not joined midrace // for vanilla compat reasons :chaosleep: if (!midgamejoin) P_RunDynamicSlopes(); +#endif P_UpdateAnimFlats(); } diff --git a/src/p_tick.c b/src/p_tick.c index 3692f9205..d0d25be69 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -646,7 +646,9 @@ void P_Ticker(boolean run) if (run) { // Dynamic slopeness +#ifdef COMPAT_VANILLA if (midgamejoin) // only run here if we joined midgame to fix some desynchs +#endif P_RunDynamicSlopes(); PS_START_TIMING(ps_thinkertime); From cabd8baae5555c1753a6f92528dd130cbfa6d52f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:13:39 +0200 Subject: [PATCH 19/39] some P_MobjWasRemoved for non COMPAT_VANILLA builds --- src/k_kart.c | 12 ++++++++++-- src/p_inter.c | 11 +++++++++-- src/p_mobj.c | 26 ++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index cb4641849..c27c8ad73 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4693,7 +4693,11 @@ void K_RepairOrbitChain(mobj_t *orbit) } // Then recount to make sure item amount is correct - if (orbit->target && orbit->target->player) // !P_MobjWasRemoved(orbit->target) +#ifndef COMPAT_VANILLA + if (!P_MobjWasRemoved(orbit->target) && orbit->target->player) +#else + if (orbit->target && orbit->target->player) +#endif { INT32 num = 0; @@ -4710,7 +4714,11 @@ void K_RepairOrbitChain(mobj_t *orbit) prev->movedir = num; } - if (orbit->target) // !P_MobjWasRemoved(orbit->target) +#ifndef COMPAT_VANILLA + if (!P_MobjWasRemoved(orbit->target)) +#else + if (orbit->target) +#endif orbit->target->player->kartstuff[k_itemamount] = num; } } diff --git a/src/p_inter.c b/src/p_inter.c index 76e4d2e8b..48961c229 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1466,8 +1466,11 @@ static void P_UpdateRemovedOrbital(mobj_t *target, mobj_t *inflictor, mobj_t *so { // SRB2kart // I wish I knew a better way to do this - //if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) +#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 (target->target->player->kartstuff[k_eggmanheld] && target->type == MT_EGGMANITEM_SHIELD) target->target->player->kartstuff[k_eggmanheld] = 0; @@ -1480,7 +1483,11 @@ 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]) { - if (target->target->hnext) // !P_MobjWasRemoved(target->target->hnext)) +#ifndef COMPAT_VANILLA + if (!P_MobjWasRemoved(target->target->hnext)) +#else + if (target->target->hnext) +#endif K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; diff --git a/src/p_mobj.c b/src/p_mobj.c index 5e33a9803..b885e76dd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3372,7 +3372,11 @@ 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 return; P_MobjCheckWater(mobj); @@ -5614,7 +5618,11 @@ 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 return; oldscale = mobj->scale; //keep for adjusting stuff below @@ -8962,7 +8970,11 @@ 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 return false; P_MobjCheckWater(mobj); @@ -9168,8 +9180,11 @@ void P_MobjThinker(mobj_t *mobj) { P_TryMove(mobj, mobj->x, mobj->y, true); // Sets mo->standingslope correctly - //if (P_MobjWasRemoved(mobj)) +#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 return; P_ButteredSlope(mobj); @@ -9197,8 +9212,11 @@ void P_MobjThinker(mobj_t *mobj) } } - //if (P_MobjWasRemoved(mobj)) +#ifndef COMPAT_VANILLA + if (P_MobjWasRemoved(mobj)) +#else if (!mobj) +#endif return; // obligatory paranoia check // Can end up here if a player dies. @@ -9258,7 +9276,11 @@ void P_PushableThinker(mobj_t *mobj) I_Assert(!P_MobjWasRemoved(mobj)); +#ifndef COMPAT_VANILLA + if (P_MobjWasRemoved(mobj)) +#else if (!mobj) +#endif return; sec = mobj->subsector->sector; From 7c84dd56613f5969e04fdf14857a5d4cc1109a0e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:40:32 +0200 Subject: [PATCH 20/39] raise NUMMOBJFREESLOTS to 4096 on non vanilla compat build --- src/info.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/info.h b/src/info.h index c84d63214..59dd2daca 100644 --- a/src/info.h +++ b/src/info.h @@ -452,7 +452,11 @@ void A_SpawnFreshCopy(void *actor); extern boolean actionsoverridden[NUMACTIONS]; // ratio of states to sprites to mobj types is roughly 6 : 1 : 1 +#ifdef COMPAT_VANILLA #define NUMMOBJFREESLOTS 1024 +#else +#define NUMMOBJFREESLOTS 4096 // should be sufficient +#endif #define NUMSPRITEFREESLOTS NUMMOBJFREESLOTS #define NUMSTATEFREESLOTS (NUMMOBJFREESLOTS*8) From 2c8099e2283f3db976817f35374bfbd3948dfefe Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:41:13 +0200 Subject: [PATCH 21/39] make builds with more than 16 players undefine COMPAT_VANILLA --- src/doomdef.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/doomdef.h b/src/doomdef.h index 69c072827..d4c9d63fa 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -604,6 +604,10 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // undefine to enable fixes and features that are not vanilla compatible #define COMPAT_VANILLA +// if we build with 32 player (or more!) support we dont need to care vanilla compat +#if MAXPLAYERS > 16 +#undef COMPAT_VANILLA +#endif //-- SATURN __ /// Detect if a client is on Saturn in the clientconfig. From f6d3ab1f3a74837c40b67dfcadddaabb36aa3037 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jun 2026 21:02:34 +0200 Subject: [PATCH 22/39] more random style cleanup had those lying around in lugstuff branch --- src/d_clisrv.c | 2 +- src/d_netcmd.c | 5 +- src/g_demo.c | 111 ++++++++++---------- src/hu_stuff.c | 2 +- src/k_kart.c | 2 +- src/lua_hudlib.c | 21 ++-- src/p_floor.c | 4 +- src/p_inter.c | 25 +++-- src/p_map.c | 12 ++- src/p_mobj.c | 266 +++++++++++++++++++++++++---------------------- src/p_setup.c | 4 +- src/p_spec.c | 1 + 12 files changed, 248 insertions(+), 207 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index cabbc1227..8ad162f6e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4798,7 +4798,7 @@ void CL_RemoveSplitscreenPlayer(UINT8 p) // is there a game running boolean Playing(void) { - return (server && serverrunning) || (client && cl_mode == CL_CONNECTED); + return ((server && serverrunning) || (client && cl_mode == CL_CONNECTED)); } boolean SV_SpawnServer(void) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 61ba54002..ecb90f224 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1550,8 +1550,8 @@ static void SendNameAndColor(UINT8 splitplayer) // TODO: make those cvars arrays consvar_t *playercolor, *playername, *playerskin; consvar_t *colorvars[] = {&cv_playercolor, &cv_playercolor2, &cv_playercolor3, &cv_playercolor4}; - consvar_t *namevars[] = {&cv_playername, &cv_playername2, &cv_playername3, &cv_playername4}; - consvar_t *skinvars[] = {&cv_skin, &cv_skin2, &cv_skin3, &cv_skin4}; + consvar_t *namevars[] = {&cv_playername, &cv_playername2, &cv_playername3, &cv_playername4}; + consvar_t *skinvars[] = {&cv_skin, &cv_skin2, &cv_skin3, &cv_skin4}; playercolor = colorvars[splitplayer]; playername = namevars[splitplayer]; @@ -5490,7 +5490,6 @@ static void Name_OnChange(void) } SendNameAndColor(0); - } static void Name2_OnChange(void) diff --git a/src/g_demo.c b/src/g_demo.c index de6a1bb5d..1123aed69 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -447,7 +447,8 @@ void G_WriteDemoExtraData(void) { static UINT8 timeout = 0; - if (timeout) timeout--; + if (timeout) + timeout--; if (demo_writerng == 1 || (demo_writerng == 2 && timeout == 0)) { @@ -467,6 +468,7 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) if (!demobuf.p || !demo.deferstart) return; + ziptic = READUINT8(demobuf.p); if (ziptic & ZT_FWD) @@ -488,11 +490,12 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) // what in the actual fuck is this??? // SRB2kart: Copy-pasted from ticcmd building, removes that crappy demo cam - if (((players[displayplayers[0]].mo && players[displayplayers[0]].speed > 0) // Moving + const player_t *player = &players[displayplayers[0]]; + if (((player->mo && player->speed > 0) // Moving || (leveltime > starttime && (cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE)) // Rubber-burn turn - || (players[displayplayers[0]].kartstuff[k_respawn]) // Respawning - || (players[displayplayers[0]].spectator || objectplacing)) // Not a physical player - && !(players[displayplayers[0]].kartstuff[k_spinouttimer] && players[displayplayers[0]].kartstuff[k_sneakertimer])) // Spinning and boosting cancels out spinout + || (player->kartstuff[k_respawn]) // Respawning + || (player->spectator || objectplacing)) // Not a physical player + && !(player->kartstuff[k_spinouttimer] && player->kartstuff[k_sneakertimer])) // Spinning and boosting cancels out spinout localangle[0] += (cmd->angleturn<<16); if (!(demoflags & DF_GHOST) && *demobuf.p == DEMOMARKER) @@ -1344,7 +1347,7 @@ fadeghost: } else { - mobj = P_SpawnMobj(g->mo->x, g->mo->y, g->mo->z - FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK); + mobj = P_SpawnMobj(g->mo->x, g->mo->y, g->mo->z - FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height, 3*FRACUNIT), MT_THOK); mobj->sprite = states[mobjinfo[type].spawnstate].sprite; mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<tics = -1; // nope. @@ -1518,7 +1521,9 @@ void G_PreviewRewind(tic_t previewtime) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + player_t *player = &players[i]; + + if (!playeringame[i] || player->spectator) { if (info->playerinfo[i].player.mo) { @@ -1530,35 +1535,35 @@ void G_PreviewRewind(tic_t previewtime) if (!info->playerinfo[i].ingame || !info->playerinfo[i].player.mo) { - if (players[i].mo) - players[i].mo->flags2 |= MF2_DONTDRAW; + if (player->mo) + player->mo->flags2 |= MF2_DONTDRAW; continue; } - if (!players[i].mo) + if (!player->mo) continue; //@TODO spawn temp object to act as a player display - players[i].mo->flags2 &= ~MF2_DONTDRAW; + player->mo->flags2 &= ~MF2_DONTDRAW; - P_UnsetThingPosition(players[i].mo); + P_UnsetThingPosition(player->mo); #define TWEEN(pr) info->playerinfo[i].mobj.pr + FixedMul((INT32) (next_info->playerinfo[i].mobj.pr - info->playerinfo[i].mobj.pr), tweenvalue) - players[i].mo->x = TWEEN(x); - players[i].mo->y = TWEEN(y); - players[i].mo->z = TWEEN(z); - players[i].mo->angle = TWEEN(angle); + player->mo->x = TWEEN(x); + player->mo->y = TWEEN(y); + player->mo->z = TWEEN(z); + player->mo->angle = TWEEN(angle); #undef TWEEN - P_SetThingPosition(players[i].mo); + P_SetThingPosition(player->mo); - players[i].frameangle = info->playerinfo[i].player.frameangle + FixedMul((INT32) (next_info->playerinfo[i].player.frameangle - info->playerinfo[i].player.frameangle), tweenvalue); + player->frameangle = info->playerinfo[i].player.frameangle + FixedMul((INT32) (next_info->playerinfo[i].player.frameangle - info->playerinfo[i].player.frameangle), tweenvalue); - players[i].mo->sprite = info->playerinfo[i].mobj.sprite; - players[i].mo->frame = info->playerinfo[i].mobj.frame; + player->mo->sprite = info->playerinfo[i].mobj.sprite; + player->mo->frame = info->playerinfo[i].mobj.frame; - players[i].realtime = info->playerinfo[i].player.realtime; + player->realtime = info->playerinfo[i].player.realtime; for (j = 0; j < NUMKARTSTUFF; j++) - players[i].kartstuff[j] = info->playerinfo[i].player.kartstuff[j]; + player->kartstuff[j] = info->playerinfo[i].player.kartstuff[j]; } for (i = splitscreen; i >= 0; i--) @@ -1691,7 +1696,7 @@ void G_BeginRecording(void) return; } - memset(name,0,sizeof(name)); + memset(name, 0, sizeof(name)); demobuf.p = demobuf.buffer; demoflags = DF_GHOST|(multiplayer ? DF_MULTIPLAYER : (modeattacking<standings[count].skin = UINT8_MAX; @@ -2353,12 +2358,12 @@ void G_LoadDemoInfo(menudemo_t *pdemo) } // Color - memcpy(temp,extrainfo_p,16); + memcpy(temp, extrainfo_p, 16); extrainfo_p += 16; for (i = 0; i < MAXSKINCOLORS; i++) { - if (fasticmp(KartColor_Names[i],temp)) // SRB2kart + if (fasticmp(KartColor_Names[i], temp)) // SRB2kart { pdemo->standings[count].color = i; break; @@ -2827,15 +2832,15 @@ void G_DoPlayDemo(char *defdemoname) if (demo.version == 0x0001) { // Player name - memcpy(player_names[0],demobuf.p,16); + memcpy(player_names[0], demobuf.p, 16); demobuf.p += 16; // Skin - memcpy(skin,demobuf.p,16); + memcpy(skin, demobuf.p, 16); demobuf.p += 16; // Color - memcpy(color,demobuf.p,16); + memcpy(color, demobuf.p, 16); demobuf.p += 16; demobuf.p += 5; // Backwards compat - some stats @@ -2868,7 +2873,7 @@ void G_DoPlayDemo(char *defdemoname) // Set color for (i = 0; i < MAXSKINCOLORS; i++) { - if (fasticmp(KartColor_Names[i],color)) // SRB2kart + if (fasticmp(KartColor_Names[i], color)) // SRB2kart { players[0].skincolor = i; break; @@ -2888,9 +2893,9 @@ void G_DoPlayDemo(char *defdemoname) return; } - memset(&oldcmd,0,sizeof(oldcmd)); - memset(&oldghost,0,sizeof(oldghost)); - memset(&ghostext,0,sizeof(ghostext)); + memset(&oldcmd, 0, sizeof(oldcmd)); + memset(&oldghost, 0, sizeof(oldghost)); + memset(&ghostext, 0, sizeof(ghostext)); CONS_Alert(CONS_WARNING, M_GetText("Demo version does not match game version. Desyncs may occur.\n")); @@ -2994,16 +2999,16 @@ void G_DoPlayDemo(char *defdemoname) players[p].spectator = spectator; // Name - memcpy(player_names[p],demobuf.p,16); + memcpy(player_names[p], demobuf.p, 16); demobuf.p += 16; // Skin - memcpy(skin,demobuf.p,16); + memcpy(skin, demobuf.p, 16); demobuf.p += 16; SetPlayerSkin(p, skin); // Color - memcpy(color,demobuf.p,16); + memcpy(color, demobuf.p, 16); demobuf.p += 16; for (i = 0; i < MAXSKINCOLORS; i++) @@ -3221,15 +3226,15 @@ void G_AddGhost(char *defdemoname) if (ghostversion == 0x0001) { // Player name (TODO: Display this somehow if it doesn't match cv_playername!) - memcpy(name, p,16); + memcpy(name, p, 16); p += 16; // Skin - memcpy(skin, p,16); + memcpy(skin, p, 16); p += 16; // Color - memcpy(color, p,16); + memcpy(color, p, 16); p += 16; // Ghosts do not have a player structure to put this in. @@ -3381,7 +3386,7 @@ void G_AddGhost(char *defdemoname) for (i = 0; i < MAXSKINCOLORS; i++) { - if (fasticmp(KartColor_Names[i],color)) // SRB2kart + if (fasticmp(KartColor_Names[i], color)) // SRB2kart { gh->mo->color = (UINT8)i; break; @@ -3473,7 +3478,7 @@ void G_UpdateStaffGhostName(lumpnum_t l) if (ghostversion == 0x0001) { // Player name - memcpy(dummystaffname, p,16); + memcpy(dummystaffname, p, 16); dummystaffname[16] = '\0'; return; // Not really a failure but whatever } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 2c509080b..82b0a74af 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -966,7 +966,7 @@ void HU_Ticker(void) size_t i = 0; // handle spam while we're at it: - for(; (i < MAXPLAYERS); i++) + for (; (i < MAXPLAYERS); i++) { if (stop_spamming[i] > 0) stop_spamming[i]--; diff --git a/src/k_kart.c b/src/k_kart.c index c27c8ad73..e30496716 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4629,7 +4629,7 @@ void K_DropRocketSneaker(player_t *player) while ((shoe = shoe->hnext) && !P_MobjWasRemoved(shoe)) { if (shoe->type != MT_ROCKETSNEAKER) - return; //woah, not a rocketsneaker, bail! safeguard in case this gets used when you're holding non-rocketsneakers + return; // woah, not a rocketsneaker, bail! safeguard in case this gets used when you're holding non-rocketsneakers shoe->flags2 &= ~MF2_DONTDRAW; shoe->flags &= ~MF_NOGRAVITY; diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 444733097..78a7a5e19 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -644,20 +644,22 @@ static int libd_drawScaled(lua_State *L) // KART: draw patch on minimap from x, y coordinates on the map static int libd_drawOnMinimap(lua_State *L) { - fixed_t x, y, scale; // coordinates of the object - patch_t *patch; // patch we want to draw - UINT8 *colormap = NULL; // do we want to colormap this patch? - boolean centered; // the patch is centered and doesn't need readjusting on x/y coordinates. + fixed_t x, y, scale; // coordinates of the object + patch_t *patch; // patch we want to draw + UINT8 *colormap = NULL; // do we want to colormap this patch? + boolean centered; // the patch is centered and doesn't need readjusting on x/y coordinates. huddrawlist_h list; - patch_t *AutomapPic = NULL; drawinfo_t info; + // variables used to replicate k_kart's mmap drawer: + patch_t *AutomapPic; + // variables used for actually drawing the icon: INT32 splitflags, minimaptrans; fixed_t amnumxpos, amnumypos; fixed_t amxpos, amypos; INT32 mm_x, mm_y; - fixed_t patchw = 0, patchh = 0; + fixed_t patchw, patchh; HUDONLY // only run this function in hud hooks @@ -722,8 +724,11 @@ static int libd_drawOnMinimap(lua_State *L) mm_y -= AutomapPic->topoffset; - // patch is supposedly already centered, don't butt in. - if (!centered) + if (centered) + { + patchw = patchh = 0; // patch is supposedly already centered, don't butt in. + } + else { // scale patch coords patchw = (patch->width * scale / 2); diff --git a/src/p_floor.c b/src/p_floor.c index 29f872745..5417029e4 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2338,7 +2338,7 @@ void T_RaiseSector(levelspecthink_t *raise) fixed_t origspeed = raise->vars[3]; // Slow down as you get closer to the bottom - raise->vars[3] = FixedMul(raise->vars[3],FixedDiv(raise->sector->ceilingheight - raise->vars[7], (raise->vars[5] - raise->vars[7])>>5)); + raise->vars[3] = FixedMul(raise->vars[3], FixedDiv(raise->sector->ceilingheight - raise->vars[7], (raise->vars[5] - raise->vars[7])>>5)); if (raise->vars[3] <= origspeed/16) raise->vars[3] = origspeed/16; @@ -2349,7 +2349,7 @@ void T_RaiseSector(levelspecthink_t *raise) { fixed_t origspeed = raise->vars[3]; // Slow down as you get closer to the top - raise->vars[3] = FixedMul(raise->vars[3],FixedDiv(raise->vars[5] - raise->sector->ceilingheight, (raise->vars[5] - raise->vars[7])>>5)); + raise->vars[3] = FixedMul(raise->vars[3], FixedDiv(raise->vars[5] - raise->sector->ceilingheight, (raise->vars[5] - raise->vars[7])>>5)); if (raise->vars[3] <= origspeed/16) raise->vars[3] = origspeed/16; diff --git a/src/p_inter.c b/src/p_inter.c index 48961c229..a2948d01b 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1701,7 +1701,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) else prandom = P_RandomKey(5); // No placable object, just use a random number. - switch(prandom) + switch (prandom) { default: item = MT_BUNNY; break; case 1: item = MT_BIRD; break; @@ -2245,16 +2245,26 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; // well no clue but this may happen ig - if (!target || (target->health <= 0)) +#ifndef COMPAT_VANILLA + if (P_MobjWasRemoved(target)) +#else + if (!target) +#endif + return false; + + if (target->health <= 0) return false; // Spectator handling if (netgame) { - if (damage == DMG_SPECTATOR && target->player && target->player->spectator) - damage = DMG_INSTAKILL; - else if (target->player && target->player->spectator) - return false; + if (target->player && target->player->spectator) + { + if (damage == DMG_SPECTATOR) + damage = DMG_INSTAKILL; + else + return false; + } if (source && source->player && source->player->spectator) return false; @@ -2360,6 +2370,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da { if (source == target) return false; // Don't hit yourself with your own paraloop, baka + if (source && source->player && !cv_friendlyfire.value && (gametype == GT_COOP || (G_GametypeHasTeams() && target->player->ctfteam == source->player->ctfteam))) @@ -2409,7 +2420,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da else if (player->kartstuff[k_invincibilitytimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->powers[pw_flashing]) { - if (!force) // shoulddamage bypasses all of that. + if (!force) // shoulddamage bypasses all of that. { K_DoInstashield(player); return false; diff --git a/src/p_map.c b/src/p_map.c index e4a7323ca..08444f4cd 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -719,11 +719,11 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->type != MT_PLAYER) return true; - if (thing->player && thing->player->powers[pw_flashing]) - return true; - - if (thing->type == MT_PLAYER && thing->player) + if (thing->player) { + if (thing->player->powers[pw_flashing]) + return true; + if (tmthing->state == &states[S_MINEEXPLOSION1]) K_ExplodePlayer(thing->player, tmthing->target, tmthing); else @@ -1077,6 +1077,7 @@ static boolean PIT_CheckThing(mobj_t *thing) thing->momy -= FixedMul(PUSHACCEL, thing->scale); tmthing->momy += FixedMul(PUSHACCEL, thing->scale); } + if (tmthing->momx > 0 && tmthing->momx > FixedMul(4*FRACUNIT, thing->scale) && tmthing->momx > thing->momx) { @@ -1094,6 +1095,7 @@ static boolean PIT_CheckThing(mobj_t *thing) thing->momx = FixedMul(thing->info->speed, thing->scale); else if (thing->momx < -FixedMul(thing->info->speed, thing->scale)) thing->momx = -FixedMul(thing->info->speed, thing->scale); + if (thing->momy > FixedMul(thing->info->speed, thing->scale)) thing->momy = FixedMul(thing->info->speed, thing->scale); else if (thing->momy < -FixedMul(thing->info->speed, thing->scale)) @@ -1105,6 +1107,7 @@ static boolean PIT_CheckThing(mobj_t *thing) tmthing->momx = FixedMul(4*FRACUNIT, thing->scale); else if (tmthing->momx < FixedMul(-4*FRACUNIT, thing->scale)) tmthing->momx = FixedMul(-4*FRACUNIT, thing->scale); + if (tmthing->momy > FixedMul(4*FRACUNIT, thing->scale)) tmthing->momy = FixedMul(4*FRACUNIT, thing->scale); else if (tmthing->momy < FixedMul(-4*FRACUNIT, thing->scale)) @@ -1126,6 +1129,7 @@ static boolean PIT_CheckThing(mobj_t *thing) P_TouchSpecialThing(thing, tmthing, true); // can remove thing return true; } + // check again for special pickup if (tmthing->flags & MF_SPECIAL && thing->player) { diff --git a/src/p_mobj.c b/src/p_mobj.c index b885e76dd..5d4a1bd6c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1249,7 +1249,6 @@ static void P_PushableCheckBustables(mobj_t *mo) if (rover->master->frontsector->crumblestate) continue; - topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); // Height checks @@ -1261,29 +1260,34 @@ static void P_PushableCheckBustables(mobj_t *mo) if (mo->z+mo->height > bottomheight) continue; } - else if (rover->flags & FF_SPINBUST) - { - if (mo->z+mo->momz > topheight) - continue; - - if (mo->z+mo->height < bottomheight) - continue; - } - else if (rover->flags & FF_SHATTER) - { - if (mo->z+mo->momz > topheight) - continue; - - if (mo->z+mo->momz + mo->height < bottomheight) - continue; - } else { - if (mo->z >= topheight) - continue; + topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); - if (mo->z+mo->height < bottomheight) - continue; + if (rover->flags & FF_SPINBUST) + { + if (mo->z+mo->momz > topheight) + continue; + + if (mo->z+mo->height < bottomheight) + continue; + } + else if (rover->flags & FF_SHATTER) + { + if (mo->z+mo->momz > topheight) + continue; + + if (mo->z+mo->momz + mo->height < bottomheight) + continue; + } + else + { + if (mo->z >= topheight) + continue; + + if (mo->z+mo->height < bottomheight) + continue; + } } EV_CrumbleChain(node->m_sector, rover); @@ -2950,7 +2954,8 @@ void P_MobjCheckWater(mobj_t *mobj) if ((mobj->eflags & MFE_VERTICALFLIP) && mobj->ceilingz-mobj->waterbottom <= FixedMul(mobj->info->height, mobj->scale)>>1) return; - if ((mobj->eflags & MFE_GOOWATER || wasingoo)) { // Decide what happens to your momentum when you enter/leave goopy water. + if ((mobj->eflags & MFE_GOOWATER || wasingoo)) // Decide what happens to your momentum when you enter/leave goopy water. + { if (P_MobjFlip(mobj)*mobj->momz < 0) // You are entering the goo? mobj->momz = FixedMul(mobj->momz, FixedDiv(2*FRACUNIT, 5*FRACUNIT)); // kill momentum significantly, to make the goo feel thick. } @@ -2964,6 +2969,7 @@ void P_MobjCheckWater(mobj_t *mobj) { // Spawn a splash mobj_t *splish; + if (mobj->eflags & MFE_VERTICALFLIP) { splish = P_SpawnMobj(mobj->x, mobj->y, mobj->waterbottom-FixedMul(mobjinfo[MT_SPLISH].height, mobj->scale), MT_SPLISH); @@ -2972,6 +2978,7 @@ void P_MobjCheckWater(mobj_t *mobj) } else splish = P_SpawnMobj(mobj->x, mobj->y, mobj->watertop, MT_SPLISH); + splish->destscale = mobj->scale; P_SetScale(splish, mobj->scale); } @@ -5165,9 +5172,9 @@ static void P_Boss9Thinker(mobj_t *mobj) { // Stunned after vector form if (mobj->movedir > ANGLE_180) - mobj->angle -= FixedAngle(FixedMul(AngleFixed(InvAngle(mobj->movedir)),FixedDiv(mobj->reactiontime<angle -= FixedAngle(FixedMul(AngleFixed(InvAngle(mobj->movedir)), FixedDiv(mobj->reactiontime<angle += FixedAngle(FixedMul(AngleFixed(mobj->movedir),FixedDiv(mobj->reactiontime<angle += FixedAngle(FixedMul(AngleFixed(mobj->movedir), FixedDiv(mobj->reactiontime<reactiontime--; @@ -5209,99 +5216,99 @@ static void P_Boss9Thinker(mobj_t *mobj) // It's time to attack! What are we gonna do?! switch(mobj->movecount) { - case 0: - default: - // Fly up and prepare for an attack! - // We have to charge up first, so let's go up into the air - P_SetMobjState(mobj, mobj->info->raisestate); - if (mobj->floorz >= mobj->target->floorz) - mobj->watertop = mobj->floorz + 256*FRACUNIT; - else - mobj->watertop = mobj->target->floorz + 256*FRACUNIT; - break; - - case 1: - { - // Okay, we're up? Good, time to gather energy... - if (mobj->health > mobj->info->damage) - { // No more bubble if we're broken (pinch phase) - mobj_t *shield = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_MSSHIELD_FRONT); - P_SetTarget(&mobj->tracer, shield); - P_SetTarget(&shield->target, mobj); - } - else - P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); - mobj->fuse = 4*TICRATE; - mobj->flags |= MF_PAIN; - if (mobj->info->attacksound) - S_StartSound(mobj, mobj->info->attacksound); - A_FaceTarget(mobj); - break; - } - - case 2: - // We're all charged and ready now! Unleash the fury!! - if (mobj->health > mobj->info->damage) - { - mobj_t *removemobj = mobj->tracer; - P_SetTarget(&mobj->tracer, mobj->hnext); - P_RemoveMobj(removemobj); - } - if (mobj->health <= mobj->info->damage) - { - // Attack 1: Pinball dash! - if (mobj->health == 1) - mobj->movedir = 0; + case 0: + default: + // Fly up and prepare for an attack! + // We have to charge up first, so let's go up into the air + P_SetMobjState(mobj, mobj->info->raisestate); + if (mobj->floorz >= mobj->target->floorz) + mobj->watertop = mobj->floorz + 256*FRACUNIT; else - mobj->movedir = 2; - if (mobj->info->seesound) - S_StartSound(mobj, mobj->info->seesound); - P_SetMobjState(mobj, mobj->info->seestate); - if (mobj->movedir == 2) - mobj->threshold = 16; // bounce 16 times - else - mobj->threshold = 32; // bounce 32 times - mobj->watertop = mobj->target->floorz + 16*FRACUNIT; - P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); - } - else + mobj->watertop = mobj->target->floorz + 256*FRACUNIT; + break; + + case 1: { - // Attack 2: Energy shot! - mobj->movedir = 1; - - if (mobj->health >= 8) - mobj->extravalue1 = 0; - else if (mobj->health >= 5) - mobj->extravalue1 = 2; - else if (mobj->health >= 4) - mobj->extravalue1 = 1; - else - mobj->extravalue1 = 3; - - switch(mobj->extravalue1) - { - case 0: // shoot once - case 2: // spread-shot - default: - mobj->threshold = 2; - break; - case 1: // shoot 3 times - mobj->threshold = 3*2; - break; - case 3: // shoot like a goddamn machinegun - mobj->threshold = 8*2; - break; + // Okay, we're up? Good, time to gather energy... + if (mobj->health > mobj->info->damage) + { // No more bubble if we're broken (pinch phase) + mobj_t *shield = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_MSSHIELD_FRONT); + P_SetTarget(&mobj->tracer, shield); + P_SetTarget(&shield->target, mobj); } + else + P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); + mobj->fuse = 4*TICRATE; + mobj->flags |= MF_PAIN; + if (mobj->info->attacksound) + S_StartSound(mobj, mobj->info->attacksound); + A_FaceTarget(mobj); + break; } - break; - case 3: - // Return to idle. - mobj->watertop = mobj->target->floorz + 32*FRACUNIT; - P_SetMobjState(mobj, mobj->info->spawnstate); - mobj->flags &= ~MF_PAIN; - mobj->fuse = 10*TICRATE; - break; + case 2: + // We're all charged and ready now! Unleash the fury!! + if (mobj->health > mobj->info->damage) + { + mobj_t *removemobj = mobj->tracer; + P_SetTarget(&mobj->tracer, mobj->hnext); + P_RemoveMobj(removemobj); + } + if (mobj->health <= mobj->info->damage) + { + // Attack 1: Pinball dash! + if (mobj->health == 1) + mobj->movedir = 0; + else + mobj->movedir = 2; + if (mobj->info->seesound) + S_StartSound(mobj, mobj->info->seesound); + P_SetMobjState(mobj, mobj->info->seestate); + if (mobj->movedir == 2) + mobj->threshold = 16; // bounce 16 times + else + mobj->threshold = 32; // bounce 32 times + mobj->watertop = mobj->target->floorz + 16*FRACUNIT; + P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); + } + else + { + // Attack 2: Energy shot! + mobj->movedir = 1; + + if (mobj->health >= 8) + mobj->extravalue1 = 0; + else if (mobj->health >= 5) + mobj->extravalue1 = 2; + else if (mobj->health >= 4) + mobj->extravalue1 = 1; + else + mobj->extravalue1 = 3; + + switch (mobj->extravalue1) + { + case 0: // shoot once + case 2: // spread-shot + default: + mobj->threshold = 2; + break; + case 1: // shoot 3 times + mobj->threshold = 3*2; + break; + case 3: // shoot like a goddamn machinegun + mobj->threshold = 8*2; + break; + } + } + break; + + case 3: + // Return to idle. + mobj->watertop = mobj->target->floorz + 32*FRACUNIT; + P_SetMobjState(mobj, mobj->info->spawnstate); + mobj->flags &= ~MF_PAIN; + mobj->fuse = 10*TICRATE; + break; } mobj->movecount++; mobj->movecount %= 4; @@ -5319,6 +5326,7 @@ static void P_Boss9Thinker(mobj_t *mobj) // Face your target angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); // absolute angle angle = (angle-mobj->angle); // relative angle + if (angle < ANGLE_180) mobj->angle += angle/8; else @@ -5330,18 +5338,19 @@ static void P_Boss9Thinker(mobj_t *mobj) || mobj->target->player->powers[pw_invulnerability] || mobj->target->player->powers[pw_super])) danger = false; - if (mobj->target->x+mobj->target->radius+abs(mobj->target->momx*2) < mobj->x-mobj->radius) + else if (mobj->target->x+mobj->target->radius+abs(mobj->target->momx*2) < mobj->x-mobj->radius) danger = false; - if (mobj->target->x-mobj->target->radius-abs(mobj->target->momx*2) > mobj->x+mobj->radius) + else if (mobj->target->x-mobj->target->radius-abs(mobj->target->momx*2) > mobj->x+mobj->radius) danger = false; - if (mobj->target->y+mobj->target->radius+abs(mobj->target->momy*2) < mobj->y-mobj->radius) + else if (mobj->target->y+mobj->target->radius+abs(mobj->target->momy*2) < mobj->y-mobj->radius) danger = false; - if (mobj->target->y-mobj->target->radius-abs(mobj->target->momy*2) > mobj->y+mobj->radius) + else if (mobj->target->y-mobj->target->radius-abs(mobj->target->momy*2) > mobj->y+mobj->radius) danger = false; - if (mobj->target->z+mobj->target->height+mobj->target->momz*2 < mobj->z) + else if (mobj->target->z+mobj->target->height+mobj->target->momz*2 < mobj->z) danger = false; - if (mobj->target->z+mobj->target->momz*2 > mobj->z+mobj->height) + else if (mobj->target->z+mobj->target->momz*2 > mobj->z+mobj->height) danger = false; + if (danger) { // An incoming attack is detected! What should we do?! @@ -5349,21 +5358,27 @@ static void P_Boss9Thinker(mobj_t *mobj) mobj->movedir = ANGLE_11hh - FixedAngle(FixedMul(AngleFixed(ANGLE_11hh), FixedDiv((mobj->info->spawnhealth - mobj->health)<info->spawnhealth-1)<movedir = InvAngle(mobj->movedir); + mobj->threshold = 6 + (FixedMul(24<info->spawnhealth - mobj->health)<info->spawnhealth-1)<>FRACBITS); + if (mobj->info->activesound) S_StartSound(mobj, mobj->info->activesound); if (mobj->info->painchance) P_SetMobjState(mobj, mobj->info->painchance); + return; } // Move normally: Approach the player using normal thrust and simulated friction. dist = P_AproxDistance(mobj->x-mobj->target->x, mobj->y-mobj->target->y); + P_Thrust(mobj, R_PointToAngle2(0, 0, mobj->momx, mobj->momy), -3*FRACUNIT/8); + if (dist < 64*FRACUNIT) P_Thrust(mobj, mobj->angle, -4*FRACUNIT); else if (dist > 180*FRACUNIT) P_Thrust(mobj, mobj->angle, FRACUNIT); + mobj->momz += P_AproxDistance(mobj->momx, mobj->momy)/12; // Move up higher the faster you're going. } } @@ -8671,14 +8686,15 @@ static boolean P_MobjRegularThink(mobj_t *mobj) { const angle_t fa = (i*FINEANGLES/16) & FINEMASK; ns = FixedMul(64 * FRACUNIT, mobj->scale); - x = mobj->x + FixedMul(FINESINE(fa),ns); - y = mobj->y + FixedMul(FINECOSINE(fa),ns); + x = mobj->x + FixedMul(FINESINE(fa), ns); + y = mobj->y + FixedMul(FINECOSINE(fa), ns); mo2 = P_SpawnMobj(x, y, z, MT_EXPLODE); ns = FixedMul(16 * FRACUNIT, mobj->scale); - mo2->momx = FixedMul(FINESINE(fa),ns); - mo2->momy = FixedMul(FINECOSINE(fa),ns); + mo2->momx = FixedMul(FINESINE(fa), ns); + mo2->momy = FixedMul(FINECOSINE(fa), ns); } + z -= FixedMul(32*FRACUNIT, mobj->scale); } P_SetMobjState(mobj, mobj->info->deathstate); @@ -8872,9 +8888,9 @@ static void P_IceBlockFuseThink(mobj_t *mobj) for (i = 0; i < 5; i++) { mobj_t *debris = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMK_ICEBLOCK_DEBRIS); - debris->angle = FixedAngle(P_RandomRange(0,360)<angle, P_RandomRange(3,18)*(FRACUNIT/4)); - debris->momz = P_RandomRange(4,8)<angle = FixedAngle(P_RandomRange(0, 360)<angle, P_RandomRange(3, 18)*(FRACUNIT/4)); + debris->momz = P_RandomRange(4, 8)< Date: Mon, 22 Jun 2026 23:10:28 +0200 Subject: [PATCH 23/39] add missing null terminator for player name on server info screen --- src/d_clisrv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8ad162f6e..7fb65d4d3 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1449,6 +1449,7 @@ static void CL_DrawConnectionStatus(void) if (playerinfo[i].node < 255) { strncpy(player_name, playerinfo[i].name, MAXPLAYERNAME); + player_name[MAXPLAYERNAME] = '\0'; // if we get a skin color // try to colourize the player name From 7ea95b44952841561e1136615ab060489bf61057 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 8 Jun 2020 00:08:07 -0400 Subject: [PATCH 24/39] Fix OSX null-pointer-arithmetic error --- src/hardware/r_opengl/r_opengl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index d3136cbfc..071e67f03 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2915,7 +2915,7 @@ void GL_CreateModelVBOs(model_t *model) } } -#define BUFFER_OFFSET(i) ((char*)(i)) +#define BUFFER_OFFSET(i) ((void*)(i)) void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface) { From fbae43f61ad30f297723edfc2d69ca6d280a3436 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jun 2026 00:10:25 +0200 Subject: [PATCH 25/39] move spinoutroll to k_hud hud thing for minimap so should be in there --- src/d_netcmd.h | 1 + src/g_game.h | 1 - src/k_hud.c | 3 +++ src/k_kart.c | 1 - src/r_main.cpp | 1 - 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index d16d2331f..46ec396ec 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -149,6 +149,7 @@ extern consvar_t cv_showminimapnames; extern consvar_t cv_showminimapfinished; extern consvar_t cv_minihead; extern consvar_t cv_showminimapangle; +extern consvar_t cv_spinoutroll; extern consvar_t cv_showlapemblem; diff --git a/src/g_game.h b/src/g_game.h index f1ed7834e..34496534e 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -121,7 +121,6 @@ extern consvar_t cv_sliptideroll; extern consvar_t cv_slamsound; extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; -extern consvar_t cv_spinoutroll; extern consvar_t cv_squishdance, cv_squishdancespeed; diff --git a/src/k_hud.c b/src/k_hud.c index 335e97340..0ad2d3b3f 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -98,6 +98,8 @@ consvar_t cv_showminimapfinished = {"showminimapfinished", "On", CV_SAVE, CV_OnO CV_PossibleValue_t minimapdot_cons_t[NUMMINIMAPDOTSTUFF]; consvar_t cv_showminimapangle = {"showminimapangle", "Off", CV_SAVE, minimapdot_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_spinoutroll = {"spinoutroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + static CV_PossibleValue_t posanim_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}}; consvar_t cv_posanim = {"postitionanimation", "On", CV_SAVE, posanim_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_smallposnum = {"smallpositionnumber", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -231,6 +233,7 @@ void K_RegisterKartHudStuff(void) CV_RegisterVar(&cv_showminimapnames); CV_RegisterVar(&cv_showminimapfinished); CV_RegisterVar(&cv_showminimapangle); + CV_RegisterVar(&cv_spinoutroll); CV_RegisterVar(&cv_showlapemblem); diff --git a/src/k_kart.c b/src/k_kart.c index e30496716..f7a3bdf9e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -67,7 +67,6 @@ 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_spinoutroll = {"spinoutroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //hardcode saltyhop mhhm static void saltyhop_onchange(void); diff --git a/src/r_main.cpp b/src/r_main.cpp index cf7df9088..5a7a1d23f 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1598,7 +1598,6 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_sliptideroll); CV_RegisterVar(&cv_sloperolldist); CV_RegisterVar(&cv_sparkroll); - CV_RegisterVar(&cv_spinoutroll); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); From cb8df4c3d005aaefa18bf72621ac38a13366272a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jun 2026 18:21:04 +0200 Subject: [PATCH 26/39] change how banana rotation throw stuff works noticed sloperoll does not properly work from certain angles so just reset rollangle if needed in K_RollMobjBySlopes since couldnt find a better place tbh --- src/k_kart.c | 31 ++++++++++++++++++++++++++----- src/p_mobj.c | 28 +++++++++++++++------------- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f7a3bdf9e..ad91b76c3 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3510,6 +3510,26 @@ boolean K_ShouldSlopeRoll(mobj_t *mobj) return K_CheckSlopeRollDist(mobj); } +// reset banan and eggbox rollangle when they´re on the ground +// if not cv_bananthrowroll option "+Onground" +static void K_ResetBananaRollangle(mobj_t* mo) +{ + if (cv_bananthrowroll.value != 1) + return; + + if (!mo->rollangle) + return; + + if (mo->type != MT_BANANA && mo->type != MT_EGGMANITEM) + return; + + // only reset if on ground + if (!P_IsObjectOnGround(mo)) + return; + + mo->rollangle = 0; +} + #define SLOPEROLL_DIV 3 void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) { @@ -3523,6 +3543,9 @@ void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) I_Assert(mo->subsector != NULL); I_Assert(mo->subsector->sector != NULL); + // kinda stupid but idk where else to put this + K_ResetBananaRollangle(mo); + if (!K_ShouldSlopeRoll(mo)) { mo->pitch_sprite = mo->roll_sprite = 0; @@ -3944,11 +3967,9 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map if (cv_bananthrowroll.value && (mapthing == MT_BANANA)) { - //mo->angle = FixedAngle(M_RandomRange(-180, 180) << FRACBITS); - if (cv_bananthrowroll.value == 1 && K_CheckSlopeRollDist(mo)) - mo->sloperoll = (angle_t)FixedAngle(M_RandomRange(-180, 180) << FRACBITS); // im lazy but this makes sure the banan goes back to upright when it lands lmao - else if (cv_bananthrowroll.value == 2) - mo->rollangle = (angle_t)FixedAngle(M_RandomRange(-180, 180) << FRACBITS); + const angle_t speen = (angle_t)FixedAngle(M_RandomRange(-180, 180) << FRACBITS); + //mo->angle = speen; + mo->rollangle = speen; } } diff --git a/src/p_mobj.c b/src/p_mobj.c index 5d4a1bd6c..12574c031 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6876,11 +6876,9 @@ static boolean P_MobjDeadThink(mobj_t *mobj) case MT_BANANA: if (cv_bananthrowroll.value) { - //mobj->angle -= spin; - if (cv_bananthrowroll.value == 1 && K_CheckSlopeRollDist(mobj)) - mobj->sloperoll += (angle_t)FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); // im lazy but this makes sure the banan goes back to upright when it lands lmao - else if (cv_bananthrowroll.value == 2) - mobj->rollangle += (angle_t)FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); + const angle_t speen = (angle_t)FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); + //mobj->angle -= speen; + mobj->rollangle += speen; } /* FALLTHRU */ case MT_ORBINAUT: @@ -7190,21 +7188,23 @@ static boolean P_MobjRegularThink(mobj_t *mobj) } case MT_BANANA: case MT_EGGMANITEM: - if (cv_bananthrowroll.value && !P_IsObjectOnGround(mobj)) + { + boolean grounded = P_IsObjectOnGround(mobj); + + if (cv_bananthrowroll.value && !grounded) { // tilt n tumble - //mobj->angle += spin; - - if (cv_bananthrowroll.value == 1 && K_CheckSlopeRollDist(mobj)) - mobj->sloperoll -= (angle_t)FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h); // im lazy but this makes sure the banan goes back to upright when it lands lmao - else if (cv_bananthrowroll.value == 2) - mobj->rollangle -= (angle_t)FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h); + const angle_t speen = (angle_t)FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); + //mobj->angle += speen; + mobj->rollangle -= speen; } mobj->friction = ORIG_FRICTION/4; + if (mobj->momx || mobj->momy) P_SpawnGhostMobj(mobj); - if (P_IsObjectOnGround(mobj) && mobj->health > 1) + + if (grounded && mobj->health > 1) { S_StartSound(mobj, mobj->info->activesound); mobj->momx = mobj->momy = 0; @@ -7215,7 +7215,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (mobj->threshold > 0) mobj->threshold--; + break; + } case MT_SPB: indirectitemcooldown = 20*TICRATE; /* FALLTHRU */ From b1100d6215cd638fc922bdd9bd74f966ba050d19 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jun 2026 18:24:16 +0200 Subject: [PATCH 27/39] add mobj "temprollangle" field same as rollangle but resets at beginning on each tic i dont feel like exposing this to lua atm, so if someone wants to or if even needed at all --- src/hardware/hw_main.cpp | 4 ++-- src/hardware/hw_md2.c | 7 +++---- src/p_mobj.h | 1 + src/p_user.c | 1 + src/r_fps.cpp | 1 + src/r_things.cpp | 10 ++++++---- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index cf5d0fda7..455503cc3 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -4630,7 +4630,7 @@ static void HWR_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE // determine here if sprite should rotate for optimization const boolean sliprollrotate = (cv_sliptideroll.value && (thing->player && thing->player->sliproll)); - const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || sliprollrotate); + const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || thing->temprollangle || sliprollrotate); #endif if (sprframe->rotate != SRF_SINGLE || papersprite @@ -4688,7 +4688,7 @@ static void HWR_ProjectSprite(mobj_t *thing) // this is very messy, but it on-the-fly calculates rotations for all the // pitch and roll variables pitchnroll = R_RotationAngle(ang, camang, &interp); - rollangle = thing->rollangle; + rollangle = (thing->rollangle - thing->temprollangle); if (rollangle || pitchnroll || sliprollrotate) { diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 2aefecea1..4cb8a0a51 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1400,12 +1400,11 @@ void HWR_DrawMD2(gl_vissprite_t *spr) const angle_t sliptideroll = ((cv_sliptideroll.value && spr->mobj->player) ? spr->mobj->player->sliproll : 0); const SINT8 flipfactor = flip ? -1 : 1; + const angle_t thingrollangle = (spr->mobj->rollangle - spr->mobj->temprollangle); - if (spr->mobj->rollangle || sliptideroll) + if (thingrollangle || sliptideroll) { - angle_t rollang = sliptideroll - ? (spr->mobj->rollangle) + (sliptideroll * spr->mobj->player->kartstuff[k_aizdriftstrat]) - : (spr->mobj->rollangle); + angle_t rollang = sliptideroll ? (thingrollangle + (sliptideroll * spr->mobj->player->kartstuff[k_aizdriftstrat])) : thingrollangle; rollang *= flipfactor; diff --git a/src/p_mobj.h b/src/p_mobj.h index 682b2fb1b..c348c925c 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -298,6 +298,7 @@ typedef struct mobj_s angle_t angle, pitch, roll; // orientation angle_t old_angle, old_pitch, old_roll; // orientation interpolation angle_t rollangle; + angle_t temprollangle; // same as rollangle but resets each tic, idk either man. // cba exposing this to lua either spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h UINT16 anim_duration; // for FF_ANIMATE states diff --git a/src/p_user.c b/src/p_user.c index d952e296d..5f13fa018 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1206,6 +1206,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost->pitch = mobj->pitch; ghost->roll = mobj->roll; ghost->rollangle = mobj->rollangle; + ghost->temprollangle = mobj->temprollangle; ghost->sloperoll = mobj->sloperoll; ghost->slopepitch = mobj->slopepitch; diff --git a/src/r_fps.cpp b/src/r_fps.cpp index 8372fa30f..121a0df5f 100644 --- a/src/r_fps.cpp +++ b/src/r_fps.cpp @@ -807,6 +807,7 @@ void R_ResetMobjInterpolationState(mobj_t *mobj) mobj->spriteyscale = mobj->realyscale; mobj->spritexoffset = mobj->realxoffset; mobj->spriteyoffset = mobj->realyoffset; + mobj->temprollangle = 0; mobj->resetinterp = false; } diff --git a/src/r_things.cpp b/src/r_things.cpp index b4707db6f..d891d40ce 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1276,7 +1276,7 @@ static void R_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE // determine here if sprite should rotate for optimization const boolean sliprollrotate = (cv_sliptideroll.value && (thing->player && thing->player->sliproll)); - const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || sliprollrotate); + const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || thing->temprollangle || sliprollrotate); #endif sprskin = K_GetMobjSkin(thing); @@ -1376,16 +1376,18 @@ static void R_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE if (shouldrotate) { + const fixed_t thingrollangle = (thing->rollangle - thing->temprollangle); + if (papersprite) { if (ang >= ANGLE_180) { // Makes Software act much more sane like OpenGL - rollangle = InvAngle(thing->rollangle); + rollangle = InvAngle(thingrollangle); } else { - rollangle = thing->rollangle; + rollangle = thingrollangle; } } else @@ -1393,7 +1395,7 @@ static void R_ProjectSprite(mobj_t *thing) // this is very messy, but it on-the-fly calculates rotations for all the // pitch and roll variables pitchnroll = R_RotationAngle(ang, camang, &interp); - rollangle = thing->rollangle; + rollangle = thingrollangle; } if (rollangle || pitchnroll || sliprollrotate) From ec047151e33eba61d483785846bffaee0196d03d Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jun 2026 19:38:14 +0200 Subject: [PATCH 28/39] toggable stair "jank" visuals akin to RR, just toned down for smaller kart chars also toggable ofc theres not that many stairs in kart but this looks cute with smol bumps in the road wish this would work on slopes but theyre kinda messed up lol --- src/d_player.h | 2 ++ src/g_game.h | 1 + src/g_input.c | 6 ++++++ src/k_kart.c | 17 +++++++++++++++++ src/p_map.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- src/p_slopes.c | 5 +++++ src/p_user.c | 5 +++++ src/r_main.cpp | 1 + 8 files changed, 82 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index bcecb66a5..e4aded95b 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -566,6 +566,8 @@ typedef struct player_s fixed_t fovadd; // adjust FOV for hw rendering SINT8 driftlevel; // just for controller rumble for now + + UINT8 stairjank; } player_t; #endif diff --git a/src/g_game.h b/src/g_game.h index 34496534e..4f46ef89d 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -118,6 +118,7 @@ extern consvar_t cv_driftsparkpulse; extern consvar_t cv_gravstretch; extern consvar_t cv_sloperoll; extern consvar_t cv_sliptideroll; +extern consvar_t cv_stairjank; extern consvar_t cv_slamsound; extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; diff --git a/src/g_input.c b/src/g_input.c index c72ed6308..fa18272b8 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1139,6 +1139,12 @@ void G_DeviceRumbleTick(void) if (leveltime & 1) // this is actually funny lel high = RUMBLE_MODERATE; } + /*else if ((player->stairjank > 8) // this is kinda cool but prob gets annoying after a while + && player->speed != 0 + && P_IsObjectOnGround(player->mo)) + { + low = high = RUMBLE_WEAK; + }*/ if (player->kartstuff[k_brakedrift]) { diff --git a/src/k_kart.c b/src/k_kart.c index ad91b76c3..e3306c629 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -67,6 +67,7 @@ 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}; //hardcode saltyhop mhhm static void saltyhop_onchange(void); @@ -3510,6 +3511,16 @@ boolean K_ShouldSlopeRoll(mobj_t *mobj) return K_CheckSlopeRollDist(mobj); } +static INT32 K_AltFlip(INT32 n, tic_t tics) +{ + return leveltime % (2 * tics) < tics ? n : -(n); +} + +static INT32 K_StairJankFlip(INT32 value) +{ + return K_AltFlip(value, 2); +} + // reset banan and eggbox rollangle when they´re on the ground // if not cv_bananthrowroll option "+Onground" static void K_ResetBananaRollangle(mobj_t* mo) @@ -7053,6 +7064,12 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_RollMobjBySlopes(player->mo, player->mo->standingslope); + // "Stair jank" visuals akin to RR + if (cv_stairjank.value && player->stairjank > 0) + { + player->mo->temprollangle += K_StairJankFlip(ANGLE_11hh / 2 / (17 / player->stairjank)); // TODO: make strength adjustable? + } + //// // Quick Turning diff --git a/src/p_map.c b/src/p_map.c index 08444f4cd..06e666a28 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2375,8 +2375,10 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) fixed_t tryx = thing->x; fixed_t tryy = thing->y; fixed_t radius = thing->radius; - fixed_t thingtop ;//= thing->z + thing->height; + fixed_t thingtop;//= thing->z + thing->height; fixed_t startingonground = P_IsObjectOnGround(thing); + fixed_t stairjank = 0; + pslope_t *oldslope = thing->standingslope; INT32 special = -1; floatok = false; @@ -2450,11 +2452,19 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thingtop = thing->z + thing->height; + const boolean flipped = + (thing->eflags & MFE_VERTICALFLIP) != 0; + // Step up if (thing->z < tmfloorz) { if (tmfloorz - thing->z <= maxstep) { + if (maxstep > 0 && !flipped) + { + stairjank = (tmfloorz - thing->z); + } + thing->z = thing->floorz = tmfloorz; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } @@ -2467,6 +2477,11 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) { if (thingtop - tmceilingz <= maxstep) { + if (maxstep > 0 && flipped) + { + stairjank = (thingtop - tmceilingz); + } + thing->z = ( thing->ceilingz = tmceilingz ) - thing->height; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } @@ -2483,11 +2498,21 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) { + if (flipped) + { + stairjank = (tmceilingz - thingtop); + } + thing->z = (thing->ceilingz = tmceilingz) - thing->height; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep) { + if (!flipped) + { + stairjank = (thing->z - tmfloorz); + } + thing->z = thing->floorz = tmfloorz; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } @@ -2563,6 +2588,25 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else // don't set standingslope if you're not going to clip against it thing->standingslope = NULL; + /* FIXME: slope step down (even up) has some false + positives, so just ignore them entirely. */ + if (stairjank && !oldslope && !thing->standingslope && thing->player && !thing->player->spectator) + { + // TODO: maybe spawn smol dust effect similar to RR? + /*if (!thing->player->stairjank) + { + mobj_t * spark = P_SpawnMobjFromMobj(thing, 0, 0, 0, MT_JANKSPARK); + spark->fuse = 9; + spark->cusval = K_StairJankFlip(ANGLE_90); + P_SetTarget(&spark->target, thing); + P_SetTarget(&spark->owner, thing); + spark->renderflags |= RF_REDUCEVFX; + }*/ + + thing->player->stairjank = 9; + //thing->player->stairjank = 17; + } + thing->x = x; thing->y = y; diff --git a/src/p_slopes.c b/src/p_slopes.c index 6334b2e45..52a262785 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -901,6 +901,11 @@ void P_SlopeLaunch(mobj_t *mo) //CONS_Printf("Launched off of slope.\n"); mo->standingslope = NULL; + + if (mo->player) + { + mo->player->stairjank = 0; // fuck you + } } // Function to help handle landing on slopes diff --git a/src/p_user.c b/src/p_user.c index 5f13fa018..90bca6cff 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5090,6 +5090,11 @@ void P_PlayerThink(player_t *player) player->squishdance.time = 0; } + if (player->stairjank > 0) + { + player->stairjank--; + } + // Flash player after being hit. if (!(player->kartstuff[k_hyudorotimer] // SRB2kart - fixes Hyudoro not flashing when it should. || player->kartstuff[k_growshrinktimer] > 0 // Grow doesn't flash either. diff --git a/src/r_main.cpp b/src/r_main.cpp index 5a7a1d23f..962ccc0a7 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1598,6 +1598,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_sliptideroll); CV_RegisterVar(&cv_sloperolldist); CV_RegisterVar(&cv_sparkroll); + CV_RegisterVar(&cv_stairjank); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); From 6efe56808a8d9f26bb42d55c77985664d4da3b67 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jun 2026 17:43:27 +0200 Subject: [PATCH 29/39] make sky "dome/barreling" toggable per "skydome" cvar using karts old sky code for gl since it appears to differ a bit from srb2 and id want to keep this "authentic" to old kart --- src/hardware/hw_main.cpp | 132 +++++++++++++++++++++++++++++++++++++-- src/r_main.cpp | 2 + src/r_main.h | 1 + src/r_plane.cpp | 9 ++- 4 files changed, 135 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 455503cc3..b9319a63a 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5186,15 +5186,10 @@ void HWR_BuildSkyDome(void) // precompute to save a bit of division static constexpr float FINEDEGREE = (360.0f/static_cast(FINEANGLES)); -static void HWR_DrawSkyBackground(void) +static void HWR_DrawSkyDome(void) { FTransform dometransform; - if (HWR_IsWireframeMode()) - return; - - GL_SetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated); - memcpy(&dometransform, &atransform, sizeof(FTransform)); dometransform.x = dometransform.y = dometransform.z = 0.0; @@ -5219,6 +5214,131 @@ static void HWR_DrawSkyBackground(void) GL_RenderSkyDome(&gl_sky); } +// the following is karts old sky code from before the skydome stuff +// this appears to differ a bit from srb2´s old sky code +static void HWR_DrawSkyTexture(void) +{ + FOutVector v[4]; + angle_t angle; + float dimensionmultiply; + float aspectratio; + float angleturn; + + HWR_GetTexture(texturetranslation[skytexture], false); + + aspectratio = (float)vid.width/(float)vid.height; + + //Hurdler: the sky is the only texture who need 4.0f instead of 1.0 + // because it's called just after clearing the screen + // and thus, the near clipping plane is set to 3.99 + // Sryder: Just use the near clipping plane value then + + // 3--2 + // | /| + // |/ | + // 0--1 + v[0].x = v[3].x = -ZCLIP_PLANE-1; + v[1].x = v[2].x = ZCLIP_PLANE+1; + v[0].y = v[1].y = -ZCLIP_PLANE-1; + v[2].y = v[3].y = ZCLIP_PLANE+1; + + v[0].z = v[1].z = v[2].z = v[3].z = ZCLIP_PLANE+1; + + // X + + // NOTE: This doesn't work right with texture widths greater than 1024 + // software doesn't draw any further than 1024 for skies anyway, but this doesn't overlap properly + // The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture + + //angle = (viewangle + ANGLE_45); + angle = (viewangle + xtoviewangle[0]); + dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->width/256.0f); + + if (atransform.fliptype == TRANSFORM_MIRROR || + atransform.fliptype == TRANSFORM_MIRRORFLIP) + { + angle = InvAngle(angle); + dimensionmultiply *= -1; + } + + v[0].s = v[3].s = ((float)angle / ((float)(ANGLE_90-1)*dimensionmultiply)); + v[2].s = v[1].s = (-1.0f/dimensionmultiply)+((float) angle / ((float)(ANGLE_90-1)*dimensionmultiply)); + + // Y + angle = aimingangle; + dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->height/(128.0f*aspectratio)); + + if (splitscreen == 1) + { + dimensionmultiply *= 2; + angle *= 2; + } + + // Middle of the sky should always be at angle 0 + // need to keep correct aspect ratio with X + if (atransform.fliptype == TRANSFORM_FLIP || + atransform.fliptype == TRANSFORM_MIRRORFLIP) + { + // During vertical flip the sky should be flipped and it's y movement should also be flipped obviously + v[3].t = v[2].t = -(0.5f-(0.5f/dimensionmultiply)); + v[0].t = v[1].t = (-1.0f/dimensionmultiply)-(0.5f-(0.5f/dimensionmultiply)); + } + else + { + v[3].t = v[2].t = (-1.0f/dimensionmultiply)-(0.5f-(0.5f/dimensionmultiply)); + v[0].t = v[1].t = -(0.5f-(0.5f/dimensionmultiply)); + } + + angleturn = (((float)ANGLE_45-1.0f)*aspectratio)*dimensionmultiply; + + if (cv_glshearing.value) + { + // Doesn't really make sense, but what can I do? + angle_t dy = FixedAngle(FixedMul(360*FRACUNIT, FixedDiv(AIMINGTODY(aimingangle), 900*FRACUNIT))); + v[3].t = v[2].t -= ((float) dy / angleturn); + v[0].t = v[1].t -= ((float) dy / angleturn); + } + else + { + if (angle > ANGLE_180) // Do this because we don't want the sky to suddenly teleport when crossing over 0 to 360 and vice versa + { + angle = InvAngle(angle); + v[3].t = v[2].t += ((float) angle / angleturn); + v[0].t = v[1].t += ((float) angle / angleturn); + } + else + { + v[3].t = v[2].t -= ((float) angle / angleturn); + v[0].t = v[1].t -= ((float) angle / angleturn); + } + } + + // since sky is drawn as a "flat quad" this way, we have to unset any view transformations for it to work + GL_SetTransform(NULL); + if (HWR_UseShader()) + { + GL_SetShader(HWR_GetShaderFromTarget(SHADER_SKY)); // not sure if this is needed? + GL_DrawPolygon(NULL, v, 4, 0); + GL_UnSetShader(); + } + else + { + GL_UnSetShader(); + GL_DrawPolygon(NULL, v, 4, 0); + } +} + +static void HWR_DrawSkyBackground(void) +{ + if (HWR_IsWireframeMode()) + return; + + if (cv_skydome.value) + HWR_DrawSkyDome(); + else + HWR_DrawSkyTexture(); +} + // -----------------+ // HWR_ClearView : clear the viewwindow, with maximum z value. also clears stencil buffer. // -----------------+ diff --git a/src/r_main.cpp b/src/r_main.cpp index 962ccc0a7..c4719e2e5 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -188,6 +188,7 @@ consvar_t cv_flipcammode = {"flipcammode", "Displayplayer", CV_SAVE, flipcammod consvar_t cv_shadow = {"shadow", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_shadowoffs = {"offsetshadows", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_skybox = {"skybox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_skydome = {"skydome", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_ffloorclip = {"r_ffloorclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_spriteclip = {"r_spriteclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_softcyancut = {"softwarecyancut", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1564,6 +1565,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_shadow); CV_RegisterVar(&cv_shadowoffs); CV_RegisterVar(&cv_skybox); + CV_RegisterVar(&cv_skydome); CV_RegisterVar(&cv_ffloorclip); CV_RegisterVar(&cv_spriteclip); CV_RegisterVar(&cv_secbright); diff --git a/src/r_main.h b/src/r_main.h index e8b7393e3..3699822a3 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -213,6 +213,7 @@ extern consvar_t cv_translucency; extern consvar_t cv_drawdist, cv_drawdist_precip, cv_lessprecip; extern consvar_t cv_fov, cv_fovchange; extern consvar_t cv_skybox; +extern consvar_t cv_skydome; extern consvar_t cv_tailspickup; extern consvar_t cv_maxinterpdist; extern consvar_t cv_playerfade; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index a6a52fe83..df289faa0 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -785,6 +785,8 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*), drawcolumndata_t dc = {}; const INT32 texture = texturetranslation[skytexture]; + const boolean skydome = cv_skydome.value != 0; + // Reset column drawer function (note: couldn't we just call colfuncs[BASEDRAWFUNC] directly?) // (that is, unless we'll need to switch drawers in future for some reason) R_SetColumnFunc(BASEDRAWFUNC); @@ -830,8 +832,8 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*), INT32 angle = (pl->viewangle + xtoviewangle[x + i])>>ANGLETOSKYSHIFT; angle -= (skytextureoffset >> FRACBITS); - - dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x + i]>>ANGLETOFINESHIFT)); + if (skydome) + dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x + i]>>ANGLETOFINESHIFT)); dc.x = x + i; dc.source = R_GetColumn(texture, -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18 @@ -866,7 +868,8 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*), INT32 angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT; angle -= (skytextureoffset >> FRACBITS); - dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT)); + if (skydome) + dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT)); dc.x = x; dc.source = R_GetColumn(texturetranslation[skytexture], -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18 From f12d5a246d0c49a58819012366dc182e7d74fd3f Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jun 2026 19:54:12 +0200 Subject: [PATCH 30/39] just dont set shader for this ig otherwise this breaks when you disable the hud for whatever reason looks the same so whatever --- src/hardware/hw_main.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index b9319a63a..de48ba6ee 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5315,17 +5315,8 @@ static void HWR_DrawSkyTexture(void) // since sky is drawn as a "flat quad" this way, we have to unset any view transformations for it to work GL_SetTransform(NULL); - if (HWR_UseShader()) - { - GL_SetShader(HWR_GetShaderFromTarget(SHADER_SKY)); // not sure if this is needed? - GL_DrawPolygon(NULL, v, 4, 0); - GL_UnSetShader(); - } - else - { - GL_UnSetShader(); - GL_DrawPolygon(NULL, v, 4, 0); - } + GL_UnSetShader(); + GL_DrawPolygon(NULL, v, 4, 0); } static void HWR_DrawSkyBackground(void) From db4aedf49880d342103e844228b154deb18ce501 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 14:05:32 +0200 Subject: [PATCH 31/39] readd missing setblend for sky bg oopsie forgor to copy this back --- src/hardware/hw_main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index de48ba6ee..485013345 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5324,6 +5324,8 @@ static void HWR_DrawSkyBackground(void) if (HWR_IsWireframeMode()) return; + GL_SetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated); + if (cv_skydome.value) HWR_DrawSkyDome(); else From 948c9399deca0a9a67d7efb37ea0e19bb9a651cc Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 14:08:38 +0200 Subject: [PATCH 32/39] fix HWR_SplitWall again.. theres guards just above this which should just skip shit but for some reason the clamps still do stuff, idk man fixes the weird grass fof in green hill --- src/hardware/hw_main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 485013345..c47fa7d68 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1071,11 +1071,11 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, else solid = false; - height = FixedToFloat(P_GetLightZAt(&list[i], v1x, v1y)); - endheight = FixedToFloat(P_GetLightZAt(&list[i], v2x, v2y)); - if (solid) { + height = FixedToFloat(P_GetLightZAt(&list[i], v1x, v1y)); + endheight = FixedToFloat(P_GetLightZAt(&list[i], v2x, v2y)); + bheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v1x, v1y)); endbheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v2x, v2y)); @@ -1105,8 +1105,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, // Found a break // The heights are clamped to ensure the polygon doesn't cross itself. - bot = std::max(bheight, realbot); - endbot = std::max(endbheight, endrealbot); + bot = std::clamp(bheight, realbot, top); + endbot = std::clamp(endbheight, endrealbot, endtop); Surf->PolyColor.s.alpha = alpha; @@ -3671,8 +3671,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) // Found a break // The heights are clamped to ensure the polygon doesn't cross itself. - bot = std::max(bheight, realbot); - endbot = std::max(endbheight, endrealbot); + bot = std::clamp(bheight, realbot, top); + endbot = std::clamp(endbheight, endrealbot, endtop); wallVerts[3].t = towtop + ((realtop - top) * towmult); wallVerts[2].t = towtop + ((endrealtop - endtop) * towmult); From 266a4effb77343bb9e2ad3431745fa177a3ca015 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 14:10:25 +0200 Subject: [PATCH 33/39] fix fogblock not accounting for fake contrast super old oopsie lulul --- src/hardware/hw_main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index c47fa7d68..642fdfec7 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1001,8 +1001,9 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, const fixed_t v2y = FloatToFixed(wallVerts[1].z); const UINT8 alpha = Surf->PolyColor.s.alpha; - FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, gl_curline, NULL); + FUINT lightnum = sector->lightlevel; extracolormap_t *colormap = NULL; + lightnum = HWR_CalcWallLight(lightnum, gl_curline, NULL); realtop = top = wallVerts[3].y; realbot = bot = wallVerts[0].y; @@ -2050,11 +2051,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; + lightnum = HWR_CalcWallLight(lightnum, gl_curline, colormap); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(lightnum, colormap); - lightnum = HWR_CalcWallLight(lightnum, gl_curline, colormap); - if (other_sector->numlights) HWR_SplitWall(other_sector, wallVerts, 0, false, &Surf, roverflags, rover, blendmode); else From 8aafde4c9d27a74d7038fba61dbfbe821187eff8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 20:05:43 +0200 Subject: [PATCH 34/39] "less" --- src/m_menudefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 0f7b5736d..d56637b7a 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1631,7 +1631,7 @@ static menuitem_t OP_AccessibilityMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Video Color Settings...", &OP_ColorOptionsDef, 30}, {IT_STRING|IT_CVAR, NULL, "Reduce Effects", &cv_reducevfx, 35}, - {IT_STRING|IT_CVAR, NULL, "Midnight Channel Flicker", &cv_lessflicker, 40}, // obsolete now? or still better be a seperate toggle? + {IT_STRING|IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 40}, // obsolete now? or still better be a seperate toggle? {IT_STRING|IT_CVAR, NULL, "Minimum Sector Brightness", &cv_secbright, 45}, From 13dc0db9a997294550225c10010c9da7723d401d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 20:25:06 +0200 Subject: [PATCH 35/39] add stairjank and skydome stuff to menu pls someone gib a better description for skydome idk ingles --- src/m_menudefs.c | 108 ++++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 52 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index d56637b7a..80c87066e 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -555,10 +555,10 @@ static menuitem_t MP_PlayerSetupMenu[] = static menuitem_t MP_ConnectMenu[] = { - {IT_STRING | IT_CVAR, NULL, "Sort By", &cv_serversort, 0}, - {IT_STRING | IT_KEYHANDLER, NULL, "Page", M_HandleServerPage, 8}, - {IT_STRING | IT_CALL, NULL, "Refresh", M_Refresh, 16}, - {IT_STRING | IT_KEYHANDLER, NULL, "", M_HandleServerSearch,25}, + {IT_STRING | IT_CVAR, NULL, "Sort By", &cv_serversort, 0}, + {IT_STRING | IT_KEYHANDLER, NULL, "Page", M_HandleServerPage, 8}, + {IT_STRING | IT_CALL, NULL, "Refresh", M_Refresh, 16}, + {IT_STRING | IT_KEYHANDLER, NULL, "", M_HandleServerSearch, 25}, {IT_STRING | IT_SPACE, NULL, "", M_Connect, 48}, {IT_STRING | IT_SPACE, NULL, "", M_Connect, 60}, @@ -725,29 +725,29 @@ static const char* OP_AllControlsTooltips[sizeof(OP_AllControlsMenu)/sizeof(OP_A // The rest is null, for now }; -#define OP_JOYMENU(pnum) \ - {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, \ - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[pnum] , 15}, \ - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[pnum] , 20}, \ - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[pnum] , 25}, \ - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[pnum] , 30}, \ - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[pnum] , 35}, \ - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[pnum] , 40}, \ - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[pnum] , 45}, \ - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[pnum] , 50}, \ - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[pnum] , 55}, \ - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[pnum] , 60}, \ - {IT_HEADER, NULL, "Camera Controls", NULL, 67}, \ - {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[pnum] , 75}, \ - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[pnum] , 80}, \ - {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[pnum] , 85}, \ - {IT_HEADER, NULL, "Deadzones", NULL, 92}, \ - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[pnum] , 100}, \ - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[pnum] , 105}, \ - {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, \ - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[pnum] , 120}, \ - {IT_STRING | IT_CVAR, NULL, "Controller Rumble Strength" , &cv_rumblestrength[pnum] , 125}, \ - {IT_STRING | IT_CVAR, NULL, "Set LED to Player color" , &cv_gamepadled[pnum] , 130}, +#define OP_JOYMENU(pnum) \ + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, \ + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[pnum] , 15}, \ + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[pnum] , 20}, \ + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[pnum] , 25}, \ + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[pnum] , 30}, \ + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[pnum] , 35}, \ + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[pnum] , 40}, \ + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[pnum] , 45}, \ + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[pnum] , 50}, \ + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[pnum] , 55}, \ + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[pnum] , 60}, \ + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, \ + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[pnum] , 75}, \ + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[pnum] , 80}, \ + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[pnum] , 85}, \ + {IT_HEADER, NULL, "Deadzones", NULL, 92}, \ + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[pnum] , 100}, \ + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[pnum] , 105}, \ + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, \ + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[pnum] , 120}, \ + {IT_STRING | IT_CVAR, NULL, "Controller Rumble Strength" , &cv_rumblestrength[pnum] , 125}, \ + {IT_STRING | IT_CVAR, NULL, "Set LED to Player color" , &cv_gamepadled[pnum] , 130}, static menuitem_t OP_Joystick1Menu[] = { @@ -789,10 +789,9 @@ static menuitem_t OP_JoystickSetMenu[] = static menuitem_t OP_MouseOptionsMenu[] = { {IT_STRING | IT_CVAR, NULL, "Use Mouse", &cv_usemouse, 10}, - {IT_STRING | IT_CVAR, NULL, "Mouse Turning", &cv_mouseturn, 20}, {IT_STRING | IT_CVAR, NULL, "Invert Mouse", &cv_invertmouse, 30}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Mouse X Speed", &cv_mousexsens, 40}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Mouse X Speed", &cv_mousexsens, 40}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Mouse Y Speed", &cv_mouseysens, 50}, }; @@ -861,7 +860,6 @@ static const char* OP_VideoTooltips[] = "Advanced graphical options.", }; - enum { op_video_res = 0, @@ -945,24 +943,25 @@ static menuitem_t OP_ExpOptionsMenu[] = //{IT_STRING | IT_CVAR, NULL, "Randomized Directional Light", &cv_randomdirlight, 45}, // should this ever come back {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 40}, + {IT_STRING | IT_CVAR, NULL, "Skydome", &cv_skydome, 45}, - {IT_STRING | IT_CVAR, NULL, "Precache Level Textures", &cv_precachetextures, 50}, + {IT_STRING | IT_CVAR, NULL, "Precache Level Textures", &cv_precachetextures, 55}, - {IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 60}, + {IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 65}, - {IT_STRING | IT_CVAR, NULL, "Frameskip", &cv_frameskip, 70}, + {IT_STRING | IT_CVAR, NULL, "Frameskip", &cv_frameskip, 75}, - {IT_STRING | IT_CVAR, NULL, "Votescreen Scaling", &cv_votebgscaling, 80}, + {IT_STRING | IT_CVAR, NULL, "Votescreen Scaling", &cv_votebgscaling, 85}, #ifdef HWRENDER - {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 90}, + {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 95}, #ifdef USE_FBO_OGL - {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 95}, - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 105}, - {IT_DISABLED, NULL, "", NULL, 115}, // dummy text + {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 100}, + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 110}, + {IT_DISABLED, NULL, "", NULL, 120}, // dummy text #else - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 100}, - {IT_DISABLED, NULL, "", NULL, 110}, // dummy text + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 110}, + {IT_DISABLED, NULL, "", NULL, 120}, // dummy text #endif #endif }; @@ -975,6 +974,7 @@ static const char* OP_ExpTooltips[] = "Sets minimum sector brightness, useful for dark areas.", //"Should the directional lightning be randomized each map?\nTakes effect on next map load.", "Toggle being able to see the sky.", + "Toggle skydome.", // idk man someone give a better description of this "Preload all level textures on level load.\nMassively reduces texture related stuttering during gameplay\nat the cost of longer level loading times.\nDisable this if you experience timeouts during level switches.", "Change the FPS counter sampling method\nInaccurate updates slower\nand might miss sudden framerate changes and drops,\nproviding a more averaged result.\nAccurate updates faster, but might be less readable.", // how to ingles?? "Skips rendering frames if game logic takes too long\npreventing gameplay issues during performance drops.", // idk im shit as describing things @@ -996,6 +996,7 @@ enum op_exp_secbright, //op_exp_dirlight, op_exp_skybox, + op_exp_skydome, op_exp_texcache, op_exp_accuratefps, op_exp_frameskip, @@ -1767,20 +1768,21 @@ static menuitem_t OP_PlayerDistortMenu[] = {IT_STRING | IT_CVAR, NULL, "Slope Rotation Distance", &cv_sloperolldist, 15}, {IT_STRING | IT_CVAR, NULL, "Rotate Players when Sliptiding", &cv_sliptideroll, 25}, - {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 30}, - {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 35}, + {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 | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 45}, - {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 50}, + {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, "Saltyhop", &cv_saltyhop, 60}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 65}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 70}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 75}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 80}, + {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, NULL, "Squishdance", &cv_squishdance, 90}, - {IT_STRING | IT_CVAR, NULL, "Squishdance Speed", &cv_squishdancespeed, 96}, + {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 }; static const char* OP_PlayerDistortTooltips[] = @@ -1789,6 +1791,7 @@ static const char* OP_PlayerDistortTooltips[] = "Sprite rotation on slopes. Can either be just players or all objects.", "Distance object rotation should be visable.", "Player rotation when sliptiding.", + "Slightly tilt the player 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.", @@ -1799,7 +1802,7 @@ static const char* OP_PlayerDistortTooltips[] = "Player hop squash and stretch.", "Should the player rotation be kept during player hop.", "Do a funny squishy dance when holding CUSTOM 3.", - "Speed of the Squishy dance in BPM.", + "Speed of the Squishy dance in SPM (Squishes Per Minute).", }; enum @@ -1808,6 +1811,7 @@ enum sloperotate, slrotatedist, sliptide, + stairjank, sparkrotate, bananrotat, stretchyplayer, From 91927e324b3e5c42cd98b15159360438b8190f6e Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 20:40:20 +0200 Subject: [PATCH 36/39] , this menu been broken since 4 months lol --- src/m_menudefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 80c87066e..0ee6af395 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -980,7 +980,7 @@ static const char* OP_ExpTooltips[] = "Skips rendering frames if game logic takes too long\npreventing gameplay issues during performance drops.", // idk im shit as describing things "Different methods of scaling the votescreen backgrounds.", #ifdef HWRENDER - "Disabling Screen Textures may result in a performance boost\nbut will break certain effects.\nScreen textures are required at resolutions lower than your desktop resolution!" + "Disabling Screen Textures may result in a performance boost\nbut will break certain effects.\nScreen textures are required at resolutions lower than your desktop resolution!", #ifdef USE_FBO_OGL "Allows the game to downsample from a higher resolution\nthan your display in OpenGL renderer mode.\nRequires a GPU with atleast OpenGL 2.1 support.", #endif From c4ed75fbc6b0379a50b395157d68b64d12b71453 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 22:42:20 +0200 Subject: [PATCH 37/39] port over some chat stuff from SRB2-Banpyura per https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2784 chat offsets and character count offsets are added to the base offset like we do for hud stuff, the og pr will directly use the cvar values for this, but wanna keep consistent with our rest needs to be added in the menu somewhere but idk where --- src/d_netcmd.c | 3 ++ src/hu_stuff.c | 107 ++++++++++++++++++++++++++++++++++++------------- src/hu_stuff.h | 4 ++ 3 files changed, 86 insertions(+), 28 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ecb90f224..9d7d697cd 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -942,6 +942,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_chatspamprotection); CV_RegisterVar(&cv_consolechat); CV_RegisterVar(&cv_chatnotifications); + CV_RegisterVar(&cv_chat_xoffset); + CV_RegisterVar(&cv_chat_yoffset); + CV_RegisterVar(&cv_chat_showlimit); CV_RegisterVar(&cv_chatbacktint); CV_RegisterVar(&cv_chatcentertext); CV_RegisterVar(&cv_songcredits); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 82b0a74af..0013900f6 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -117,6 +117,11 @@ static void HU_DrawRankings(void); consvar_t cv_showspecstuff = {"showspecstuff", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +// stuff from SRB2-Banpyura thx alot! :3 +consvar_t cv_chat_xoffset = {"chat_xoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_chat_yoffset = {"chat_yoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_chat_showlimit = {"chat_showlimit", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + static char cechotext[1024]; static tic_t cechotimer = 0; static tic_t cechoduration = 5*TICRATE; @@ -1370,7 +1375,12 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string) // 30/7/18: chaty is now the distance at which the lowest point of the chat will be drawn if that makes any sense. -INT16 chatx = 13, chaty = 169; // let's use this as our coordinates, shh +// let's use this as our coordinates, shh +// :chao: guess this just works lol +#define chatx ((INT16)(13 + (cv_chat_xoffset.value))) +#define chaty ((INT16)(169 + (cv_chat_yoffset.value))) + +#define CHATSNAP (V_SNAPTOBOTTOM|V_SNAPTOLEFT) // chat stuff by VincyTM LOL XD! @@ -1397,7 +1407,7 @@ static void HU_drawMiniChat(void) for (; i > 0; i--) { - char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i-1]); + char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), CHATSNAP|V_ALLOWLOWERCASE, chat_mini[i-1]); size_t j = 0; INT32 linescount = 0; emote_t *emote = NULL; @@ -1457,6 +1467,7 @@ static void HU_drawMiniChat(void) if (splitscreen) { y -= BASEVIDHEIGHT/2; + if (splitscreen > 1) y += 16; } @@ -1474,7 +1485,7 @@ static void HU_drawMiniChat(void) INT32 timer = ((cv_chattime.value*TICRATE)-chat_timers[i]) - cv_chattime.value*TICRATE+9; // see below... INT32 transflag = (timer >= 0 && timer <= 9) ? (timer*V_10TRANS) : 0; // you can make bad jokes out of this one. size_t j = 0; - char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i]); // get the current message, and word wrap it. + char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), CHATSNAP|V_ALLOWLOWERCASE, chat_mini[i]); // get the current message, and word wrap it. UINT8 *colormap = NULL; emote_t *emote = NULL; int emotelen = 0; @@ -1507,9 +1518,9 @@ static void HU_drawMiniChat(void) else if ((emote = M_VerifyEmote(msg+j, &emotelen))) { if (cv_chatbacktint.value) // on request of wolfy - V_DrawFillConsoleMap(x + dx + 2, y+dy, EMOTEWIDTH, charheight, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); + V_DrawFillConsoleMap(x + dx + 2, y+dy, EMOTEWIDTH, charheight, 239|CHATSNAP); - M_DrawEmote(x+dx+2, y+dy, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag); + M_DrawEmote(x+dx+2, y+dy, emote, CHATSNAP|transflag); dx += EMOTEWIDTH - charwidth; j += emotelen; @@ -1517,9 +1528,9 @@ static void HU_drawMiniChat(void) else { if (cv_chatbacktint.value) // on request of wolfy - V_DrawFillConsoleMap(x + dx + 2, y+dy, charwidth, charheight, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); + V_DrawFillConsoleMap(x + dx + 2, y+dy, charwidth, charheight, 239|CHATSNAP); - V_DrawChatCharacter(x + dx + 2, y+dy+cv_chatcentertext.value, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag, !cv_allcaps.value, colormap); + V_DrawChatCharacter(x + dx + 2, y+dy+cv_chatcentertext.value, msg[j++] |CHATSNAP|transflag, !cv_allcaps.value, colormap); } dx += charwidth; @@ -1580,13 +1591,13 @@ static void HU_drawChatLog(INT32 offset) chat_topy = y + chat_scroll*charheight; chat_bottomy = chat_topy + boxh*charheight; - V_DrawFillConsoleMap(chatx, chat_topy, boxw, boxh*charheight +2, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); // log box + V_DrawFillConsoleMap(chatx, chat_topy, boxw, boxh*charheight +2, 239|CHATSNAP); // log box for (i = 0; i < chat_nummsg_log; i++) // iterate through our chatlog { INT32 clrflag = 0; INT32 j = 0; - char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_log[i]); // get the current message, and word wrap it. + char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), CHATSNAP|V_ALLOWLOWERCASE, chat_log[i]); // get the current message, and word wrap it. UINT8 *colormap = NULL; emote_t *emote = NULL; int emotelen = 0; @@ -1616,7 +1627,7 @@ static void HU_drawChatLog(INT32 offset) { if ((y+dy+2 >= chat_topy) && (y+dy < (chat_bottomy))) { - M_DrawEmote(x+dx+2, y+dy+1, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT); + M_DrawEmote(x+dx+2, y+dy+1, emote, CHATSNAP); dx += EMOTEWIDTH - charwidth; } j += emotelen; @@ -1624,7 +1635,7 @@ static void HU_drawChatLog(INT32 offset) else { if ((y+dy+2 >= chat_topy) && (y+dy < (chat_bottomy))) - V_DrawChatCharacter(x + dx + 2, y+dy+2, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT, !cv_allcaps.value, colormap); + V_DrawChatCharacter(x + dx + 2, y+dy+2, msg[j++] |CHATSNAP, !cv_allcaps.value, colormap); else j++; // don't forget to increment this or we'll get stuck in the limbo. } @@ -1661,9 +1672,9 @@ static void HU_drawChatLog(INT32 offset) // draw arrows to indicate that we can (or not) scroll. if (chat_scroll > 0) - V_DrawCharacter(chatx-9, ((justscrolledup) ? (chat_topy-1) : (chat_topy)), V_SNAPTOBOTTOM | V_SNAPTOLEFT | highlight | '\x1A', false); // up arrow + V_DrawCharacter(chatx-9, ((justscrolledup) ? (chat_topy-1) : (chat_topy)), CHATSNAP | highlight | '\x1A', false); // up arrow if (chat_scroll < chat_maxscroll) - V_DrawCharacter(chatx-9, chat_bottomy-((justscrolleddown) ? 5 : 6), V_SNAPTOBOTTOM | V_SNAPTOLEFT | highlight | '\x1B', false); // down arrow + V_DrawCharacter(chatx-9, chat_bottomy-((justscrolleddown) ? 5 : 6), CHATSNAP | highlight | '\x1B', false); // down arrow justscrolleddown = false; justscrolledup = false; @@ -1681,6 +1692,7 @@ static void HU_DrawChat(void) INT32 boxw = cv_chatwidth.value; INT32 t = 0, c = 0, y = chaty - (typelines*charheight); UINT32 i = 0, saylen = strlen(w_chat_buf); // You learn new things everyday! + UINT32 charcount = 0; INT32 cflag = 0; INT32 pm_offset = 0; // for cases when you type emote while also doing /pm size_t select_start = 0, select_end = 0; @@ -1712,7 +1724,7 @@ static void HU_DrawChat(void) cflag = V_GRAYMAP; // set text in gray if chat is muted. } - V_DrawFillConsoleMap(chatx, y-1, boxw, (typelines*charheight), 239 | V_SNAPTOBOTTOM | V_SNAPTOLEFT); + V_DrawFillConsoleMap(chatx, y-1, boxw, (typelines*charheight), 239 | CHATSNAP); while (talk[i]) { @@ -1720,7 +1732,7 @@ static void HU_DrawChat(void) ++i; else { - V_DrawChatCharacter(chatx + c + 2, y, talk[i] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|cflag, !cv_allcaps.value, V_GetStringColormap(talk[i]|cflag)); + V_DrawChatCharacter(chatx + c + 2, y, talk[i] |CHATSNAP|cflag, !cv_allcaps.value, V_GetStringColormap(talk[i]|cflag)); i++; } @@ -1738,7 +1750,7 @@ static void HU_DrawChat(void) typelines = 1; if ((w_chat.cursor == 0 || w_chat.length == 0) && hu_tick < 4) - V_DrawChatCharacter(chatx+2+c, y+1, '_'|V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, !cv_allcaps.value, NULL); + V_DrawChatCharacter(chatx+2+c, y+1, '_'|CHATSNAP|t, !cv_allcaps.value, NULL); if (w_chat.select != w_chat.cursor) { @@ -1755,17 +1767,23 @@ static void HU_DrawChat(void) if ((emote = M_VerifyEmote(w_chat_buf+i, &emotelen))) { - M_DrawEmote(chatx + c + 2, y-1, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT|t); + M_DrawEmote(chatx + c + 2, y-1, emote, CHATSNAP|t); c += EMOTEWIDTH - charwidth; i += emotelen-1; drawwidth = EMOTEWIDTH; + if (cv_chat_showlimit.value) + charcount += emotelen; } else if (w_chat_buf[i] >= HU_FONTSTART) //Hurdler: isn't it better like that? - V_DrawChatCharacter(chatx + c + 2, y, w_chat_buf[i] | V_SNAPTOBOTTOM|V_SNAPTOLEFT | t, !cv_allcaps.value, NULL); + { + V_DrawChatCharacter(chatx + c + 2, y, w_chat_buf[i] | CHATSNAP | t, !cv_allcaps.value, NULL); + if (cv_chat_showlimit.value) + charcount++; + } // Draw selection if (i >= select_start && i < select_end) - V_DrawFill(chatx + c + 2 - (drawwidth-charwidth), y-1, drawwidth, charheight, 103|V_TRANSLUCENT|V_SNAPTOBOTTOM|V_SNAPTOLEFT|t); + V_DrawFill(chatx + c + 2 - (drawwidth-charwidth), y-1, drawwidth, charheight, 103|V_TRANSLUCENT|CHATSNAP|t); ++i; @@ -1774,7 +1792,7 @@ static void HU_DrawChat(void) INT32 cursorx = (c+charwidth < boxw-charwidth) ? (chatx + 2 + c+charwidth) : (chatx+1); // we may have to go down. INT32 cursory = (cursorx != chatx+1) ? (y) : (y+charheight); if (hu_tick < 4) - V_DrawChatCharacter(cursorx, cursory+1, '_' |V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, !cv_allcaps.value, NULL); + V_DrawChatCharacter(cursorx, cursory+1, '_' |CHATSNAP|t, !cv_allcaps.value, NULL); if (cursorx == chatx+1 && saylen == i-1) // a weirdo hack { @@ -1792,6 +1810,13 @@ static void HU_DrawChat(void) } } + if (cv_chat_showlimit.value) + { + // Limit + const INT32 clr = ((HU_MAXMSGLEN - charcount) > 64 ? V_TRANSLUCENT : (charcount == HU_MAXMSGLEN ? V_REDMAP : V_YELLOWMAP)); + V_DrawSmallString(chatx, y+7, CHATSNAP|clr, va("%d/%d", charcount, HU_MAXMSGLEN)); + } + // handle /pm list. It's messy, horrible and I don't care. if (strnicmp(w_chat_buf, "/pm", 3) == 0 && vid.width >= 400 && !teamtalk) // 320x200 unsupported kthxbai { @@ -1827,6 +1852,7 @@ static void HU_DrawChat(void) { char nodenum[3]; UINT32 n; + // right, that's half important: (w_chat_buf[4] may be a space since /pm0 msg is perfectly acceptable!) if (!isdigit(w_chat_buf[3]) || !(isdigit(w_chat_buf[4]) || (w_chat_buf[4] == ' ') || (w_chat_buf[4] == 0))) break; @@ -1864,17 +1890,17 @@ static void HU_DrawChat(void) } // fill it like the chat so the text doesn't become hard to read because of the hud. - V_DrawFillConsoleMap(chatx + boxw + 2, p_dispy - (6*count), (longest_name_length+4)*4, 6, 239 | V_SNAPTOBOTTOM | V_SNAPTOLEFT); + V_DrawFillConsoleMap(chatx + boxw + 2, p_dispy - (6*count), (longest_name_length+4)*4, 6, 239 | CHATSNAP); - V_DrawSmallString(chatx + boxw + 4, p_dispy - (6*count), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, va("\x82%d\x80 - %s", i, player_names[i])); + V_DrawSmallString(chatx + boxw + 4, p_dispy - (6*count), CHATSNAP|V_ALLOWLOWERCASE, va("\x82%d\x80 - %s", i, player_names[i])); count++; } if (count == 0) // no results. { pm_offset = 48 + 2; - V_DrawFillConsoleMap(chatx + boxw + 2, p_dispy - (6*count), 48, 6, 239 | V_SNAPTOBOTTOM | V_SNAPTOLEFT); // fill it like the chat so the text doesn't become hard to read because of the hud. - V_DrawSmallString(chatx + boxw + 4, p_dispy - (6*count), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, "NO RESULT."); + V_DrawFillConsoleMap(chatx + boxw + 2, p_dispy - (6*count), 48, 6, 239 | CHATSNAP); // fill it like the chat so the text doesn't become hard to read because of the hud. + V_DrawSmallString(chatx + boxw + 4, p_dispy - (6*count), CHATSNAP|V_ALLOWLOWERCASE, "NO RESULT."); } else { @@ -1926,15 +1952,15 @@ static void HU_DrawChat(void) while ((suggest = M_FindEmote(complete, complete_len, skip)) != NULL) { - V_DrawFillConsoleMap(chatx + boxw + pm_offset + 2, suggesty - (7*skip), emote_suggest_boxw, 6, V_SNAPTOBOTTOM|V_SNAPTOLEFT); + V_DrawFillConsoleMap(chatx + boxw + pm_offset + 2, suggesty - (7*skip), emote_suggest_boxw, 6, CHATSNAP); // Highlight currently suggested emote int hlflag = 0; if (skip == emote_autocomplete.skip && emote_autocomplete.complete[0]) hlflag = V_YELLOWMAP; - V_DrawSmallString(chatx + boxw + pm_offset + 4 + EMOTEWIDTH, suggesty - (7*skip), hlflag|V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, va(":%s:", suggest->name)); - M_DrawEmote(chatx + boxw + pm_offset + 2, suggesty - skip*7, suggest, V_SNAPTOBOTTOM|V_SNAPTOLEFT); + V_DrawSmallString(chatx + boxw + pm_offset + 4 + EMOTEWIDTH, suggesty - (7*skip), hlflag|CHATSNAP|V_ALLOWLOWERCASE, va(":%s:", suggest->name)); + M_DrawEmote(chatx + boxw + pm_offset + 2, suggesty - skip*7, suggest, CHATSNAP); ++skip; } @@ -1948,6 +1974,7 @@ static void HU_DrawChat(void) static void HU_DrawChat_Old(void) { INT32 t = 0, c = 0, y = HU_INPUTY; + UINT32 charcount = 0; size_t i = 0; const char *ntalk = "Say: ", *ttalk = "Say-Team: "; const char *talk = ntalk; @@ -1993,11 +2020,17 @@ static void HU_DrawChat_Old(void) { M_DrawScaledEmote((HU_INPUTX + c)<= HU_FONTSTART) //Hurdler: isn't it better like that? { //charwidth = hu_font[w_chat[i]-HU_FONTSTART]->width * con_scalefactor; V_DrawCharacter(HU_INPUTX + c, y, w_chat_buf[i] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value); + + if (cv_chat_showlimit.value) + charcount++; } // Draw selection @@ -2010,7 +2043,7 @@ static void HU_DrawChat_Old(void) { INT32 cursorx = (HU_INPUTX+c+charwidth < vid.width) ? (HU_INPUTX + c + charwidth) : (HU_INPUTX); // we may have to go down. INT32 cursory = (cursorx != HU_INPUTX) ? (y) : (y+charheight); - V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value); + V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' | cv_constextsize.value | V_NOSCALESTART |t, !cv_allcaps.value); } c += charwidth; @@ -2020,6 +2053,24 @@ static void HU_DrawChat_Old(void) y += charheight; } } + + // console chat users are FINALLY being fed! + if (cv_chat_showlimit.value) + { + const char *lim = va(" (%i/%i)", charcount, HU_MAXMSGLEN); + for (i = 0; lim[i]; i++) + { + V_DrawCharacter(HU_INPUTX + c, y, lim[i] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value); + + c += charwidth; + if (c >= vid.width) // text wrapping + { + c = 0; + y += charheight; + } + } + } + } static void HU_DrawCEcho(void) diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 30dfddc0c..8cfd650cb 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -88,6 +88,10 @@ extern patch_t *tallminus; // set true whenever the tab rankings are being shown for any reason extern boolean hu_showscores; +extern consvar_t cv_chat_xoffset; +extern consvar_t cv_chat_yoffset; +extern consvar_t cv_chat_showlimit; + // init heads up data at game startup. void HU_Init(void); From d99c272a7933b721bc6231c409ff7d3ba5ec63cf Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 23:14:32 +0200 Subject: [PATCH 38/39] have textboxes "reserve" space for cursor so it wont draw outside the textbox but rather scrolls --- src/m_textinput.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_textinput.h b/src/m_textinput.h index ce296ffde..f5846059e 100644 --- a/src/m_textinput.h +++ b/src/m_textinput.h @@ -44,7 +44,7 @@ boolean M_TextInputHandle(textinput_t *input, INT32 key); // If currently typing something that looks like an existing emote, return suggestions for it boolean M_TextInputHandleEmotes(textinput_t *input, INT32 key, emote_autocomplete_t *autocomplete); -#define M_DrawTextInput(x, y, input, flags) M_DrawTextInputScroll((x), (y), (input), (flags), ((input)->buffer_size-1)*8) +#define M_DrawTextInput(x, y, input, flags) M_DrawTextInputScroll((x), (y), (input), (flags), ((input)->buffer_size-2)*8) void M_DrawTextInputScroll(INT32 x, INT32 y, textinput_t *input, INT32 flags, INT32 MAXINPUTWIDTH); #endif From 4f036c93129182b2c4065a08a274f5a5b066e6b6 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 28 Jun 2026 00:14:35 +0300 Subject: [PATCH 39/39] Fix setupm_ip going out of textbox when its not being edited --- src/m_menu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 499e5b9c4..e80fbf47e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7608,7 +7608,11 @@ Update the maxplayers label... // draw name string if (itemOn != 9) - V_DrawString(x+8,y+12, V_ALLOWLOWERCASE, setupm_ip); + { + char buf[28]; + strlcpy(buf, setupm_ip, sizeof(buf)); + V_DrawString(x+8,y+12, V_ALLOWLOWERCASE, buf); + } else M_DrawTextInputScroll(x+8, y+12, &setupm_input_ip, 0, SETUPM_IP_MAXSIZE);