From a608676bbd7dfc5dcebd942a8fd7f5f63da12622 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 5 May 2025 12:50:14 +0200 Subject: [PATCH 01/10] fix the fast pointonsides --- src/r_main.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/r_main.h b/src/r_main.h index 780e4db70..d3284764d 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -99,7 +99,7 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, // also use a mask to avoid branch prediction INT32 mask = (node->dy ^ node->dx ^ x ^ y) >> 31; return (mask & ((node->dy ^ x) < 0)) | // (left is negative) - (~mask & (FixedMul(y, node->dx>>FRACBITS) >= FixedMul(node->dy>>FRACBITS, x))); + (~mask & (FixedMul(y, node->dx>>FRACBITS) >= FixedMul(node->dy>>FRACBITS, x))); } // This is not as accurate @@ -107,7 +107,8 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSideFast(fixed_t x, fixed_t y, const node_t *node) { // use cross product to determine side quickly - return ((((INT64)y - node->y) * node->dx - ((INT64)x - node->x) * node->dy) >= 0); + INT64 v = ((INT64)y - node->y) * node->dx - ((INT64)x - node->x) * node->dy; + return v > 0; } FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line) @@ -118,7 +119,8 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t fixed_t ldy = line->v2->y - ly; // use cross product to determine side quickly - return ((((INT64)y - ly) * ldx - ((INT64)x - lx) * ldy) >= 0); + INT64 v = ((INT64)y - ly) * ldx - ((INT64)x - lx) * ldy; + return v > 0; } angle_t R_PointToAngle(fixed_t x, fixed_t y); From fa951475ba2927f535b4a2448b230b27f1f7581f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 6 May 2025 11:53:27 +0100 Subject: [PATCH 02/10] fix 32bit windoze compile everything needs time.h idk why it never errored out before lol --- src/i_tcp.c | 49 +++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index c27fa2480..8151abce0 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -49,34 +49,28 @@ #ifdef NONET #undef HAVE_MINIUPNPC #else -#ifdef USE_WINSOCK1 -#include -#elif !defined (SCOUW2) && !defined (SCOUW7) && !defined (__OS2__) -#ifndef USE_WINSOCK -#include -#endif //normal BSD API - -#ifndef USE_WINSOCK -#ifdef __APPLE_CC__ -#ifndef _BSD_SOCKLEN_T_ -#define _BSD_SOCKLEN_T_ -#endif //_BSD_SOCKLEN_T_ -#endif //__APPLE_CC__ -#include -#include -#endif //normal BSD API - -#ifndef USE_WINSOCK -#include -#include -#endif //normal BSD API - -#include #include +#ifdef USE_WINSOCK1 + #include +#else + #ifndef USE_WINSOCK + #include + #ifdef __APPLE_CC__ + #ifndef _BSD_SOCKLEN_T_ + #define _BSD_SOCKLEN_T_ + #endif //_BSD_SOCKLEN_T_ + #endif //__APPLE_CC__ + #include + #include + #include + #include + #endif //normal BSD API -#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) - #include -#endif // UNIXCOMMON + #include + + #if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) + #include + #endif // UNIXCOMMON #endif // !NONET #ifdef USE_WINSOCK @@ -123,7 +117,7 @@ #ifndef STATUS_INVALID_PARAMETER #define STATUS_INVALID_PARAMETER 0xC000000D #endif -#endif +#endif // USE_WINSOCK typedef union { @@ -168,7 +162,6 @@ static UINT8 UPNP_support = TRUE; #endif #include "i_addrinfo.h" - #define DEFAULTPORT "5029" #if defined (USE_WINSOCK) && !defined (NONET) From 0c7d50b38af1a4d491bfb629c6aaac030711c8cb Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 6 May 2025 17:08:24 +0200 Subject: [PATCH 03/10] call M_ClearMenus in D_StartTitle --- src/d_clisrv.c | 4 ++-- src/d_main.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 83e68a944..6b496c0e7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3156,8 +3156,6 @@ static void Command_connect(void) return; } - M_ClearMenus(true); - if (Playing() || demo.title || demo.playback) { if (demo.title || demo.playback) @@ -3175,6 +3173,8 @@ static void Command_connect(void) D_StartTitle(); } + else + M_ClearMenus(true); // close the menus // modified game check: no longer handled // we don't request a restart unless the filelist differs diff --git a/src/d_main.c b/src/d_main.c index 8aff70d97..6bd8b13f1 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -956,6 +956,8 @@ void D_StartTitle(void) return; } + M_ClearMenus(true); + // okay, stop now // (otherwise the game still thinks we're playing!) SV_StopServer(); From 7e5baeebafd006ccf4858b56d92b8448dcad575c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 6 May 2025 17:37:48 +0200 Subject: [PATCH 04/10] dont free item patches at levelload lol --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index e9ce093fc..dd024ecd0 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -647,7 +647,7 @@ void F_CreditDrawer(void) sc = FRACUNIT; // quick hack so I don't have to add another field to credits_pics } - V_DrawFixedPatch(credits_pics[i].x< Date: Tue, 6 May 2025 19:35:10 +0200 Subject: [PATCH 05/10] Revert "optimize MT_TUBEWAYPOINT" This reverts commit 3d0ac03f06b9027dc9467813e30a08b84c81158b. --- src/doomstat.h | 12 ---- src/p_mobj.c | 9 +-- src/p_polyobj.c | 154 +++++++++++++++++++++++++++++++++++++++++++++--- src/p_setup.c | 97 ------------------------------ src/p_spec.c | 150 +++++++++++++++++++++++++++++++++++++++++++--- src/p_user.c | 30 +++++++++- 6 files changed, 318 insertions(+), 134 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 54c6ae320..f8a3899ca 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -536,18 +536,6 @@ extern mapthing_t *playerstarts[MAXPLAYERS]; // Cooperative extern mapthing_t *bluectfstarts[MAXPLAYERS]; // CTF extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF -#define WAYPOINTSEQUENCESIZE 256 -#define NUMWAYPOINTSEQUENCES 256 -extern mobj_t *waypoints[NUMWAYPOINTSEQUENCES][WAYPOINTSEQUENCESIZE]; -extern UINT16 numwaypoints[NUMWAYPOINTSEQUENCES]; - -void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint); -mobj_t *P_GetFirstWaypoint(UINT8 sequence); -mobj_t *P_GetLastWaypoint(UINT8 sequence); -mobj_t *P_GetPreviousWaypoint(mobj_t *current, boolean wrap); -mobj_t *P_GetNextWaypoint(mobj_t *current, boolean wrap); -mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo); - // ===================================== // Internal parameters, used for engine. // ===================================== diff --git a/src/p_mobj.c b/src/p_mobj.c index 3fd74f4a7..3780ef949 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11466,14 +11466,9 @@ ML_NOCLIMB : Direction not controllable mobj->threshold = min(mthing->extrainfo, 7); break; case MT_TUBEWAYPOINT: - { - UINT8 sequence = mthing->angle >> 8; - UINT8 id = mthing->angle & 255; - mobj->health = id; - mobj->threshold = sequence; - P_AddWaypoint(sequence, id, mobj); + mobj->health = mthing->angle & 255; + mobj->threshold = mthing->angle >> 8; break; - } case MT_NIGHTSDRONE: if (mthing->angle > 0) mobj->health = mthing->angle; diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 629595068..53d975e8e 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1803,12 +1803,12 @@ void T_PolyObjMove(polymove_t *th) // void T_PolyObjWaypoint(polywaypoint_t *th) { + mobj_t *mo2; mobj_t *target = NULL; mobj_t *waypoint = NULL; - mobj_t *mo2; + thinker_t *wp; fixed_t adjustx, adjusty, adjustz; fixed_t momx, momy, momz, dist; - thinker_t *wp; INT32 start; polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); polyobj_t *oldpo = po; @@ -1825,7 +1825,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) #endif // check for displacement due to override and reattach when possible - if (!po->thinker) + if (po->thinker == NULL) po->thinker = &th->thinker; // Find out target first. @@ -1913,7 +1913,39 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { CONS_Debug(DBG_POLYOBJ, "Looking for next waypoint...\n"); - waypoint = (th->direction == -1) ? P_GetPreviousWaypoint(target, false) : P_GetNextWaypoint(target, false); + // Find next waypoint + for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) + { + if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + continue; + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)wp; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + + if (mo2->threshold != th->sequence) + continue; + + if (th->direction == -1) + { + if (mo2->health == target->health - 1) + { + waypoint = mo2; + break; + } + } + else + { + if (mo2->health == target->health + 1) + { + waypoint = mo2; + break; + } + } + } if (!waypoint && th->wrap) // If specified, wrap waypoints { @@ -1923,7 +1955,37 @@ void T_PolyObjWaypoint(polywaypoint_t *th) th->stophere = true; } - waypoint = (th->direction == -1) ? P_GetLastWaypoint(th->sequence) : P_GetFirstWaypoint(th->sequence); + for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) + { + if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + continue; + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)wp; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + + if (mo2->threshold != th->sequence) + continue; + + if (th->direction == -1) + { + if (waypoint == NULL) + waypoint = mo2; + else if (mo2->health > waypoint->health) + waypoint = mo2; + } + else + { + if (mo2->health == 0) + { + waypoint = mo2; + break; + } + } + } } else if (!waypoint && th->comeback) // Come back to the start { @@ -1932,7 +1994,38 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (!th->continuous) th->comeback = false; - waypoint = (th->direction == -1) ? P_GetPreviousWaypoint(target, false) : P_GetNextWaypoint(target, false); + for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) + { + if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + continue; + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)wp; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + + if (mo2->threshold != th->sequence) + continue; + + if (th->direction == -1) + { + if (mo2->health == target->health - 1) + { + waypoint = mo2; + break; + } + } + else + { + if (mo2->health == target->health + 1) + { + waypoint = mo2; + break; + } + } + } } } @@ -2382,9 +2475,11 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) polyobj_t *po; polyobj_t *oldpo; polywaypoint_t *th; + mobj_t *mo2; mobj_t *first = NULL; mobj_t *last = NULL; mobj_t *target = NULL; + thinker_t *wp; INT32 start; if (!(po = Polyobj_GetForNum(pwdata->polyObjNum))) @@ -2410,7 +2505,10 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) th->polyObjNum = pwdata->polyObjNum; th->speed = pwdata->speed; th->sequence = pwdata->sequence; // Used to specify sequence # - th->direction = pwdata->reverse ? -1 : 1; + if (pwdata->reverse) + th->direction = -1; + else + th->direction = 1; th->comeback = pwdata->comeback; th->continuous = pwdata->continuous; @@ -2418,8 +2516,46 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) th->stophere = false; // Find the first waypoint we need to use - first = (th->direction == -1) ? P_GetLastWaypoint(th->sequence) : P_GetFirstWaypoint(th->sequence); - last = (th->direction == -1) ? P_GetFirstWaypoint(th->sequence) : P_GetLastWaypoint(th->sequence); + for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) + { + if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + continue; + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)wp; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + + if (mo2->threshold != th->sequence) + continue; + + if (th->direction == -1) // highest waypoint # + { + if (mo2->health == 0) + last = mo2; + else + { + if (first == NULL) + first = mo2; + else if (mo2->health > first->health) + first = mo2; + } + } + else // waypoint 0 + { + if (mo2->health == 0) + first = mo2; + else + { + if (last == NULL) + last = mo2; + else if (mo2->health > last->health) + last = mo2; + } + } + } if (!first) { diff --git a/src/p_setup.c b/src/p_setup.c index a5cf90a2d..fe3a0d7fc 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -149,101 +149,6 @@ mapthing_t *playerstarts[MAXPLAYERS]; mapthing_t *bluectfstarts[MAXPLAYERS]; mapthing_t *redctfstarts[MAXPLAYERS]; -// Maintain waypoints -mobj_t *waypoints[NUMWAYPOINTSEQUENCES][WAYPOINTSEQUENCESIZE]; -UINT16 numwaypoints[NUMWAYPOINTSEQUENCES]; - -void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint) -{ - waypoints[sequence][id] = waypoint; - if (id >= numwaypoints[sequence]) - numwaypoints[sequence] = id + 1; -} - -static void P_ResetWaypoints(void) -{ - UINT16 sequence, id; - for (sequence = 0; sequence < NUMWAYPOINTSEQUENCES; sequence++) - { - for (id = 0; id < numwaypoints[sequence]; id++) - waypoints[sequence][id] = NULL; - - numwaypoints[sequence] = 0; - } -} - -mobj_t *P_GetFirstWaypoint(UINT8 sequence) -{ - return waypoints[sequence][0]; -} - -mobj_t *P_GetLastWaypoint(UINT8 sequence) -{ - return waypoints[sequence][numwaypoints[sequence] - 1]; -} - -mobj_t *P_GetPreviousWaypoint(mobj_t *current, boolean wrap) -{ - UINT8 sequence = current->threshold; - UINT8 id = current->health; - - if (id == 0) - { - if (!wrap) - return NULL; - - id = numwaypoints[sequence] - 1; - } - else - id--; - - return waypoints[sequence][id]; -} - -mobj_t *P_GetNextWaypoint(mobj_t *current, boolean wrap) -{ - UINT8 sequence = current->threshold; - UINT8 id = current->health; - - if (id == numwaypoints[sequence] - 1) - { - if (!wrap) - return NULL; - - id = 0; - } - else - id++; - - return waypoints[sequence][id]; -} - -mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo) -{ - UINT8 wp; - mobj_t *mo2, *result = NULL; - fixed_t bestdist = 0; - fixed_t curdist; - - for (wp = 0; wp < numwaypoints[sequence]; wp++) - { - mo2 = waypoints[sequence][wp]; - - if (!mo2) - continue; - - curdist = P_AproxDistance(P_AproxDistance(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z); - - if (result && curdist > bestdist) - continue; - - result = mo2; - bestdist = curdist; - } - - return result; -} - // Global state for PartialAddWadFile/MultiSetupWadFiles // Might be replacable with parameters, but non-trivial when the functions are called on separate tics static SINT8 partadd_stage = -1; @@ -3051,8 +2956,6 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) memset(playerstarts, 0, sizeof(playerstarts)); memset(skyboxmo, 0, sizeof(skyboxmo)); - P_ResetWaypoints(); - P_MapStart(); if (lastloadedmaplumpnum) diff --git a/src/p_spec.c b/src/p_spec.c index e14d09333..f12d5b00f 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3737,7 +3737,9 @@ DoneSection2: INT32 sequence; fixed_t speed; INT32 lineindex; + thinker_t *th; mobj_t *waypoint = NULL; + mobj_t *mo2; angle_t an; if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) @@ -3756,7 +3758,27 @@ DoneSection2: speed = abs(lines[lineindex].dx)/8; sequence = abs(lines[lineindex].dy)>>FRACBITS; - waypoint = P_GetFirstWaypoint(sequence); + // scan the thinkers + // to find the first waypoint + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + if (mo2->threshold != sequence) + continue; + if (mo2->health != 0) + continue; + + waypoint = mo2; + break; + } if (!waypoint) { @@ -3796,7 +3818,9 @@ DoneSection2: INT32 sequence; fixed_t speed; INT32 lineindex; + thinker_t *th; mobj_t *waypoint = NULL; + mobj_t *mo2; angle_t an; if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) @@ -3815,7 +3839,27 @@ DoneSection2: speed = -(abs(lines[lineindex].dx)/8); // Negative means reverse sequence = abs(lines[lineindex].dy)>>FRACBITS; - waypoint = P_GetLastWaypoint(sequence); + // scan the thinkers + // to find the last waypoint + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + if (mo2->threshold != sequence) + continue; + + if (!waypoint) + waypoint = mo2; + else if (mo2->health > waypoint->health) + waypoint = mo2; + } if (!waypoint) { @@ -3966,12 +4010,15 @@ DoneSection2: INT32 sequence; fixed_t speed; INT32 lineindex; + thinker_t *th; mobj_t *waypointmid = NULL; mobj_t *waypointhigh = NULL; mobj_t *waypointlow = NULL; + mobj_t *mo2; mobj_t *closest = NULL; line_t junk; vertex_t v1, v2, resulthigh, resultlow; + mobj_t *highest = NULL; if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) break; @@ -4011,16 +4058,104 @@ DoneSection2: // Determine the closest spot on the line between the three waypoints // Put player at that location. - waypointmid = P_GetClosestWaypoint(sequence, player->mo); + // scan the thinkers + // to find the first waypoint + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; - if (!waypointmid) + mo2 = (mobj_t *)th; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + + if (mo2->threshold != sequence) + continue; + + if (!highest) + highest = mo2; + else if (mo2->health > highest->health) // Find the highest waypoint # in case we wrap + highest = mo2; + + if (closest && P_AproxDistance(P_AproxDistance(player->mo->x-mo2->x, player->mo->y-mo2->y), + player->mo->z-mo2->z) > P_AproxDistance(P_AproxDistance(player->mo->x-closest->x, + player->mo->y-closest->y), player->mo->z-closest->z)) + continue; + + // Found a target + closest = mo2; + } + + waypointmid = closest; + + closest = NULL; + + if (waypointmid == NULL) { CONS_Debug(DBG_GAMELOGIC, "ERROR: WAYPOINT(S) IN SEQUENCE %d NOT FOUND.\n", sequence); break; } - waypointlow = P_GetPreviousWaypoint(waypointmid, true); - waypointhigh = P_GetNextWaypoint(waypointmid, true); + // Find waypoint before this one (waypointlow) + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + + if (mo2->threshold != sequence) + continue; + + if (waypointmid->health == 0) + { + if (mo2->health != highest->health) + continue; + } + else if (mo2->health != waypointmid->health - 1) + continue; + + // Found a target + waypointlow = mo2; + break; + } + + // Find waypoint after this one (waypointhigh) + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) + continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + + if (mo2->threshold != sequence) + continue; + + if (waypointmid->health == highest->health) + { + if (mo2->health != 0) + continue; + } + else if (mo2->health != waypointmid->health + 1) + continue; + + // Found a target + waypointhigh = mo2; + break; + } CONS_Debug(DBG_GAMELOGIC, "WaypointMid: %d; WaypointLow: %d; WaypointHigh: %d\n", waypointmid->health, waypointlow ? waypointlow->health : -1, waypointhigh ? waypointhigh->health : -1); @@ -4071,7 +4206,6 @@ DoneSection2: if (lines[lineindex].flags & ML_EFFECT1) // Don't wrap { - mobj_t *highest = P_GetLastWaypoint(sequence); highest->flags |= MF_SLIDEME; } @@ -4083,7 +4217,7 @@ DoneSection2: player->mo->y = resulthigh.y; player->mo->z = resulthigh.z - P_GetPlayerHeight(player); } - else if ((lines[lineindex].flags & ML_EFFECT1) && waypointmid->health == numwaypoints[sequence] - 1) + else if ((lines[lineindex].flags & ML_EFFECT1) && waypointmid->health == highest->health) { closest = waypointmid; player->mo->x = resultlow.x; diff --git a/src/p_user.c b/src/p_user.c index af1e5c2fc..374443042 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2528,7 +2528,10 @@ static void P_MovePlayer(player_t *player) static void P_DoZoomTube(player_t *player) { + INT32 sequence; fixed_t speed; + thinker_t *th; + mobj_t *mo2; mobj_t *waypoint = NULL; fixed_t dist; boolean reverse; @@ -2544,6 +2547,8 @@ static void P_DoZoomTube(player_t *player) speed = abs(player->speed); + sequence = player->mo->tracer->threshold; + // change slope dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z); @@ -2575,7 +2580,30 @@ static void P_DoZoomTube(player_t *player) CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n"); // Find next waypoint - waypoint = reverse ? P_GetPreviousWaypoint(player->mo->tracer, false) : P_GetNextWaypoint(player->mo->tracer, false); + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + continue; + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + + if (mo2->threshold != sequence) + continue; + + if (reverse && mo2->health != player->mo->tracer->health - 1) + continue; + + if (!reverse && mo2->health != player->mo->tracer->health + 1) + continue; + + waypoint = mo2; + break; + } if (waypoint) { From c0d8f4fbfe83069fb239ce27fd1c0b8a357c3085 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 6 May 2025 19:42:32 +0200 Subject: [PATCH 06/10] idk where this stuff came from but we can access delayremoved thinkers in kart cause bleh --- src/p_polyobj.c | 8 -------- src/p_spec.c | 10 ---------- src/p_user.c | 2 -- 3 files changed, 20 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 53d975e8e..7b2a45b3b 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1918,8 +1918,6 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; - if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)wp; @@ -1959,8 +1957,6 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; - if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)wp; @@ -1998,8 +1994,6 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; - if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)wp; @@ -2520,8 +2514,6 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) { if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; - if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)wp; diff --git a/src/p_spec.c b/src/p_spec.c index f12d5b00f..40e47bf83 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3764,8 +3764,6 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -3845,8 +3843,6 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -4064,8 +4060,6 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -4104,8 +4098,6 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; @@ -4133,8 +4125,6 @@ DoneSection2: { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; diff --git a/src/p_user.c b/src/p_user.c index 374443042..5d69dc381 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2584,8 +2584,6 @@ static void P_DoZoomTube(player_t *player) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker continue; - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; mo2 = (mobj_t *)th; From 5cc6743328d7bd5bcde269d3d0cab1c51690ad58 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 6 May 2025 22:06:33 +0200 Subject: [PATCH 07/10] dont keepmusic music that is not flagged as keep on death uuuuuggggghhhhhhhhhhhh --- src/s_sound.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/s_sound.c b/src/s_sound.c index 6aa3f74ae..922d864d5 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1945,6 +1945,10 @@ static boolean S_CheckMusicException(void) if (stricmp(music.name, mapmusic.name)) return true; + // dumb hack but dont keepmusic music that is supposed to reset + if (music.flags & MUSIC_RELOADRESET) + return true; + // in case somehow the mapmusic was replaced with smth we dont want to keep for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) { From f98e7b13f41330e2f8870f2acf60ddc66f94986f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 8 May 2025 10:24:03 +0200 Subject: [PATCH 08/10] cleanup dpad scroll stuff even more mostly just to make this more readable --- src/d_main.c | 66 +++++++++++++++++++++++++++++----------------------- src/m_menu.c | 30 +++++++++--------------- src/m_menu.h | 10 ++++++++ 3 files changed, 58 insertions(+), 48 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 6bd8b13f1..fd92739b9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -166,48 +166,56 @@ UINT8 ctrldown = 0; // 0x1 left, 0x2 right UINT8 altdown = 0; // 0x1 left, 0x2 right boolean capslock = 0; // gee i wonder what this does. -static void D_PadMenuScrollInput(int input) +static void D_PadMenuScrollInput(UINT8 input) { - event_t myev = {0, 0, 0, 0}; - myev.type = ev_keydown; - myev.data1 = input; - D_PostEvent(&myev); // put into eventlist + event_t dpadev; + memset(&dpadev, 0, sizeof(event_t)); + dpadev.type = ev_keydown; + + switch (input) + { + case DPAD_UP: + dpadev.data1 = KEY_UPARROW; + break; + case DPAD_DOWN: + dpadev.data1 = KEY_DOWNARROW; + break; + case DPAD_LEFT: + dpadev.data1 = KEY_LEFTARROW; + break; + case DPAD_RIGHT: + dpadev.data1 = KEY_RIGHTARROW; + break; + } + + D_PostEvent(&dpadev); // put into eventlist } -#define SCROLLDELAY 19 // TICRATE * ( (k+2) (1 - [wz + h + j - q]^2 - [(gk + 2g + k + 1)(h + j) + h - z]^2 - [16(k + 1)^3(k + 2)(n + 1)^2 + 1 - f^2]^2 calculated by my butt +#define SCROLLDELAY 19 -// this is absolutely awful and i hate it lmao -// but le hAx0r to make dpad also be able to scroll in the menu +// Check if any dpad button is held +// and pass it to the eventlist static void D_GamePadMenuScrollTicker(void) { - static SINT8 menuInputDelayTimer = 0; - int key = 0; // butt-on output + static UINT8 menuInputDelayTimer = 0; if (dedicated) return; - // wish i had a switch ono - if (DPADUPSCROLL) - key = KEY_UPARROW; - else if (DPADDOWNSCROLL) - key = KEY_DOWNARROW; - else if (DPADLEFTSCROLL) - key = KEY_LEFTARROW; - else if (DPADRIGHTSCROLL) - key = KEY_RIGHTARROW; - - if (key) + for (UINT8 i = 0; i < 4; i++) { - if (menuInputDelayTimer < SCROLLDELAY) - menuInputDelayTimer++; + if (dpadscrollstate[i]) + { + if (menuInputDelayTimer < SCROLLDELAY) + menuInputDelayTimer++; + else if (menuInputDelayTimer == SCROLLDELAY) + D_PadMenuScrollInput(i); - if (menuInputDelayTimer == SCROLLDELAY) - D_PadMenuScrollInput(key); - } - else - { - menuInputDelayTimer = 0; + return; + } } + + menuInputDelayTimer = 0; } #undef SCROLLDELAY diff --git a/src/m_menu.c b/src/m_menu.c index 17bbdd65d..a87033997 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3822,10 +3822,7 @@ static void Command_Manual_f(void) itemOn = 0; } -boolean DPADUPSCROLL = false; -boolean DPADDOWNSCROLL = false; -boolean DPADLEFTSCROLL = false; -boolean DPADRIGHTSCROLL = false; +boolean dpadscrollstate[4] = {false, false, false, false}; // // M_Responder @@ -3833,7 +3830,6 @@ boolean DPADRIGHTSCROLL = false; boolean M_Responder(event_t *ev) { INT32 ch = -1; -// INT32 i; static tic_t joywaitx = 0, joywaity = 0, joywaitaccel = 0, mousewait = 0; static INT32 pjoyx = 0, pjoyy = 0, pjoyaccel = 0; static INT32 pmousex = 0, pmousey = 0; @@ -3874,19 +3870,19 @@ boolean M_Responder(event_t *ev) break; case KEY_HAT1: ch = KEY_UPARROW; - DPADUPSCROLL = true; + dpadscrollstate[DPAD_UP] = true; break; case KEY_HAT1 + 1: ch = KEY_DOWNARROW; - DPADDOWNSCROLL = true; + dpadscrollstate[DPAD_DOWN] = true; break; case KEY_HAT1 + 2: ch = KEY_LEFTARROW; - DPADLEFTSCROLL = true; + dpadscrollstate[DPAD_LEFT] = true; break; case KEY_HAT1 + 3: ch = KEY_RIGHTARROW; - DPADRIGHTSCROLL = true; + dpadscrollstate[DPAD_RIGHT] = true; break; } @@ -3907,22 +3903,23 @@ boolean M_Responder(event_t *ev) switch (ev->data1) // if you let go of those set those to false { case KEY_HAT1: - DPADUPSCROLL = false; + dpadscrollstate[DPAD_UP] = false; break; case KEY_HAT1 + 1: - DPADDOWNSCROLL = false; + dpadscrollstate[DPAD_DOWN] = false; break; case KEY_HAT1 + 2: - DPADLEFTSCROLL = false; + dpadscrollstate[DPAD_LEFT] = false; break; case KEY_HAT1 + 3: - DPADRIGHTSCROLL = false; + dpadscrollstate[DPAD_RIGHT] = false; break; } } else if (menuactive) { tic_t thistime = I_GetTime(); + if (ev->type == ev_joystick) { const INT32 jxdeadzone = ((JOYAXISRANGE-1) * max(cv_xdeadzone[0].value, FRACUNIT/2)) >> FRACBITS; @@ -4376,7 +4373,6 @@ boolean M_Responder(event_t *ev) // special responder for demos boolean M_DemoResponder(event_t *ev) { - INT32 ch = -1; // cur event data boolean eatinput = false; // :omnom: @@ -4562,11 +4558,7 @@ void M_StartControlPanel(void) menuactive = true; // reset those just in case the game missed the keyup event - DPADUPSCROLL = false; - DPADDOWNSCROLL = false; - DPADLEFTSCROLL = false; - DPADRIGHTSCROLL = false; - // + memset(dpadscrollstate, false, sizeof(dpadscrollstate)); if (demo.playback) { diff --git a/src/m_menu.h b/src/m_menu.h index 45f0fbbf9..126d59e1b 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -33,6 +33,16 @@ extern boolean forceshowhud; // Does all the real work of the menu interaction. boolean M_Responder(event_t *ev); +// for scrolling through menus with controllers +extern boolean dpadscrollstate[4]; +enum +{ + DPAD_UP, + DPAD_DOWN, + DPAD_LEFT, + DPAD_RIGHT +}; + // Called by main loop, runs for demo playback. If this returns true, nullify any further user input. boolean M_DemoResponder(event_t *ev); From 9747eab9f3e41d0646db3f8ee1880044eadef86b Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 8 May 2025 17:20:21 +0300 Subject: [PATCH 09/10] Add I_Sleep into CONS_Error so if a wad file was not found game won't take 100% of cpu --- src/console.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/console.c b/src/console.c index b97ba9934..7f417625b 100644 --- a/src/console.c +++ b/src/console.c @@ -1334,7 +1334,12 @@ void CONS_Error(const char *msg) // dirty quick hack, but for the good cause while (I_GetKey() != KEY_ENTER) + { + // Sleep so we don't take too much of cpu usage + I_Sleep(1.f/TICRATE*1000); + I_OsPolling(); + } } //====================================================================== From 2fbc1140c4eb8ff4d09e141dd9467cbd93fa75f5 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 8 May 2025 17:39:27 +0300 Subject: [PATCH 10/10] Fix NOWH compilation (only check if renderer supports palette if HWRENDER is defined, otherwise run subpalette code unconditionally) --- src/v_video.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/v_video.c b/src/v_video.c index 34bc9f296..65fcc3440 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -550,7 +550,9 @@ void V_SetPalette(INT32 palettenum) if (!pLocalPalette) V_ReloadPalette(); +#ifdef HWRENDER if (rendermode == render_soft || (rendermode == render_opengl && HWR_ShouldUsePaletteRendering())) // opengl without paletterendering hates subpalettes +#endif { if (palettenum == 0) {