From ef93209d409816f2104d40bc12a942073e1072cf Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 11:23:09 +0200 Subject: [PATCH 01/35] delet bunch of stuff --- src/d_clisrv.c | 5 ----- src/d_clisrv.h | 1 - src/doomstat.h | 2 -- src/info.c | 2 +- src/p_setup.c | 15 ++++----------- src/sdl/i_system.c | 6 ------ 6 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 97b6c9358..4a2a0cc0f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -539,11 +539,6 @@ void D_ResetTiccmds(void) D_Clearticcmd(textcmds[i]->tic); } -ticcmd_t *D_LocalTiccmd(UINT8 ss) -{ - return &localcmds[ss][0]; -} - void SendKick(UINT8 playernum, UINT8 msg) { UINT8 buf[2]; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 8ad038a36..65884362b 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -662,7 +662,6 @@ extern UINT8 playernode[MAXPLAYERS]; INT32 D_NumPlayers(void); void D_ResetTiccmds(void); -ticcmd_t *D_LocalTiccmd(UINT8 ss); tic_t GetLag(INT32 node); //UINT8 GetFreeXCmdSize(UINT8 playerid); diff --git a/src/doomstat.h b/src/doomstat.h index 6e1aa2485..f6e708be6 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -299,8 +299,6 @@ typedef struct #define LF_NORELOAD 8 ///< Don't reload level on death #define LF_NOZONE 16 ///< Don't include "ZONE" on level title #define LF_SECTIONRACE 32 ///< Section race level -#define LF_SUBTRACTNUM 64 ///< Use subtractive position number (for bright levels) - #define LF2_HIDEINMENU 1 ///< Hide in the multiplayer menu #define LF2_HIDEINSTATS 2 ///< Hide in the statistics screen diff --git a/src/info.c b/src/info.c index fcf0029e9..7afc76bf6 100644 --- a/src/info.c +++ b/src/info.c @@ -2614,7 +2614,7 @@ state_t states[NUMSTATES] = {SPR_KINV, FF_FULLBRIGHT|1, 1, {NULL}, 0, 0, S_KARTINVULN_SMALL3}, // S_KARTINVULN_SMALL2 {SPR_KINV, FF_FULLBRIGHT|2, 1, {NULL}, 0, 0, S_KARTINVULN_SMALL4}, // S_KARTINVULN_SMALL3 {SPR_KINV, FF_FULLBRIGHT|3, 1, {NULL}, 0, 0, S_KARTINVULN_SMALL5}, // S_KARTINVULN_SMALL4 - {SPR_KINV, FF_FULLBRIGHT|4, 1, {NULL}, 0, 0, S_NULL}, // S_KARTINVULN_SMALL5 + {SPR_KINV, FF_FULLBRIGHT|4, 1, {NULL}, 0, 0, S_NULL}, // S_KARTINVULN_SMALL5 {SPR_KINV, FF_FULLBRIGHT|1, 1, {NULL}, 0, 0, S_KARTINVULN_LARGE2}, // S_KARTINVULN_LARGE1 {SPR_KINV, FF_FULLBRIGHT|2, 1, {NULL}, 0, 0, S_KARTINVULN_LARGE3}, // S_KARTINVULN_LARGE2 diff --git a/src/p_setup.c b/src/p_setup.c index 5d13df8b5..e4c22f253 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -615,10 +615,10 @@ static void P_SetupDirectionalLight(void) if (gamemap != oldmap || encoremode != oldencore || reinitmaplight) { - maplighting.contrast = M_RandomRange(0, 58); - maplighting.backlight = 0; - maplighting.directional = M_RandomRange(0, 1); // either on or off - maplighting.angle = M_RandomRange(-382, 382); + lighting->light_contrast = M_RandomRange(0, 58); + lighting->sprite_backlight = 0; + lighting->use_light_angle = M_RandomRange(0, 1); // either on or off + lighting->light_angle = M_RandomRange(-382, 382); reinitmaplight = false; } @@ -627,13 +627,6 @@ static void P_SetupDirectionalLight(void) oldencore = encoremode; return; } - else if (lighting->use_custom_light == false) - { - maplighting.contrast = 8; - maplighting.backlight = 0; - maplighting.directional = false; - maplighting.angle = 0; - } maplighting.contrast = lighting->light_contrast; maplighting.backlight = lighting->sprite_backlight; diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 1262707a8..b622c4c45 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -501,9 +501,6 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) write_backtrace(BT_CRASH_REASON_SIGNAL(num)); #endif - if (demo.recording) - G_SaveDemo(); - I_ReportSignal(num, 0); I_ShutdownSystem(); signal(num, SIG_DFL); //default signal action @@ -884,9 +881,6 @@ static void signal_handler_child(INT32 num) write_backtrace(BT_CRASH_REASON_SIGNAL(num)); #endif - if (demo.recording) - G_SaveDemo(); - signal(num, SIG_DFL); //default signal action raise(num); } From abba2a9eac194fb0a49aa593d246c465d5ff586c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:09:03 +0200 Subject: [PATCH 02/35] fix cv_set being called for allowsaturnjoin before its registered --- src/d_netcmd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ebbf91736..3b53dd8c4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -752,6 +752,11 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_killingdead); // d_clisrv +#ifndef NONET +#ifdef SATURNJOIN + CV_RegisterVar(&cv_allownewsaturnplayer); // need to register it before cv_maxplayers && cv_allownewplayer +#endif +#endif CV_RegisterVar(&cv_maxplayers); CV_RegisterVar(&cv_resynchattempts); #ifdef SATURNPAK @@ -765,9 +770,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_httpsource); #ifndef NONET CV_RegisterVar(&cv_allownewplayer); -#ifdef SATURNJOIN - CV_RegisterVar(&cv_allownewsaturnplayer); -#endif + CV_RegisterVar(&cv_joinrefusemessage); CV_RegisterVar(&cv_chatlogsize); #ifdef VANILLAJOINNEXTROUND From 0b515939ad4719d3f55cbfc42ecb181cc35c8695 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:10:07 +0200 Subject: [PATCH 03/35] we have a global to check if config was loaded --- src/d_main.c | 6 ++++-- src/m_misc.c | 7 +------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ad65138e8..44511b87d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -147,7 +147,7 @@ INT32 eventhead, eventtail; boolean dedicated = false; -boolean loaded_config = false; +boolean loaded_config = false; // true once config.cfg loaded AND executed // // D_PostEvent @@ -1881,7 +1881,9 @@ void D_SRB2Main(void) savedata.lives = 0; // flag this as not-used - loaded_config = true; // so pallettechange doesent get called 500 times at startup lol + // make sure I_Quit() will write back the correct config + // (do not write back the config if it crash before) + loaded_config = true; // so palettechange doesent get called 500 times at startup lol //------------------------------------------------ COMMAND LINE PARAMS diff --git a/src/m_misc.c b/src/m_misc.c index ca4b745ed..ff9892464 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -443,7 +443,6 @@ char configfile[MAX_WADPATH]; // ========================================================================== // CONFIGURATION // ========================================================================== -static boolean gameconfig_loaded = false; // true once config.cfg loaded AND executed /** Saves a player's config, possibly to a particular file. * @@ -548,10 +547,6 @@ void M_FirstLoadConfig(void) // don't filter anymore vars and don't let this convsvar be changed COM_BufInsertText(va("%s \"%d\"\n", cv_execversion.name, EXECVERSION)); CV_ToggleExecVersion(false); - - // make sure I_Quit() will write back the correct config - // (do not write back the config if it crash before) - gameconfig_loaded = true; } /** Saves the game configuration. @@ -565,7 +560,7 @@ void M_SaveConfig(const char *filename) char backupfile[MAX_WADPATH+4]; // make sure not to write back the config until it's been correctly loaded - if (!gameconfig_loaded) + if (!loaded_config) return; // Create backup of the config file From 0ceeac4726cf799ea7f4f645adb7527bd8b63ab8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:23:11 +0200 Subject: [PATCH 04/35] nooo PARANOIA dont set our thinker next to NULL --- src/p_tick.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 8fbdf8b6a..91f40c623 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -243,13 +243,19 @@ static thinker_t *currentthinker; void P_RemoveThinkerDelayed(thinker_t *thinker) { #ifdef PARANOIA - if (thinker->next) - thinker->next = NULL; - else if (thinker->references) // Usually gets cleared up in one frame; what's going on here, then? - CONS_Printf("Number of potentially faulty references: %d\n", thinker->references); -#endif - if (thinker->references) +#define BEENAROUNDBIT (0x40000000) // has to be sufficiently high that it's unlikely to happen in regular gameplay. If you change this, pay attention to the bit pattern of INT32_MIN. + if (thinker->references & ~BEENAROUNDBIT) + { + if (thinker->references & BEENAROUNDBIT) // Usually gets cleared up in one frame; what's going on here, then? + CONS_Printf("Number of potentially faulty references: %d\n", (thinker->references & ~BEENAROUNDBIT)); + thinker->references |= BEENAROUNDBIT; return; + } +#undef BEENAROUNDBIT +#else + if (thinker->references != 0) + return; +#endif /* Remove from main thinker list */ thinker_t *next = thinker->next; From cd7177682ab8696e6c4fdf72d0c8175f0e1c4b2d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 13:43:55 +0200 Subject: [PATCH 05/35] fix P_RemoveSavegameMobj triggering assert in P_UnlinkThinker --- src/p_mobj.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index a743f05fc..66d4493ca 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10163,8 +10163,10 @@ void P_FreePrecipMobj(precipmobj_t *mobj) // Clearing out stuff for savegames void P_RemoveSavegameMobj(mobj_t *mobj) { + thinker_t *th = (thinker_t*)mobj; + // unlink from sector and block lists - if (((thinker_t *)mobj)->function.acp1 == (actionf_p1)P_NullPrecipThinker) + if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker) { P_UnsetPrecipThingPosition((precipmobj_t *)mobj); } @@ -10185,9 +10187,13 @@ void P_RemoveSavegameMobj(mobj_t *mobj) S_StopSound(mobj); R_RemoveMobjInterpolator(mobj); + // just set its reference count to 0 to not trigger the assert in P_UnlinkThinker + if (th->references != 0) + th->references = 0; + // free block // Here we use the same code as R_RemoveThinkerDelayed, but without reference counting (we're removing everything so it shouldn't matter) and without touching currentthinker since we aren't in P_RunThinkers - P_UnlinkThinker((thinker_t*)mobj); + P_UnlinkThinker(th); } static CV_PossibleValue_t respawnitemtime_cons_t[] = {{1, "MIN"}, {300, "MAX"}, {0, NULL}}; From 55704f2ba2a9ff6ca31b911a5154c0a72dabe1ff Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 16:02:41 +0200 Subject: [PATCH 06/35] port RRs improved paranoia thinker/mobj prints https://git.srb2.org/KartKrew/RingRacers/-/commit/509a023329ea1cd583c500a3287c488e5ee3e3a6 https://git.srb2.org/KartKrew/RingRacers/-/commit/17aaf178d587970a3a845aa6c2f3807077996a77 --- src/d_think.h | 6 +++ src/p_mobj.c | 8 ++++ src/p_polyobj.c | 3 ++ src/p_tick.c | 123 ++++++++++++++++++++++++++++++++++++++++++------ src/p_tick.h | 14 +++++- 5 files changed, 139 insertions(+), 15 deletions(-) diff --git a/src/d_think.h b/src/d_think.h index 6b8ee113a..8177f464d 100644 --- a/src/d_think.h +++ b/src/d_think.h @@ -17,6 +17,8 @@ #ifndef __D_THINK__ #define __D_THINK__ +#include "doomdef.h" + #ifdef __GNUG__ #pragma interface #endif @@ -50,6 +52,10 @@ typedef struct thinker_s // this one using pointers. Used for garbage collection. INT32 references; boolean cachable; +#ifdef PARANOIA + INT32 debug_mobjtype; + tic_t debug_time; +#endif } thinker_t; #endif diff --git a/src/p_mobj.c b/src/p_mobj.c index 66d4493ca..fb34b335d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10132,6 +10132,10 @@ void P_RemoveMobj(mobj_t *mobj) { // Add thinker just to delay removing it until refrences are gone. mobj->flags &= ~MF_NOTHINK; P_AddThinker((thinker_t *)mobj); +#ifdef PARANOIA + // Saved to avoid being scrambled like below... + mobj->thinker.debug_mobjtype = mobj->type; +#endif #ifdef SCRAMBLE_REMOVED // Invalidate mobj_t data to cause crashes if accessed! memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); @@ -10141,6 +10145,10 @@ void P_RemoveMobj(mobj_t *mobj) } else { +#ifdef PARANOIA + // Saved to avoid being scrambled like below... + mobj->thinker.debug_mobjtype = mobj->type; +#endif #ifdef SCRAMBLE_REMOVED // Invalidate mobj_t data to cause crashes if accessed! memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 61c08a05d..629595068 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -156,6 +156,9 @@ FUNCINLINE static ATTRINLINE void PolyObj_AddThinker(thinker_t *th) th->references = 0; th->cachable = false; // not initialising this made the mobjcache die thx! +#ifdef PARANOIA + th->debug_mobjtype = MT_NULL; +#endif } static void FreeSideLists(void) diff --git a/src/p_tick.c b/src/p_tick.c index 91f40c623..986708767 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -11,6 +11,10 @@ /// \file p_tick.c /// \brief Archiving: SaveGame I/O, Thinker, Ticker +#ifdef PARANOIA +#include "dehacked.h" // MOBJTYPE_LIST +#endif + #include "doomstat.h" #include "g_game.h" #include "g_input.h" @@ -204,6 +208,9 @@ void P_AddThinker(thinker_t *thinker) thinker->references = 0; // killough 11/98: init reference counter to 0 thinker->cachable = (thinker->function.acp1 == (actionf_p1)P_MobjThinker); +#ifdef PARANOIA + thinker->debug_mobjtype = MT_NULL; +#endif } // @@ -220,8 +227,48 @@ void P_AddPrecipThinker(thinker_t *thinker) thinker->references = 0; // killough 11/98: init reference counter to 0 thinker->cachable = false; +#ifdef PARANOIA + thinker->debug_mobjtype = MT_NULL; +#endif } +#ifdef PARANOIA +static const char *MobjTypeName(const mobj_t *mobj) +{ + actionf_p1 p1 = mobj->thinker.function.acp1; + + if (p1 == (actionf_p1)P_MobjThinker) + { + return MOBJTYPE_LIST[mobj->type]; + } + else if (p1 == (actionf_p1)P_RemoveThinkerDelayed) + { + if (mobj->thinker.debug_mobjtype != MT_NULL) + { + return MOBJTYPE_LIST[mobj->thinker.debug_mobjtype]; + } + } + + return ""; +} + +static const char *MobjThinkerName(const mobj_t *mobj) +{ + actionf_p1 p1 = mobj->thinker.function.acp1; + + if (p1 == (actionf_p1)P_MobjThinker) + { + return "P_MobjThinker"; + } + else if (p1 == (actionf_p1)P_RemoveThinkerDelayed) + { + return "P_RemoveThinkerDelayed"; + } + + return ""; +} +#endif + // // killough 11/98: // @@ -242,20 +289,35 @@ static thinker_t *currentthinker; // void P_RemoveThinkerDelayed(thinker_t *thinker) { -#ifdef PARANOIA -#define BEENAROUNDBIT (0x40000000) // has to be sufficiently high that it's unlikely to happen in regular gameplay. If you change this, pay attention to the bit pattern of INT32_MIN. - if (thinker->references & ~BEENAROUNDBIT) + if (thinker->references != 0) { - if (thinker->references & BEENAROUNDBIT) // Usually gets cleared up in one frame; what's going on here, then? - CONS_Printf("Number of potentially faulty references: %d\n", (thinker->references & ~BEENAROUNDBIT)); - thinker->references |= BEENAROUNDBIT; +#ifdef PARANOIA + // Removed mobjs can be the target of another mobj. In + // that case, the other mobj will manage its reference + // to the removed mobj in P_MobjThinker. However, if + // the removed mobj is removed after the other object + // thinks, the reference management is delayed by one + // tic (or two?) + const UINT8 delay = 2; + + if (thinker->debug_time > leveltime) + { + thinker->debug_time = leveltime + delay + 1; // do not print errors again + } + else if ((thinker->debug_time + delay) <= leveltime) + { + CONS_Printf( + "PARANOIA/P_RemoveThinkerDelayed: %p %s references=%d\n", + (void*)thinker, + MobjTypeName((mobj_t*)thinker), + thinker->references + ); + + thinker->debug_time = leveltime + delay + 1; // do not print this error again + } +#endif return; } -#undef BEENAROUNDBIT -#else - if (thinker->references != 0) - return; -#endif /* Remove from main thinker list */ thinker_t *next = thinker->next; @@ -333,12 +395,45 @@ void P_RemoveThinker(thinker_t *thinker) * references, and delay removal until the count is 0. */ -mobj_t *P_SetTarget(mobj_t **mop, mobj_t *targ) +mobj_t *P_SetTarget2(mobj_t **mop, mobj_t *targ +#ifdef PARANOIA + , const char *source_file, int source_line +#endif +) { - if (*mop) // If there was a target already, decrease its refcount + if (*mop) // If there was a target already, decrease its refcount + { (*mop)->thinker.references--; - if ((*mop = targ) != NULL) // Set new target and if non-NULL, increase its counter + +#ifdef PARANOIA + if ((*mop)->thinker.references < 0) + { + CONS_Printf( + "PARANOIA/P_SetTarget: %p %s %s references=%d, references go negative! (%s:%d)\n", + (void*)*mop, + MobjTypeName(*mop), + MobjThinkerName(*mop), + (*mop)->thinker.references, + source_file, + source_line + ); + } + + (*mop)->thinker.debug_time = leveltime; +#endif + } + + if (targ != NULL) // Set new target and if non-NULL, increase its counter + { targ->thinker.references++; + +#ifdef PARANOIA + targ->thinker.debug_time = leveltime; +#endif + } + + *mop = targ; + return targ; } diff --git a/src/p_tick.h b/src/p_tick.h index 11b5889ed..a903be0fd 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -14,6 +14,8 @@ #ifndef __P_TICK__ #define __P_TICK__ +#include "doomdef.h" + #ifdef __GNUG__ #pragma interface #endif @@ -29,6 +31,16 @@ void P_Ticker(boolean run); void P_PreTicker(INT32 frames); void P_DoTeamscrambling(void); void P_RemoveThinkerDelayed(thinker_t *thinker); -mobj_t *P_SetTarget(mobj_t **mo, mobj_t *target); // killough 11/98 +mobj_t *P_SetTarget2(mobj_t **mo, mobj_t *target +#ifdef PARANOIA +, const char *source_file, int source_line +#endif +); + +#ifdef PARANOIA +#define P_SetTarget(...) P_SetTarget2(__VA_ARGS__, __FILE__, __LINE__) +#else +#define P_SetTarget P_SetTarget2 +#endif #endif From ede95c8ec40cfd7c0dcb75a44d3f5c954088cee7 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 16:04:53 +0200 Subject: [PATCH 07/35] use P_UnlinkThinker idk why it still was like this in here lel --- src/p_tick.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 986708767..212c2f1e6 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -319,25 +319,16 @@ void P_RemoveThinkerDelayed(thinker_t *thinker) return; } - /* Remove from main thinker list */ - thinker_t *next = thinker->next; + R_DestroyLevelInterpolators(thinker); + /* Note that currentthinker is guaranteed to point to us, * and since we're freeing our memory, we had better change that. So * point it to thinker->prev, so the iterator will correctly move on to * thinker->prev->next = thinker->next */ - (next->prev = currentthinker = thinker->prev)->next = next; - R_DestroyLevelInterpolators(thinker); + currentthinker = thinker->prev; - if (thinker->cachable == true) - { - // put cachable thinkers in the mobj cache, so we can avoid allocations - ((mobj_t *)thinker)->hnext = mobjcache; - mobjcache = (mobj_t *)thinker; - } - else - { - Z_Free(thinker); - } + /* Remove from main thinker list */ + P_UnlinkThinker(thinker); } // From def40280285d8b2ff3fdbd94b9b36010be9f3458 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 11:39:54 +0200 Subject: [PATCH 08/35] add P_DivlineCrossedFast to take more advantage of P_DivlineSideFast --- src/p_sight.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index 5dfc796b8..b02ffd786 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -34,6 +34,7 @@ typedef struct { static INT32 sightcounts[2]; typedef INT32 (*divlinefunc)(fixed_t x, fixed_t y, const divline_t *node); +typedef INT32 (*divlinecrossfunc)(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node); // // P_DivlineSide @@ -67,6 +68,11 @@ static inline INT32 P_DivlineCrossed(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t return (P_DivlineSide(x1, y1, node) == P_DivlineSide(x2, y2, node)); } +static inline INT32 P_DivlineCrossedFast(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node) +{ + return (P_DivlineSideFast(x1, y1, node) == P_DivlineSideFast(x2, y2, node)); +} + static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) { size_t i; @@ -130,7 +136,7 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) // // Returns true if strace crosses the given subsector successfully. // -static boolean P_CrossSubsector(size_t num, register los_t *los) +static boolean P_CrossSubsector(size_t num, register los_t *los, boolean fast) { seg_t *seg; INT32 count; @@ -159,6 +165,8 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) } } + const divlinecrossfunc divlinecrossFunc = fast ? P_DivlineCrossedFast : P_DivlineCrossed; + for (count = subsectors[num].numlines; --count >= 0; seg++) // check lines { line_t *line = seg->linedef; @@ -187,14 +195,14 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) v2 = line->v2; // line isn't crossed? - if (P_DivlineCrossed(v1->x, v1->y, v2->x, v2->y, &los->strace)) + if (divlinecrossFunc(v1->x, v1->y, v2->x, v2->y, &los->strace)) continue; divl.dx = v2->x - (divl.x = v1->x); divl.dy = v2->y - (divl.y = v1->y); // line isn't crossed? - if (P_DivlineCrossed(los->strace.x, los->strace.y, los->t2x, los->t2y, &divl)) + if (divlinecrossFunc(los->strace.x, los->strace.y, los->t2x, los->t2y, &divl)) continue; // stop because it is not two sided anyway @@ -326,7 +334,7 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast) } } - return P_CrossSubsector((bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR), los); + return P_CrossSubsector((bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR), los, fast); } // From 9d1b8ba736922f69f6df16c3b549e3b5f8dba428 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 16:14:33 +0200 Subject: [PATCH 09/35] move saturn menu stuff around --- src/m_menu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 72c28857c..bcd406e4c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2452,17 +2452,17 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135}, {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 140}, - {IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 150}, - {IT_STRING | IT_CVAR, NULL, "Player Angle Dot", &cv_showminimapangle, 160}, + {IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 145}, + {IT_STRING | IT_CVAR, NULL, "Player Angle Dot", &cv_showminimapangle, 150}, - {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 170}, + {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 160}, - {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 180}, + {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 170}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 190}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 195}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 180}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 185}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 205}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 195}, }; static const char* OP_SaturnHudTooltips[] = From 1d15f89433c4cb485b7894373bb97fb7d8db9da8 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 23 Apr 2025 19:09:02 +0300 Subject: [PATCH 10/35] Remove I_Assert in GetItemId in lua_hudlib_drawlist.c It is legal for lua_getpc to be null (thanks GenericHeroGuy for investigating!) --- src/lua_hudlib_drawlist.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 98a4890b1..a9c9d93b7 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -337,7 +337,6 @@ static UINT64 GetItemId(void) #else // he who controls the JIT controls the API const void *p = lua_getpc(gL, 1); - I_Assert(p != NULL); UINT64 id = (uintptr_t)p; #endif // leave bits 0 and 1 free for the string mode From 1bb52b9c2d270f243bda280915406645ca59b207 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 23 Apr 2025 19:54:17 +0200 Subject: [PATCH 11/35] check ceiling first in encore flat precaching no clue why but this fixes the sides of the road on ORR not being encore remapped --- src/hardware/hw_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 5ba8655b8..f3b4ae84f 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -553,7 +553,7 @@ static void HWR_PrecacheLevelFlats(void) // gotta check sector floor and ceiling for (j = 0; j < 2; j++) { - const boolean ceiling = (j == 1); + const boolean ceiling = (j == 0); INT32 pic = ceiling ? sec->ceilingpic : sec->floorpic; levelflat = levelflats[pic]; From a099f825a77c64ee61adb546d14b7e5b6eca62bd Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 06:42:50 +0200 Subject: [PATCH 12/35] missed removing this --- src/d_netcmd.c | 18 +++++++++--------- src/r_things.c | 1 - src/w_wad.c | 5 +++++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3b53dd8c4..d3b9ca5b4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4591,7 +4591,7 @@ static void Command_GLocalSkin (void) char* fuck; // local skin name - if (!( first_option = COM_FirstOption() )) + if (!(first_option = COM_FirstOption())) first_option = COM_Argc(); if (first_option < 2) @@ -4599,14 +4599,14 @@ static void Command_GLocalSkin (void) /* holy fucking shit */ CONS_Printf("localskin [-player ] [-display ] [-all]:\n"); CONS_Printf(M_GetText("Set a localskin via its internal name (usually printed on the console).\n\n\ -* Using \"-player\" will set a localskin to a specified player.\n\ - Defaults to yourself.\n\ -* Using \"-display\" will set a localskin to the displayed player.\n\ - Defaults to 0, which is the first player displayed.\n\ - Can go up to 3 for splitscreen.\n\ -* Using \"-all\" will set a localskin to ALL players.\n\ -* \"localskin none\" removes the localskin, just like how\n\ - \"forceskin none\" does.\n")); + * Using \"-player\" will set a localskin to a specified player.\n\ + Defaults to yourself.\n\ + * Using \"-display\" will set a localskin to the displayed player.\n\ + Defaults to 0, which is the first player displayed.\n\ + Can go up to 3 for splitscreen.\n\ + * Using \"-all\" will set a localskin to ALL players.\n\ + * \"localskin none\" removes the localskin, just like how\n\ + \"forceskin none\" does.\n")); return; } diff --git a/src/r_things.c b/src/r_things.c index ddae1d7ec..44a2bfe84 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3700,7 +3700,6 @@ next_token: numallskins++; } -#undef lskin #undef lnumskins //sortSkinGrid(); diff --git a/src/w_wad.c b/src/w_wad.c index 6432c3223..3a9ab6c6c 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -898,8 +898,10 @@ INT32 W_InitMultipleFiles(char **filenames, boolean addons) //CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames); rc = W_InitFile(*filenames, false); + if (rc == INT16_MAX) CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames); + overallrc &= (rc != INT16_MAX) ? 1 : 0; } @@ -918,8 +920,10 @@ INT32 W_AddAutoloadedLocalFiles(char **filenames) for (; *filenames; filenames++) { rc = P_PartialAddWadFile(*filenames, true); + if (rc == UINT16_MAX) CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), *filenames); + overallrc &= (rc != UINT16_MAX) ? 1 : 0; } @@ -928,6 +932,7 @@ INT32 W_AddAutoloadedLocalFiles(char **filenames) if (P_PartialAddGetStage() >= 0) P_MultiSetupWadFiles(true); + return overallrc; } From f81488500c6f10d3416711f86d6deee3eda6acee Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 06:46:41 +0200 Subject: [PATCH 13/35] just mark it like this --- src/r_things.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index 44a2bfe84..aad15de15 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2856,7 +2856,7 @@ void R_ClipSprites(void) /* Check if thing may be drawn from our current view. */ boolean R_ThingVisible (mobj_t *thing) { - if (UNLIKELY(thing->sprite == SPR_NULL) || UNLIKELY((thing->flags2 & MF2_DONTDRAW))) + if (UNLIKELY((thing->sprite == SPR_NULL) || (thing->flags2 & MF2_DONTDRAW))) return false; if (splitscreen) From cf92df5faafaf1f267444c7d726a1fda3317d4a3 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 06:54:22 +0200 Subject: [PATCH 14/35] skip checking skin array if localskin was found in localskin array --- src/lua_mobjlib.c | 5 ++--- src/r_things.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 9498974d5..44c43297f 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -452,7 +452,7 @@ int mobj_localskin_setter(lua_State *L) strlcpy(skin, luaL_optstring(L, 2, "none"), sizeof skin); strlwr(skin); // all skin names are lowercase - if (strcasecmp(skin, "none")) + if (stricmp(skin, "none")) { // Try localskins for (i = 0; i < numlocalskins; i++) @@ -468,7 +468,7 @@ int mobj_localskin_setter(lua_State *L) // Try other skins for (i = 0; i < numskins; i++) { - if (fastcmp(skins[i].name, skin)) + if (stricmp(skins[i].name, skin) == 0) { mo->localskin = &skins[i]; mo->skinlocal = false; @@ -483,7 +483,6 @@ int mobj_localskin_setter(lua_State *L) } } - return 0; } diff --git a/src/r_things.c b/src/r_things.c index aad15de15..e2c3c2c76 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3163,11 +3163,11 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) INT32 i; player_t *player = &players[playernum]; - if (strcasecmp(skinname, "none")) + if (stricmp(skinname, "none")) { for (i = 0; i < numlocalskins; i++) { - // search in the skin list + // search in the localskin list if (stricmp(localskins[i].name, skinname) == 0) { player->localskin = 1 + i; @@ -3177,9 +3177,11 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) player->mo->localskin = &localskins[i]; player->mo->skinlocal = true; } - break; + + goto setcvar; } } + for (i = 0; i < numskins; i++) { // search in the skin list @@ -3192,7 +3194,8 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) player->mo->localskin = &skins[i]; player->mo->skinlocal = false; } - break; + + goto setcvar; } } } @@ -3207,6 +3210,7 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) } } +setcvar: if (cvar != NULL) { if (player->localskin > 0) From 7bb4b74c65e7db92d55417f0b0221b67579e6e45 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 06:56:57 +0200 Subject: [PATCH 15/35] fix potential crash on startup thx hanicef --- src/g_input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_input.c b/src/g_input.c index f0121f37d..7adb4462a 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1022,7 +1022,7 @@ INT32 G_KeyStringtoNum(const char *keystr) if (!keystr[0]) return 0; - if (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z') + if (!keystr[0] || (!keystr[1] && keystr[0] > ' ' && keystr[0] <= 'z')) return keystr[0]; if (!strncmp(keystr, "KEY", 3) && keystr[3] >= '0' && keystr[3] <= '9') From 987d18fe992418007891a837d15a9f00d0fa3a67 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 09:24:37 +0200 Subject: [PATCH 16/35] memset those --- src/doomstat.h | 4 ++-- src/p_setup.c | 26 ++++++++++++++++++++------ src/r_things.c | 7 ++++--- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index f6e708be6..54c6ae320 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -244,7 +244,7 @@ typedef struct INT16 nextlevel; ///< Map number of next level, or 1100-1102 to end. char musname[7]; ///< Music track to play. "" for no music. UINT16 mustrack; ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore. - UINT32 muspos; ///< Music position to jump to. + UINT32 muspos; ///< Music position to jump to. char forcecharacter[17]; ///< (SKINNAMESIZE+1) Skin to switch to or "" to disable. UINT8 weather; ///< 0 = sunny day, 1 = storm, 2 = snow, 3 = rain, 4 = blank, 5 = thunder w/o rain, 6 = rain w/o lightning, 7 = heat wave. INT16 skynum; ///< Sky number to use. @@ -276,7 +276,7 @@ typedef struct // SRB2kart //boolean automap; ///< Displays a level's white map outline in modified games - fixed_t mobj_scale; ///< Replacement for TOL_ERZ3 + fixed_t mobj_scale; ///< Replacement for TOL_ERZ3 mapheader_lighting_t lighting; ///< Wall and sprite lighting mapheader_lighting_t lighting_encore; ///< Alternative lighting for Encore mode diff --git a/src/p_setup.c b/src/p_setup.c index e4c22f253..b51a8abce 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -296,6 +296,7 @@ static void P_ClearMapHeaderLighting(mapheader_lighting_t *lighting) static void P_ClearSingleMapHeaderInfo(INT16 i) { const INT16 num = (INT16)(i-1); + mapheaderinfo[num]->lvlttl[0] = '\0'; mapheaderinfo[num]->subttl[0] = '\0'; mapheaderinfo[num]->zonttl[0] = '\0'; @@ -329,8 +330,10 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->saveoverride = SAVE_DEFAULT; mapheaderinfo[num]->levelflags = 0; mapheaderinfo[num]->menuflags = (mainwads ? 0 : LF2_EXISTSHACK); // see p_setup.c - prevents replacing maps in addons with easier versions + // TODO grades support for delfile (pfft yeah right) P_DeleteGrades(num); + // SRB2Kart //mapheaderinfo[num]->automap = false; mapheaderinfo[num]->mobj_scale = FRACUNIT; @@ -752,7 +755,7 @@ INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat) // first scan through the already found flats // for (i = 0; i < numlevelflats; i++, levelflat++) - if (strnicmp(levelflat->name,flatname,8)==0) + if (strnicmp(levelflat->name,flatname,8) == 0) break; // that flat was already found in the level, return the id @@ -947,6 +950,7 @@ static void P_LoadRawNodes(UINT8 *data) no->y = SHORT(mn->y)<dx = SHORT(mn->dx)<dy = SHORT(mn->dy)<children[j] = SHORT(mn->children[j]); @@ -2376,10 +2380,14 @@ static INT32 P_MakeBufferMD5(const char *buffer, size_t len, void *resblock) return 1; #else tic_t t = I_GetTime(); + CONS_Debug(DBG_SETUP, "Making MD5\n"); + if (md5_buffer(buffer, len, resblock) == NULL) return 1; + CONS_Debug(DBG_SETUP, "MD5 calc took %f seconds\n", (float)(I_GetTime() - t)/NEWTICRATE); + return 0; #endif } @@ -2460,6 +2468,7 @@ static void P_RunLevelScript(const char *scriptname) { COM_BufAddText(va("exec %s\n", scriptname)); } + COM_BufExecute(); // Run it! } @@ -2760,7 +2769,7 @@ static boolean P_RunSpecialWipe(boolean reloadinggamestate) F_WipeEndScreen(); F_RunWipe(wipedefs[wipe_level_final], false); } - else //dedicated servers can call this now, to wait the appropriate amount of time for clients to wipe + else // dedicated servers can call this now, to wait the appropriate amount of time for clients to wipe { F_RunWipe(wipedefs[wipe_speclevel_towhite], false); F_RunWipe(wipedefs[wipe_level_final], false); @@ -2778,7 +2787,9 @@ static boolean P_RunSpecialWipe(boolean reloadinggamestate) I_Sleep(cv_sleep.value); I_UpdateTime(cv_timescale.value); } + lastwipetic = nowtime; + if (moviemode) // make sure we save frames for the white hold too M_SaveFrame(); @@ -2797,6 +2808,7 @@ static void P_SetupPlayer(void) INT32 i; for (i = 0; i < MAXPLAYERS; i++) + { if (playeringame[i]) { players[i].pflags &= ~PF_NIGHTSMODE; @@ -2821,6 +2833,7 @@ static void P_SetupPlayer(void) G_SpawnPlayer(i, false); } } + } if (modeattacking == ATTACKING_RECORD && !demo.playback) P_LoadRecordGhosts(); @@ -3077,10 +3090,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) numdmstarts = numredctfstarts = numbluectfstarts = 0; // reset the player starts - for (i = 0; i < MAXPLAYERS; i++) - playerstarts[i] = NULL; - for (i = 0; i < 2; i++) - skyboxmo[i] = NULL; + memset(playerstarts, 0, sizeof(playerstarts)); + memset(skyboxmo, 0, sizeof(skyboxmo)); P_ResetWaypoints(); @@ -3180,12 +3191,15 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) if (!fromnetsave) // uglier hack { // to make a newly loaded level start on the second frame. INT32 buf = gametic % TICQUEUE; + for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i]) G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); } + P_PreTicker(2); + if (!reloadinggamestate) LUA_HookInt(gamemap, HOOK(MapLoad)); } diff --git a/src/r_things.c b/src/r_things.c index e2c3c2c76..45afd824d 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3096,7 +3096,7 @@ INT32 R_SkinAvailable(const char *name) for (i = 0; i < numskins; i++) { - if (stricmp(skins[i].name,name)==0) + if (stricmp(skins[i].name,name) == 0) return i; } return -1; @@ -3110,7 +3110,7 @@ INT32 R_AnySkinAvailable(const char *name) for (i = 0; i < numallskins; i++) { - if (stricmp(allskins[i].name,name)==0) + if (stricmp(allskins[i].name,name) == 0) return i; } return -1; @@ -3124,7 +3124,7 @@ INT32 R_LocalSkinAvailable(const char *name, boolean local) { for (i = 0; i < numlocalskins; i++) { - if (stricmp(localskins[i].name,name)==0) + if (stricmp(localskins[i].name,name) == 0) return i; } return -1; @@ -3258,6 +3258,7 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) CONS_Alert(CONS_WARNING, M_GetText("Skin %d not found\n"), skinnum); else if(server || IsPlayerAdmin(consoleplayer)) CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); + SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin } From 5df33e070549ef0964f9aab5d3b39abca4aab242 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 08:58:05 +0200 Subject: [PATCH 17/35] cleanup G_Responder man --- src/g_game.c | 328 ++++++++++++++++++++------------------------------ src/g_input.c | 8 ++ src/g_input.h | 2 + 3 files changed, 141 insertions(+), 197 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 7acda852e..de290949b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1277,7 +1277,8 @@ static void G_DoLoadLevel(boolean resetplayer) // clear cmd building stuff memset(gamekeydown, 0, sizeof (gamekeydown)); - for (i = 0;i < JOYAXISSET; i++) + + for (i = 0; i < JOYAXISSET; i++) { joyxmove[i] = joyymove[i] = 0; joy2xmove[i] = joy2ymove[i] = 0; @@ -1298,91 +1299,10 @@ static INT32 pausedelay = 0; static INT32 camtoggledelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; static INT32 spectatedelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; -// -// G_Responder -// Get info needed to make ticcmd_ts for the players. -// -boolean G_Responder(event_t *ev) +static boolean G_LevelResponder(event_t *ev) { - // any other key pops up menu if in demos - if (gameaction == ga_nothing && !demo.quitafterplaying && - ((demo.playback && !modeattacking && !demo.title && !multiplayer) || gamestate == GS_TITLESCREEN)) - { - if (ev->type == ev_keydown && ev->data1 != 301) - { - M_StartControlPanel(); - return true; - } - return false; - } - else if (demo.playback && demo.title) - { - // Title demo uses intro responder - if (F_IntroResponder(ev)) - { - // stop the title demo - G_CheckDemoStatus(); - return true; - } - return false; - } - - if (gamestate == GS_LEVEL) - { - if (HU_Responder(ev)) - return true; // chat ate the event - if (AM_Responder(ev)) - return true; // automap ate it - // map the event (key/mouse/joy) to a gamecontrol - } - // Intro - else if (gamestate == GS_INTRO) - { - if (F_IntroResponder(ev)) - { - D_StartTitle(); - return true; - } - } - else if (gamestate == GS_CUTSCENE) - { - if (HU_Responder(ev)) - return true; // chat ate the event - - if (F_CutsceneResponder(ev)) - { - D_StartTitle(); - return true; - } - } - - else if (gamestate == GS_CREDITS) - { - if (HU_Responder(ev)) - return true; // chat ate the event - - if (F_CreditResponder(ev)) - { - F_StartGameEvaluation(); - return true; - } - } - - else if (gamestate == GS_CONTINUING) - { - if (F_ContinueResponder(ev)) - return true; - } - // Demo End - else if (gamestate == GS_GAMEEND || gamestate == GS_EVALUATION || gamestate == GS_CREDITS) - return true; - - else if (gamestate == GS_INTERMISSION || gamestate == GS_VOTING || gamestate == GS_WAITINGPLAYERS) - if (HU_Responder(ev)) - return true; // chat ate the event - // allow spy mode changes even during the demo - if (gamestate == GS_LEVEL && ev->type == ev_keydown + if (ev->type == ev_keydown && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) { if (!demo.playback && (splitscreen || !netgame)) @@ -1399,30 +1319,20 @@ boolean G_Responder(event_t *ev) } } - if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback) + if (ev->type == ev_keydown && multiplayer && demo.playback) { - if (ev->data1 == gamecontrolbis[gc_viewpoint][0] || ev->data1 == gamecontrolbis[gc_viewpoint][1]) + for (INT32 i = 1; i <= splitscreen; i++) { - G_AdjustView(2, 1, true); - - return true; - } - else if (ev->data1 == gamecontrol3[gc_viewpoint][0] || ev->data1 == gamecontrol3[gc_viewpoint][1]) - { - G_AdjustView(3, 1, true); - - return true; - } - else if (ev->data1 == gamecontrol4[gc_viewpoint][0] || ev->data1 == gamecontrol4[gc_viewpoint][1]) - { - G_AdjustView(4, 1, true); - - return true; + if (ev->data1 == gamecontrols[i][gc_viewpoint][0] + || ev->data1 == gamecontrols[i][gc_viewpoint][1]) + { + G_AdjustView(i+1, 1, true); + return true; + } } // Allow pausing - if ( - ev->data1 == gamecontrol[gc_pause][0] + if (ev->data1 == gamecontrol[gc_pause][0] || ev->data1 == gamecontrol[gc_pause][1] || ev->data1 == KEY_PAUSE ) @@ -1447,11 +1357,98 @@ boolean G_Responder(event_t *ev) if (ev->data1 == 32) { M_StartControlPanel(); - return true; } } + return false; +} + +// +// G_Responder +// Get info needed to make ticcmd_ts for the players. +// +boolean G_Responder(event_t *ev) +{ + if (demo.playback && demo.title) + { + // Title demo uses intro responder + if (F_IntroResponder(ev)) + { + // stop the title demo + G_CheckDemoStatus(); + return true; + } + + return false; + } + else if (gameaction == ga_nothing + && !demo.quitafterplaying + && ((demo.playback && !modeattacking && !multiplayer) || gamestate == GS_TITLESCREEN)) + { + // any other key pops up menu if in demos + if (ev->type == ev_keydown && ev->data1 != 301) + { + M_StartControlPanel(); + return true; + } + + return false; + } + + if (Playing()) + { + // If you're playing, chat is real. + // Neatly sidesteps a class of bugs where whenever we add a + // new gamestate accessible in netplay, chat was console-only. + if (HU_Responder(ev)) + { + return true; // chat ate the event + } + } + + switch (gamestate) + { + case GS_LEVEL: + if (AM_Responder(ev)) + return true; // automap ate it + // map the event (key/mouse/joy) to a gamecontrol + if (G_LevelResponder(ev)) + return true; + break; + case GS_INTRO: + if (F_IntroResponder(ev)) + { + D_StartTitle(); + return true; + } + break; + case GS_CUTSCENE: + if (F_CutsceneResponder(ev)) + { + D_StartTitle(); + return true; + } + break; + case GS_CREDITS: + if (F_CreditResponder(ev)) + { + F_StartGameEvaluation(); + return true; + } + break; + case GS_CONTINUING: + if (F_ContinueResponder(ev)) + return true; + break; + case GS_GAMEEND: + case GS_EVALUATION: + return true; // Demo End + break; + default: + break; + } + // update keys current state G_MapEventsToControls(ev); @@ -1474,121 +1471,58 @@ boolean G_Responder(event_t *ev) else pausedelay = NEWTICRATE/7; } - if (ev->data1 == gamecontrol[gc_camtoggle][0] - || ev->data1 == gamecontrol[gc_camtoggle][1]) - { - if (!camtoggledelay[0]) - { - camtoggledelay[0] = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam[0], cv_chasecam[0].value ? 0 : 1); - } - } - if (ev->data1 == gamecontrolbis[gc_camtoggle][0] - || ev->data1 == gamecontrolbis[gc_camtoggle][1]) - { - if (!camtoggledelay[1]) - { - camtoggledelay[1] = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam[1], cv_chasecam[1].value ? 0 : 1); - } - } - if (ev->data1 == gamecontrol3[gc_camtoggle][0] - || ev->data1 == gamecontrol3[gc_camtoggle][1]) - { - if (!camtoggledelay[2]) - { - camtoggledelay[2] = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam[2], cv_chasecam[2].value ? 0 : 1); - } - } - if (ev->data1 == gamecontrol4[gc_camtoggle][0] - || ev->data1 == gamecontrol4[gc_camtoggle][1]) - { - if (!camtoggledelay[3]) - { - camtoggledelay[3] = NEWTICRATE / 7; - CV_SetValue(&cv_chasecam[3], cv_chasecam[3].value ? 0 : 1); - } - } - if (ev->data1 == gamecontrol[gc_spectate][0] - || ev->data1 == gamecontrol[gc_spectate][1]) - { - if (!spectatedelay[0]) - { - spectatedelay[0] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam spectator"); - } - } - if (ev->data1 == gamecontrolbis[gc_spectate][0] - || ev->data1 == gamecontrolbis[gc_spectate][1]) - { - if (!spectatedelay[1]) - { - spectatedelay[1] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam2 spectator"); - } - } - if (ev->data1 == gamecontrol3[gc_spectate][0] - || ev->data1 == gamecontrol3[gc_spectate][1]) - { - if (!spectatedelay[2]) - { - spectatedelay[2] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam3 spectator"); - } - } - if (ev->data1 == gamecontrol4[gc_spectate][0] - || ev->data1 == gamecontrol4[gc_spectate][1]) - { - if (!spectatedelay[3]) - { - spectatedelay[3] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam4 spectator"); - } - } - if (ev->data1 == gamecontrol[gc_director][0] || ev->data1 == gamecontrol[gc_director][1]) + // no splitscreen support for director here + if (ev->data1 == gamecontrol[gc_director][0] + || ev->data1 == gamecontrol[gc_director][1]) { K_ToggleDirector(); } - if (ev->data1 == gamecontrol[gc_freecam][0] || ev->data1 == gamecontrol[gc_freecam][1]) + // absolutely horrid + for (INT32 i = 0; i <= splitscreen; i++) { - P_ToggleDemoCamera(0); - } - else if (ev->data1 == gamecontrolbis[gc_freecam][0] || ev->data1 == gamecontrolbis[gc_freecam][1]) - { - P_ToggleDemoCamera(1); - } - else if (ev->data1 == gamecontrol3[gc_freecam][0] || ev->data1 == gamecontrol3[gc_freecam][1]) - { - P_ToggleDemoCamera(2); - } - else if (ev->data1 == gamecontrol4[gc_freecam][0] || ev->data1 == gamecontrol4[gc_freecam][1]) - { - P_ToggleDemoCamera(3); + if (ev->data1 == gamecontrols[i][gc_camtoggle][0] + || ev->data1 == gamecontrols[i][gc_camtoggle][1]) + { + if (!camtoggledelay[i]) + { + camtoggledelay[i] = NEWTICRATE / 7; + CV_SetValue(&cv_chasecam[i], (cv_chasecam[i].value ^ 1)); + } + } + + if (ev->data1 == gamecontrols[i][gc_spectate][0] + || ev->data1 == gamecontrols[i][gc_spectate][1]) + { + if (!spectatedelay[i]) + { + spectatedelay[i] = NEWTICRATE / 7; + COM_ImmedExecute("changeteam spectator"); + } + } + + if (ev->data1 == gamecontrols[i][gc_freecam][0] + || ev->data1 == gamecontrols[i][gc_freecam][1]) + { + P_ToggleDemoCamera(i); + } } return true; case ev_keyup: return false; // always let key up events filter down - case ev_mouse: return true; // eat events - case ev_joystick: return true; // eat events - case ev_joystick2: return true; // eat events - case ev_joystick3: return true; // eat events - case ev_joystick4: return true; // eat events - default: break; } diff --git a/src/g_input.c b/src/g_input.c index 7adb4462a..3c38cf192 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -136,6 +136,14 @@ INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player INT32 gamecontrol3[num_gamecontrols][2]; // tertiary splitscreen player INT32 gamecontrol4[num_gamecontrols][2]; // quarternary splitscreen player +// TODO: this is dumb as hell +INT32 (*gamecontrols[MAXSPLITSCREENPLAYERS])[2] = { + gamecontrol, + gamecontrolbis, + gamecontrol3, + gamecontrol4 +}; + typedef struct { UINT8 time; diff --git a/src/g_input.h b/src/g_input.h index 505d210f8..820e2cdbc 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -125,6 +125,8 @@ extern INT32 gamecontrol[num_gamecontrols][2]; extern INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player extern INT32 gamecontrol3[num_gamecontrols][2]; extern INT32 gamecontrol4[num_gamecontrols][2]; +extern INT32 (*gamecontrols[MAXSPLITSCREENPLAYERS])[2]; + #define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]]) #define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]]) #define PLAYER3INPUTDOWN(gc) (gamekeydown[gamecontrol3[gc][0]] || gamekeydown[gamecontrol3[gc][1]]) From c14c28ac1e35aac55da3b96589eae2fd91b270a4 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 09:13:14 +0200 Subject: [PATCH 18/35] attempt at cleaning up gamecontrol splitscreen shit --- src/console.c | 6 +- src/d_clisrv.c | 4 +- src/g_game.c | 32 +++---- src/g_input.c | 233 +++++++++++++++++++++---------------------------- src/g_input.h | 14 ++- src/hu_stuff.c | 14 +-- src/m_menu.c | 38 ++++---- src/m_misc.c | 4 +- src/st_stuff.c | 4 +- 9 files changed, 155 insertions(+), 194 deletions(-) diff --git a/src/console.c b/src/console.c index 3212521b0..f1c8efcc2 100644 --- a/src/console.c +++ b/src/console.c @@ -827,7 +827,7 @@ boolean CON_Responder(event_t *ev) // let go keyup events, don't eat them if (ev->type != ev_keydown && ev->type != ev_console) { - if (ev->data1 == gamecontrol[gc_console][0] || ev->data1 == gamecontrol[gc_console][1]) + if (ev->data1 == gamecontrol[0][gc_console][0] || ev->data1 == gamecontrol[0][gc_console][1]) consdown = false; return false; } @@ -845,7 +845,7 @@ boolean CON_Responder(event_t *ev) INT32 i; for (i = 0; i < num_gamecontrols; i++) { - if (gamecontrol[i][0] == ev->data1 || gamecontrol[i][1] == ev->data1) + if (gamecontrol[0][i][0] == ev->data1 || gamecontrol[0][i][1] == ev->data1) break; } @@ -853,7 +853,7 @@ boolean CON_Responder(event_t *ev) return false; } - if (key == gamecontrol[gc_console][0] || key == gamecontrol[gc_console][1]) + if (key == gamecontrol[0][gc_console][0] || key == gamecontrol[0][gc_console][1]) { if (consdown) // ignore repeat return true; diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4a2a0cc0f..d76e67e88 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2261,13 +2261,13 @@ static void M_ConfirmConnect(event_t *ev) #ifndef NONET if (ev->type == ev_keydown) { - if (ev->data1 == ' ' || ev->data1 == 'y' || ev->data1 == KEY_ENTER || ev->data1 == gamecontrol[gc_accelerate][0] || ev->data1 == gamecontrol[gc_accelerate][1]) + if (ev->data1 == ' ' || ev->data1 == 'y' || ev->data1 == KEY_ENTER || ev->data1 == gamecontrol[0][gc_accelerate][0] || ev->data1 == gamecontrol[0][gc_accelerate][1]) { CL_ConfirmConnect(); M_ClearMenus(true); } - else if (ev->data1 == 'n' || ev->data1 == KEY_ESCAPE|| ev->data1 == gamecontrol[gc_brake][0] || ev->data1 == gamecontrol[gc_brake][1]) + else if (ev->data1 == 'n' || ev->data1 == KEY_ESCAPE|| ev->data1 == gamecontrol[0][gc_brake][0] || ev->data1 == gamecontrol[0][gc_brake][1]) { cl_mode = CL_ABORTED; M_ClearMenus(true); diff --git a/src/g_game.c b/src/g_game.c index de290949b..eaec9e212 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1303,7 +1303,9 @@ static boolean G_LevelResponder(event_t *ev) { // allow spy mode changes even during the demo if (ev->type == ev_keydown - && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) + && (ev->data1 == KEY_F12 + || ev->data1 == gamecontrol[0][gc_viewpoint][0] + || ev->data1 == gamecontrol[0][gc_viewpoint][1])) { if (!demo.playback && (splitscreen || !netgame)) displayplayers[0] = consoleplayer; @@ -1323,8 +1325,8 @@ static boolean G_LevelResponder(event_t *ev) { for (INT32 i = 1; i <= splitscreen; i++) { - if (ev->data1 == gamecontrols[i][gc_viewpoint][0] - || ev->data1 == gamecontrols[i][gc_viewpoint][1]) + if (ev->data1 == gamecontrol[i][gc_viewpoint][0] + || ev->data1 == gamecontrol[i][gc_viewpoint][1]) { G_AdjustView(i+1, 1, true); return true; @@ -1332,8 +1334,8 @@ static boolean G_LevelResponder(event_t *ev) } // Allow pausing - if (ev->data1 == gamecontrol[gc_pause][0] - || ev->data1 == gamecontrol[gc_pause][1] + if (ev->data1 == gamecontrol[0][gc_pause][0] + || ev->data1 == gamecontrol[0][gc_pause][1] || ev->data1 == KEY_PAUSE ) { @@ -1455,8 +1457,8 @@ boolean G_Responder(event_t *ev) switch (ev->type) { case ev_keydown: - if (ev->data1 == gamecontrol[gc_pause][0] - || ev->data1 == gamecontrol[gc_pause][1] + if (ev->data1 == gamecontrol[0][gc_pause][0] + || ev->data1 == gamecontrol[0][gc_pause][1] || ev->data1 == KEY_PAUSE) { if (!pausedelay) @@ -1473,8 +1475,8 @@ boolean G_Responder(event_t *ev) } // no splitscreen support for director here - if (ev->data1 == gamecontrol[gc_director][0] - || ev->data1 == gamecontrol[gc_director][1]) + if (ev->data1 == gamecontrol[0][gc_director][0] + || ev->data1 == gamecontrol[0][gc_director][1]) { K_ToggleDirector(); } @@ -1482,8 +1484,8 @@ boolean G_Responder(event_t *ev) // absolutely horrid for (INT32 i = 0; i <= splitscreen; i++) { - if (ev->data1 == gamecontrols[i][gc_camtoggle][0] - || ev->data1 == gamecontrols[i][gc_camtoggle][1]) + if (ev->data1 == gamecontrol[i][gc_camtoggle][0] + || ev->data1 == gamecontrol[i][gc_camtoggle][1]) { if (!camtoggledelay[i]) { @@ -1492,8 +1494,8 @@ boolean G_Responder(event_t *ev) } } - if (ev->data1 == gamecontrols[i][gc_spectate][0] - || ev->data1 == gamecontrols[i][gc_spectate][1]) + if (ev->data1 == gamecontrol[i][gc_spectate][0] + || ev->data1 == gamecontrol[i][gc_spectate][1]) { if (!spectatedelay[i]) { @@ -1502,8 +1504,8 @@ boolean G_Responder(event_t *ev) } } - if (ev->data1 == gamecontrols[i][gc_freecam][0] - || ev->data1 == gamecontrols[i][gc_freecam][1]) + if (ev->data1 == gamecontrol[i][gc_freecam][0] + || ev->data1 == gamecontrol[i][gc_freecam][1]) { P_ToggleDemoCamera(i); } diff --git a/src/g_input.c b/src/g_input.c index 3c38cf192..f7ea83a75 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -131,18 +131,7 @@ joy3xmove[JOYAXISSET], joy3ymove[JOYAXISSET], joy4xmove[JOYAXISSET], joy4ymove[J UINT8 gamekeydown[NUMINPUTS]; // two key codes (or virtual key) per game control -INT32 gamecontrol[num_gamecontrols][2]; -INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player -INT32 gamecontrol3[num_gamecontrols][2]; // tertiary splitscreen player -INT32 gamecontrol4[num_gamecontrols][2]; // quarternary splitscreen player - -// TODO: this is dumb as hell -INT32 (*gamecontrols[MAXSPLITSCREENPLAYERS])[2] = { - gamecontrol, - gamecontrolbis, - gamecontrol3, - gamecontrol4 -}; +INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][2]; typedef struct { @@ -985,13 +974,14 @@ void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control) void G_ClearAllControlKeys(void) { - INT32 i; - for (i = 0; i < num_gamecontrols; i++) + INT32 i, k; + + for (k = 0; k < MAXSPLITSCREENPLAYERS; k++) { - G_ClearControlKeys(gamecontrol, i); - G_ClearControlKeys(gamecontrolbis, i); - G_ClearControlKeys(gamecontrol3, i); - G_ClearControlKeys(gamecontrol4, i); + for (i = 0; i < num_gamecontrols; i++) + { + G_ClearControlKeys(gamecontrol[k], i); + } } } @@ -1049,158 +1039,131 @@ void G_Controldefault(UINT8 player) if (player == 0 || player == 1) { // Main controls - gamecontrol[gc_aimforward ][0] = KEY_UPARROW; - gamecontrol[gc_aimbackward][0] = KEY_DOWNARROW; - gamecontrol[gc_turnleft ][0] = KEY_LEFTARROW; - gamecontrol[gc_turnright ][0] = KEY_RIGHTARROW; - gamecontrol[gc_accelerate ][0] = 'a'; - gamecontrol[gc_drift ][0] = 's'; - gamecontrol[gc_brake ][0] = 'd'; - gamecontrol[gc_fire ][0] = KEY_SPACE; - gamecontrol[gc_lookback ][0] = KEY_LSHIFT; + gamecontrol[0][gc_aimforward ][0] = KEY_UPARROW; + gamecontrol[0][gc_aimbackward][0] = KEY_DOWNARROW; + gamecontrol[0][gc_turnleft ][0] = KEY_LEFTARROW; + gamecontrol[0][gc_turnright ][0] = KEY_RIGHTARROW; + gamecontrol[0][gc_accelerate ][0] = 'a'; + gamecontrol[0][gc_drift ][0] = 's'; + gamecontrol[0][gc_brake ][0] = 'd'; + gamecontrol[0][gc_fire ][0] = KEY_SPACE; + gamecontrol[0][gc_lookback ][0] = KEY_LSHIFT; - gamecontrol[gc_accelerate ][1] = KEY_JOY1+0; // A - gamecontrol[gc_lookback ][1] = KEY_JOY1+2; // X - gamecontrol[gc_brake ][1] = KEY_JOY1+1; // B - gamecontrol[gc_fire ][1] = KEY_JOY1+9; // LB - gamecontrol[gc_drift ][1] = KEY_JOY1+10; // RB + gamecontrol[0][gc_accelerate ][1] = KEY_JOY1+0; // A + gamecontrol[0][gc_lookback ][1] = KEY_JOY1+2; // X + gamecontrol[0][gc_brake ][1] = KEY_JOY1+1; // B + gamecontrol[0][gc_fire ][1] = KEY_JOY1+9; // LB + gamecontrol[0][gc_drift ][1] = KEY_JOY1+10; // RB // Extra controls - gamecontrol[gc_pause ][0] = KEY_PAUSE; - gamecontrol[gc_console ][0] = KEY_CONSOLE; - gamecontrol[gc_screenshot ][0] = KEY_F8; - gamecontrol[gc_recordgif ][0] = KEY_F9; - gamecontrol[gc_viewpoint ][0] = KEY_F12; - gamecontrol[gc_talkkey ][0] = 't'; + gamecontrol[0][gc_pause ][0] = KEY_PAUSE; + gamecontrol[0][gc_console ][0] = KEY_CONSOLE; + gamecontrol[0][gc_screenshot ][0] = KEY_F8; + gamecontrol[0][gc_recordgif ][0] = KEY_F9; + gamecontrol[0][gc_viewpoint ][0] = KEY_F12; + gamecontrol[0][gc_talkkey ][0] = 't'; //gamecontrol[gc_teamkey ][0] = 'y'; - gamecontrol[gc_scores ][0] = KEY_TAB; - gamecontrol[gc_spectate ][0] = '\''; - gamecontrol[gc_lookup ][0] = KEY_PGUP; - gamecontrol[gc_lookdown ][0] = KEY_PGDN; - gamecontrol[gc_centerview ][0] = KEY_END; - gamecontrol[gc_camreset ][0] = KEY_HOME; - gamecontrol[gc_camtoggle ][0] = KEY_BACKSPACE; + gamecontrol[0][gc_scores ][0] = KEY_TAB; + gamecontrol[0][gc_spectate ][0] = '\''; + gamecontrol[0][gc_lookup ][0] = KEY_PGUP; + gamecontrol[0][gc_lookdown ][0] = KEY_PGDN; + gamecontrol[0][gc_centerview ][0] = KEY_END; + gamecontrol[0][gc_camreset ][0] = KEY_HOME; + gamecontrol[0][gc_camtoggle ][0] = KEY_BACKSPACE; - gamecontrol[gc_viewpoint ][1] = KEY_JOY1+3; // Y - gamecontrol[gc_pause ][1] = KEY_JOY1+4; // Back - gamecontrol[gc_systemmenu ][0] = KEY_JOY1+6; // Start - //gamecontrol[gc_camtoggle ][1] = KEY_HAT1+0; // D-Pad Up - //gamecontrol[gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT - gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down - gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up + gamecontrol[0][gc_viewpoint ][1] = KEY_JOY1+3; // Y + gamecontrol[0][gc_pause ][1] = KEY_JOY1+4; // Back + gamecontrol[0][gc_systemmenu ][0] = KEY_JOY1+6; // Start + //gamecontrol[0][gc_camtoggle ][1] = KEY_HAT1+0; // D-Pad Up + //gamecontrol[0][gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT + gamecontrol[0][gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down + gamecontrol[0][gc_scores ][1] = KEY_HAT1+0; // D-Pad Up } if (player == 0 || player == 2) { // Player 2 controls - gamecontrolbis[gc_accelerate ][0] = KEY_2JOY1+0; // A - gamecontrolbis[gc_lookback ][0] = KEY_2JOY1+2; // X - gamecontrolbis[gc_brake ][0] = KEY_2JOY1+1; // B - gamecontrolbis[gc_fire ][0] = KEY_2JOY1+9; // LB - gamecontrolbis[gc_drift ][0] = KEY_2JOY1+10; // RB + gamecontrol[1][gc_accelerate ][0] = KEY_2JOY1+0; // A + gamecontrol[1][gc_lookback ][0] = KEY_2JOY1+2; // X + gamecontrol[1][gc_brake ][0] = KEY_2JOY1+1; // B + gamecontrol[1][gc_fire ][0] = KEY_2JOY1+9; // LB + gamecontrol[1][gc_drift ][0] = KEY_2JOY1+10; // RB } if (player == 0 || player == 3) { // Player 3 controls - gamecontrol3[gc_accelerate ][0] = KEY_3JOY1+0; // A - gamecontrol3[gc_lookback ][0] = KEY_3JOY1+2; // X - gamecontrol3[gc_brake ][0] = KEY_3JOY1+1; // B - gamecontrol3[gc_fire ][0] = KEY_3JOY1+9; // LB - gamecontrol3[gc_drift ][0] = KEY_3JOY1+10; // RB + gamecontrol[2][gc_accelerate ][0] = KEY_3JOY1+0; // A + gamecontrol[2][gc_lookback ][0] = KEY_3JOY1+2; // X + gamecontrol[2][gc_brake ][0] = KEY_3JOY1+1; // B + gamecontrol[2][gc_fire ][0] = KEY_3JOY1+9; // LB + gamecontrol[2][gc_drift ][0] = KEY_3JOY1+10; // RB } if (player == 0 || player == 4) { // Player 4 controls - gamecontrol4[gc_accelerate ][0] = KEY_4JOY1+0; // A - gamecontrol4[gc_lookback ][0] = KEY_4JOY1+2; // X - gamecontrol4[gc_brake ][0] = KEY_4JOY1+1; // B - gamecontrol4[gc_fire ][0] = KEY_4JOY1+9; // LB - gamecontrol4[gc_drift ][0] = KEY_4JOY1+10; // RB + gamecontrol[3][gc_accelerate ][0] = KEY_4JOY1+0; // A + gamecontrol[3][gc_lookback ][0] = KEY_4JOY1+2; // X + gamecontrol[3][gc_brake ][0] = KEY_4JOY1+1; // B + gamecontrol[3][gc_fire ][0] = KEY_4JOY1+9; // LB + gamecontrol[3][gc_drift ][0] = KEY_4JOY1+10; // RB } } void G_SaveKeySetting(FILE *f) { - INT32 i; + INT32 i, k; - for (i = 1; i < num_gamecontrols; i++) + static const char *controltext[MAXSPLITSCREENPLAYERS] = { + "setcontrol", + "setcontrol2", + "setcontrol3", + "setcontrol4" + }; + + for (k = 0; k < MAXSPLITSCREENPLAYERS; k++) { - fprintf(f, "setcontrol \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrol[i][0])); + for (i = 1; i < num_gamecontrols; i++) + { + fprintf(f, "%s \"%s\" \"%s\"", controltext[k], gamecontrolname[i], + G_KeynumToString(gamecontrol[k][i][0])); - if (gamecontrol[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol[i][1])); - else - fprintf(f, "\n"); - } - - for (i = 1; i < num_gamecontrols; i++) - { - fprintf(f, "setcontrol2 \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrolbis[i][0])); - - if (gamecontrolbis[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrolbis[i][1])); - else - fprintf(f, "\n"); - } - - for (i = 1; i < num_gamecontrols; i++) - { - fprintf(f, "setcontrol3 \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrol3[i][0])); - - if (gamecontrol3[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol3[i][1])); - else - fprintf(f, "\n"); - } - - for (i = 1; i < num_gamecontrols; i++) - { - fprintf(f, "setcontrol4 \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrol4[i][0])); - - if (gamecontrol4[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol4[i][1])); - else - fprintf(f, "\n"); + if (gamecontrol[k][i][1]) + fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol[k][i][1])); + else + fprintf(f, "\n"); + } } } INT32 G_CheckDoubleUsage(INT32 keynum, boolean modify) { INT32 result = gc_null; + if (cv_controlperkey.value == 1) { - INT32 i, j; - for (i = 0; i < num_gamecontrols; i++) + INT32 i, j, k; + + for (k = 0; k < MAXSPLITSCREENPLAYERS; k++) { - for (j = 0; j < 2; j++) + for (i = 0; i < num_gamecontrols; i++) { - if (gamecontrol[i][j] == keynum) { - result = i; - if (modify) gamecontrol[i][j] = KEY_NULL; + for (j = 0; j < 2; j++) + { + if (gamecontrol[k][i][j] == keynum) + { + result = i; + if (modify) gamecontrol[k][i][j] = KEY_NULL; + } + + if (result && !modify) + return result; } - if (gamecontrolbis[i][j] == keynum) { - result = i; - if (modify) gamecontrolbis[i][j] = KEY_NULL; - } - if (gamecontrol3[i][j] == keynum) { - result = i; - if (modify) gamecontrol3[i][j] = KEY_NULL; - } - if (gamecontrol4[i][j] == keynum) { - result = i; - if (modify) gamecontrol4[i][j] = KEY_NULL; - } - if (result && !modify) - return result; } } } + return result; } @@ -1354,11 +1317,11 @@ static void setcontrol(INT32 (*gc)[2]) INT32 player; boolean nestedoverride = false; - if ((void*)gc == (void*)&gamecontrol4) + if ((void*)gc == (void*)&gamecontrol[3]) player = 3; - else if ((void*)gc == (void*)&gamecontrol3) + else if ((void*)gc == (void*)&gamecontrol[2]) player = 2; - else if ((void*)gc == (void*)&gamecontrolbis) + else if ((void*)gc == (void*)&gamecontrol[1]) player = 1; else player = 0; @@ -1421,7 +1384,7 @@ void Command_Setcontrol_f(void) return; } - setcontrol(gamecontrol); + setcontrol(gamecontrol[0]); } void Command_Setcontrol2_f(void) @@ -1436,7 +1399,7 @@ void Command_Setcontrol2_f(void) return; } - setcontrol(gamecontrolbis); + setcontrol(gamecontrol[1]); } void Command_Setcontrol3_f(void) @@ -1451,7 +1414,7 @@ void Command_Setcontrol3_f(void) return; } - setcontrol(gamecontrol3); + setcontrol(gamecontrol[2]); } void Command_Setcontrol4_f(void) @@ -1466,5 +1429,5 @@ void Command_Setcontrol4_f(void) return; } - setcontrol(gamecontrol4); + setcontrol(gamecontrol[3]); } diff --git a/src/g_input.h b/src/g_input.h index 820e2cdbc..b8e4cd8d8 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -121,16 +121,12 @@ extern INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], extern UINT8 gamekeydown[NUMINPUTS]; // two key codes (or virtual key) per game control -extern INT32 gamecontrol[num_gamecontrols][2]; -extern INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player -extern INT32 gamecontrol3[num_gamecontrols][2]; -extern INT32 gamecontrol4[num_gamecontrols][2]; -extern INT32 (*gamecontrols[MAXSPLITSCREENPLAYERS])[2]; +extern INT32 gamecontrol[MAXSPLITSCREENPLAYERS][num_gamecontrols][2]; -#define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]]) -#define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]]) -#define PLAYER3INPUTDOWN(gc) (gamekeydown[gamecontrol3[gc][0]] || gamekeydown[gamecontrol3[gc][1]]) -#define PLAYER4INPUTDOWN(gc) (gamekeydown[gamecontrol4[gc][0]] || gamekeydown[gamecontrol4[gc][1]]) +#define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[0][gc][0]] || gamekeydown[gamecontrol[0][gc][1]]) +#define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrol[1][gc][0]] || gamekeydown[gamecontrol[1][gc][1]]) +#define PLAYER3INPUTDOWN(gc) (gamekeydown[gamecontrol[2][gc][0]] || gamekeydown[gamecontrol[2][gc][1]]) +#define PLAYER4INPUTDOWN(gc) (gamekeydown[gamecontrol[3][gc][0]] || gamekeydown[gamecontrol[3][gc][1]]) // peace to my little coder fingers! // check a gamecontrol being active or not diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 268059d06..feedf4039 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1315,7 +1315,7 @@ boolean HU_Responder(event_t *ev) INT32 i; for (i = 0; i < num_gamecontrols; i++) { - if (gamecontrol[i][0] == ev->data1 || gamecontrol[i][1] == ev->data1) + if (gamecontrol[0][i][0] == ev->data1 || gamecontrol[0][i][1] == ev->data1) break; } @@ -1327,7 +1327,7 @@ boolean HU_Responder(event_t *ev) if (!chat_on) { // enter chat mode - if ((ev->data1 == gamecontrol[gc_talkkey][0] || ev->data1 == gamecontrol[gc_talkkey][1]) + if ((ev->data1 == gamecontrol[0][gc_talkkey][0] || ev->data1 == gamecontrol[0][gc_talkkey][1]) && netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise. { chat_on = true; @@ -1338,7 +1338,7 @@ boolean HU_Responder(event_t *ev) typelines = 1; return true; } - if ((ev->data1 == gamecontrol[gc_teamkey][0] || ev->data1 == gamecontrol[gc_teamkey][1]) + if ((ev->data1 == gamecontrol[0][gc_teamkey][0] || ev->data1 == gamecontrol[0][gc_teamkey][1]) && netgame && !OLD_MUTE) { chat_on = true; @@ -1364,8 +1364,8 @@ boolean HU_Responder(event_t *ev) // Ignore non-keyboard keys, except when the talk key is bound if (ev->data1 >= KEY_MOUSE1 - && (ev->data1 != gamecontrol[gc_talkkey][0] - && ev->data1 != gamecontrol[gc_talkkey][1])) + && (ev->data1 != gamecontrol[0][gc_talkkey][0] + && ev->data1 != gamecontrol[0][gc_talkkey][1])) return false; M_TextInputHandle(&w_chat, c); @@ -1377,8 +1377,8 @@ boolean HU_Responder(event_t *ev) HU_SendChatMessage(); } else if (c == KEY_ESCAPE - || ((c == gamecontrol[gc_talkkey][0] || c == gamecontrol[gc_talkkey][1] - || c == gamecontrol[gc_teamkey][0] || c == gamecontrol[gc_teamkey][1]) + || ((c == gamecontrol[0][gc_talkkey][0] || c == gamecontrol[0][gc_talkkey][1] + || c == gamecontrol[0][gc_teamkey][0] || c == gamecontrol[0][gc_teamkey][1]) && c >= KEY_MOUSE1)) // If it's not a keyboard key, then the chat button is used as a toggle. { chat_on = false; diff --git a/src/m_menu.c b/src/m_menu.c index bcd406e4c..27902ce9c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3887,8 +3887,8 @@ boolean M_Responder(event_t *ev) { if (currentMenu == &MISC_ChangeLevelDef || currentMenu == &MP_OfflineServerDef || currentMenu == &MP_ServerDef) { - if (ch == gamecontrol[gc_fire][0] - || ch == gamecontrol[gc_fire][1]) + if (ch == gamecontrol[0][gc_fire][0] + || ch == gamecontrol[0][gc_fire][1]) { COM_ImmedExecute("add kartencore 1"); } @@ -4021,9 +4021,9 @@ boolean M_Responder(event_t *ev) if (ch == -1) return false; - else if (ch == gamecontrol[gc_systemmenu][0] || ch == gamecontrol[gc_systemmenu][1]) // allow remappable ESC key + else if (ch == gamecontrol[0][gc_systemmenu][0] || ch == gamecontrol[0][gc_systemmenu][1]) // allow remappable ESC key ch = KEY_ESCAPE; - else if ((ch == gamecontrol[gc_accelerate][0] || ch == gamecontrol[gc_accelerate][1]) && ch >= KEY_MOUSE1) + else if ((ch == gamecontrol[0][gc_accelerate][0] || ch == gamecontrol[0][gc_accelerate][1]) && ch >= KEY_MOUSE1) ch = KEY_ENTER; // F-Keys @@ -4099,7 +4099,7 @@ boolean M_Responder(event_t *ev) return false; } - if ((ch == gamecontrol[gc_brake][0] || ch == gamecontrol[gc_brake][1]) && ch >= KEY_MOUSE1) // do this here, otherwise brake opens the menu mid-game + if ((ch == gamecontrol[0][gc_brake][0] || ch == gamecontrol[0][gc_brake][1]) && ch >= KEY_MOUSE1) // do this here, otherwise brake opens the menu mid-game ch = KEY_ESCAPE; routine = currentMenu->menuitems[itemOn].itemaction; @@ -10097,7 +10097,7 @@ static void M_HandleMasterServerResetChoice(event_t *ev) if (ev->type == ev_keydown) { - if (choice == ' ' || choice == 'y' || choice == KEY_ENTER || choice == gamecontrol[gc_accelerate][0] || choice == gamecontrol[gc_accelerate][1]) + if (choice == ' ' || choice == 'y' || choice == KEY_ENTER || choice == gamecontrol[0][gc_accelerate][0] || choice == gamecontrol[0][gc_accelerate][1]) { CV_Set(&cv_masterserver, cv_masterserver.defaultvalue); CV_Set(&cv_masterserver_nagattempts, cv_masterserver_nagattempts.defaultvalue); @@ -10251,8 +10251,8 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) if (levellistmode != LLM_RECORDATTACK) // so it doesent show in record attack menu { char encoretoggle[32] = {0}; - const char *item1 = gamecontrol[gc_fire][0] != 0 ? G_KeynumToString(gamecontrol[gc_fire][0]) : NULL; - const char *item2 = gamecontrol[gc_fire][1] != 0 ? G_KeynumToString(gamecontrol[gc_fire][1]) : NULL; + const char *item1 = gamecontrol[0][gc_fire][0] != 0 ? G_KeynumToString(gamecontrol[0][gc_fire][0]) : NULL; + const char *item2 = gamecontrol[0][gc_fire][1] != 0 ? G_KeynumToString(gamecontrol[0][gc_fire][1]) : NULL; if (item1 != NULL && item2 != NULL) snprintf(encoretoggle, 32, "%s/%s - Toggle Encore", item1, item2); @@ -11445,7 +11445,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) boolean exitmenu = false; // exit to previous menu and send name change const boolean gridselect = (cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED); // menus with "grids" - if ((choice == gamecontrol[gc_fire][0] || choice == gamecontrol[gc_fire][1]) && (itemOn == 2 || (gridselect && itemOn == 1))) + if ((choice == gamecontrol[0][gc_fire][0] || choice == gamecontrol[0][gc_fire][1]) && (itemOn == 2 || (gridselect && itemOn == 1))) choice = KEY_BACKSPACE; // Hack to allow resetting prefcolor on controllers #define BREAKWHENLOCKED {\ @@ -11741,8 +11741,8 @@ static void M_HandleSetupMultiPlayer(INT32 choice) break; //c why????? - //case gamecontrol[gc_accelerate][0]: - //case gamecontrol[gc_accelerate][1]: + //case gamecontrol[0][gc_accelerate][0]: + //case gamecontrol[0][gc_accelerate][1]: case KEY_ENTER: if (cv_skinselectmenu.value == SKINMENUTYPE_2D) { @@ -12356,7 +12356,7 @@ static void M_Setup1PControlsMenu(INT32 choice) { (void)choice; setupcontrolplayer = 1; - setupcontrols = gamecontrol; // was called from main Options (for console player, then) + setupcontrols = gamecontrol[0]; // was called from main Options (for console player, then) currentMenu->lastOn = itemOn; // Set proper gamepad options @@ -12379,7 +12379,7 @@ static void M_Setup2PControlsMenu(INT32 choice) { (void)choice; setupcontrolplayer = 2; - setupcontrols = gamecontrolbis; + setupcontrols = gamecontrol[1]; currentMenu->lastOn = itemOn; // Set proper gamepad options @@ -12402,7 +12402,7 @@ static void M_Setup3PControlsMenu(INT32 choice) { (void)choice; setupcontrolplayer = 3; - setupcontrols = gamecontrol3; + setupcontrols = gamecontrol[2]; currentMenu->lastOn = itemOn; // Set proper gamepad options @@ -12425,7 +12425,7 @@ static void M_Setup4PControlsMenu(INT32 choice) { (void)choice; setupcontrolplayer = 4; - setupcontrols = gamecontrol4; + setupcontrols = gamecontrol[3]; currentMenu->lastOn = itemOn; // Set proper gamepad options @@ -12673,17 +12673,17 @@ static void M_ResetControlsResponse(INT32 ch) switch (setupcontrolplayer) { case 4: - G_ClearControlKeys(gamecontrol4, i); + G_ClearControlKeys(gamecontrol[3], i); break; case 3: - G_ClearControlKeys(gamecontrol3, i); + G_ClearControlKeys(gamecontrol[2], i); break; case 2: - G_ClearControlKeys(gamecontrolbis, i); + G_ClearControlKeys(gamecontrol[1], i); break; case 1: default: - G_ClearControlKeys(gamecontrol, i); + G_ClearControlKeys(gamecontrol[0], i); break; } } diff --git a/src/m_misc.c b/src/m_misc.c index ff9892464..6b9699243 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1577,9 +1577,9 @@ boolean M_ScreenshotResponder(event_t *ev) if (ch >= KEY_MOUSE1 && menuactive) // If it's not a keyboard key, then don't allow it in the menus! return false; - if (ch == KEY_F8 || ch == gamecontrol[gc_screenshot][0] || ch == gamecontrol[gc_screenshot][1]) // remappable F8 + if (ch == KEY_F8 || ch == gamecontrol[0][gc_screenshot][0] || ch == gamecontrol[0][gc_screenshot][1]) // remappable F8 M_ScreenShot(); - else if (ch == KEY_F9 || ch == gamecontrol[gc_recordgif][0] || ch == gamecontrol[gc_recordgif][1]) // remappable F9 + else if (ch == KEY_F9 || ch == gamecontrol[0][gc_recordgif][0] || ch == gamecontrol[0][gc_recordgif][1]) // remappable F9 ((moviemode) ? M_StopMovie : M_StartMovie)(); else return false; diff --git a/src/st_stuff.c b/src/st_stuff.c index 6e39661e7..aac9b7fa7 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -506,8 +506,8 @@ static void ST_drawLevelTitle(void) static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound, boolean gamectrl) { static char buttname[32] = ""; - const char *butt1 = (gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL); - const char *butt2 = (gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL); // alternative bind + const char *butt1 = (gamecontrol[0][control][0] != 0 ? G_KeynumToString(gamecontrol[0][control][0]) : NULL); + const char *butt2 = (gamecontrol[0][control][1] != 0 ? G_KeynumToString(gamecontrol[0][control][1]) : NULL); // alternative bind if (butt1 == NULL && butt2 == NULL) // not bound to a button snprintf(buttname, 32, (unbound ? "%s - %s" : (gamectrl ? "-%s - %s" : "%s - %s")), (unbound ? "Unbound" : ""), inputtext); From 58a9e17500296996f402e93da3ce26dc863d5d19 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 09:42:01 +0200 Subject: [PATCH 19/35] fix spectator key lel oopsie --- src/g_game.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index eaec9e212..18b7f94c0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1299,6 +1299,25 @@ static INT32 pausedelay = 0; static INT32 camtoggledelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; static INT32 spectatedelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; +static void G_ToggleSpectate(INT32 player) +{ + switch (player) + { + case 0: + COM_ImmedExecute("changeteam spectator"); + break; + case 1: + COM_ImmedExecute("changeteam2 spectator"); + break; + case 2: + COM_ImmedExecute("changeteam3 spectator"); + break; + case 3: + COM_ImmedExecute("changeteam4 spectator"); + break; + } +} + static boolean G_LevelResponder(event_t *ev) { // allow spy mode changes even during the demo @@ -1500,7 +1519,7 @@ boolean G_Responder(event_t *ev) if (!spectatedelay[i]) { spectatedelay[i] = NEWTICRATE / 7; - COM_ImmedExecute("changeteam spectator"); + G_ToggleSpectate(i); } } From b6fd7a1e9675f6fa6513f3aea765a334e56672c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 13:02:26 +0200 Subject: [PATCH 20/35] put precip purge into a function to reduce code dupe and branching --- src/p_mobj.c | 20 ++++++-------------- src/p_saveg.c | 19 +------------------ src/p_spec.c | 44 +++++++++++++++----------------------------- src/p_spec.h | 1 + src/r_main.c | 22 +++------------------- 5 files changed, 26 insertions(+), 80 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index fb34b335d..364396ce8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10174,21 +10174,13 @@ void P_RemoveSavegameMobj(mobj_t *mobj) thinker_t *th = (thinker_t*)mobj; // unlink from sector and block lists - if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker) - { - P_UnsetPrecipThingPosition((precipmobj_t *)mobj); - } - else - { - // unlink from sector and block lists - P_UnsetThingPosition(mobj); + P_UnsetThingPosition(mobj); - // Remove touching_sectorlist from mobj. - if (sector_list) - { - P_DelSeclist(sector_list); - sector_list = NULL; - } + // Remove touching_sectorlist from mobj. + if (sector_list) + { + P_DelSeclist(sector_list); + sector_list = NULL; } // stop any playing sound diff --git a/src/p_saveg.c b/src/p_saveg.c index b5f11cedb..c63887b69 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2669,8 +2669,6 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) { thinker_t *currentthinker; thinker_t *next; - thinker_t *currentprecipthinker; - thinker_t *nextprecip; UINT8 tclass; UINT8 restoreNum = false; UINT32 i; @@ -2696,22 +2694,7 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) } // remove all the current precip thinkers - currentprecipthinker = precipcap.next; - for (currentprecipthinker = precipcap.next; currentprecipthinker != &precipcap; currentprecipthinker = nextprecip) - { - nextprecip = currentprecipthinker->next; - -#ifdef PARANOIA - if (currentprecipthinker->function.acp1 != (actionf_p1)P_NullPrecipThinker) - { - (next->prev = currentprecipthinker->prev)->next = nextprecip; - R_DestroyLevelInterpolators(currentprecipthinker); - Z_Free(currentprecipthinker); - } - else -#endif - P_RemoveSavegameMobj((mobj_t *)currentprecipthinker); // item isn't saved, don't remove it - } + P_PurgePrecipitation(); // we don't want the removed mobjs to come back iquetail = iquehead = 0; diff --git a/src/p_spec.c b/src/p_spec.c index 670289fcf..e14d09333 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1721,6 +1721,19 @@ static boolean is_rain_type (INT32 weathernum) } } +void P_PurgePrecipitation(void) +{ + thinker_t *think; + thinker_t *next; + + for (think = precipcap.next; think != NULL && think != &precipcap;) + { + next = think->next; + P_FreePrecipMobj((precipmobj_t *)think); + think = next; + } +} + // // P_SwitchWeather // @@ -1729,6 +1742,7 @@ static boolean is_rain_type (INT32 weathernum) void P_SwitchWeather(INT32 weathernum) { boolean purge = true; + boolean spawnprecip = false; if (weathernum == curWeather) return; @@ -1739,22 +1753,7 @@ void P_SwitchWeather(INT32 weathernum) if (purge) { - thinker_t *think; - thinker_t *next; - precipmobj_t *precipmobj; - - for (think = precipcap.next; think != &precipcap; think = next) - { - next = think->next; - -#ifdef PARANOIA - if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) - continue; // not a precipmobj thinker -#endif - - precipmobj = (precipmobj_t *)think; - P_FreePrecipMobj(precipmobj); - } + P_PurgePrecipitation(); } else // Rather than respawn all that crap, reuse it! { @@ -1764,11 +1763,6 @@ void P_SwitchWeather(INT32 weathernum) for (think = precipcap.next; think != &precipcap; think = think->next) { -#ifdef PARANOIA - if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) - continue; // not a precipmobj thinker -#endif - precipmobj = (precipmobj_t *)think; INT32 z = 0; @@ -1813,8 +1807,6 @@ void P_SwitchWeather(INT32 weathernum) } } - boolean spawnprecip = false; - switch (weathernum) { case PRECIP_SNOW: // snow @@ -1822,23 +1814,17 @@ void P_SwitchWeather(INT32 weathernum) spawnprecip = true; break; case PRECIP_RAIN: // rain - { curWeather = PRECIP_RAIN; spawnprecip = true; break; - } case PRECIP_STORM: // storm - { curWeather = PRECIP_STORM; spawnprecip = true; break; - } case PRECIP_STORM_NOSTRIKES: // storm w/o lightning - { curWeather = PRECIP_STORM_NOSTRIKES; spawnprecip = true; break; - } case PRECIP_STORM_NORAIN: // storm w/o rain curWeather = PRECIP_STORM_NORAIN; break; diff --git a/src/p_spec.h b/src/p_spec.h index c89d024d2..60b10a8f4 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -74,6 +74,7 @@ INT32 P_FindMinSurroundingLight(sector_t *sector, INT32 max); void P_SetupSignExit(player_t *player); boolean P_IsFlagAtBase(mobjtype_t flag); +void P_PurgePrecipitation(void); void P_SwitchWeather(INT32 weathernum); boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller); diff --git a/src/r_main.c b/src/r_main.c index 4ff9a96ff..b1b707d1d 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -295,27 +295,11 @@ static void FlipCam4_OnChange(void) static void Precipstuff_OnChange(void) { - if (gamestate != GS_LEVEL) - return; - - thinker_t *think; - thinker_t *next; - precipmobj_t *precipmobj; - - for (think = precipcap.next; think != &precipcap; think = next) + if (gamestate == GS_LEVEL) { - next = think->next; - -#ifdef PARANOIA - if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) - continue; // not a precipmobj thinker -#endif - - precipmobj = (precipmobj_t *)think; - P_FreePrecipMobj(precipmobj); + P_PurgePrecipitation(); + P_SpawnPrecipitation(); } - - P_SpawnPrecipitation(); } // From 45506b381e7c167c4c232622304e849917dc11f0 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 13:11:09 +0200 Subject: [PATCH 21/35] take mobjscale into account when skipping small sectors for precip spawn --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 364396ce8..3fd74f4a7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10244,7 +10244,7 @@ void P_SpawnPrecipitation(void) continue; // Exists, but is too small for reasonable precipitation. - if (!(precipsector->sector->floorheight <= precipsector->sector->ceilingheight - (32<sector->ceilingheight - precipsector->sector->floorheight, mapobjectscale) < 64< Date: Thu, 24 Apr 2025 06:56:35 +0200 Subject: [PATCH 22/35] deprecate "addskins" command "addskins" is an incredibly ambigous name since its main purpose was to add skins LOCALLY just prints a notice for now since there may be ppl that still use it --- src/d_netcmd.c | 35 +++-------------------------------- src/p_setup.c | 11 ----------- src/p_setup.h | 2 +- 3 files changed, 4 insertions(+), 44 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d3b9ca5b4..cd9c354fe 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4449,7 +4449,7 @@ static void Command_Addfilelocal(void) // Add any wad file, ignoring checks for if it contains complex things like // lua. Great for complex but client-side customizations, like different // level cards or anything like that. - P_AddWadFileLocal(fn); + P_AddWadFile(fn, true); } @@ -4544,38 +4544,9 @@ static void Command_Addfile(void) /** Adds something at runtime. */ -static void -Command_Addskins (void) +static void Command_Addskins(void) { - if (COM_Argc() > 3) - { - CONS_Printf( - "addskins : Load a skin file.\n"); - return; - } - // no forcing? - /* - if (fasticmp(COM_Argv(2), "-force") || fasticmp(COM_Argv(2), "-f")) { - CONS_Alert(CONS_NOTICE, M_GetText("Adding file %s. May or may not be a skin.\n"), COM_Argv(1)); - P_AddWadFile(COM_Argv(1), 0, true); - } else { - if (DumbStartsWith("KC_", COM_Argv(1))) { - P_AddWadFile(COM_Argv(1), 0, true); - } else if (DumbStartsWith("KCL_", COM_Argv(1))) { - if (!demo.playback) { - CONS_Alert(CONS_ERROR, M_GetText("Cannot add file %s as it is a skin with lua. Include -force or -f to force it to load.\n"), COM_Argv(1)); - return; - } else { - */ - P_AddWadFile(COM_Argv(1), true); - /* - } - } else { - CONS_Alert(CONS_ERROR, M_GetText("Cannot add file %s as it is not a skin.\n"), COM_Argv(1)); - return; - } - } - */ + CONS_Printf("addskins has been deprecated\nuse addfilelocal instead!\n"); } static void Command_GLocalSkin (void) diff --git a/src/p_setup.c b/src/p_setup.c index b51a8abce..1ef81c3cb 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3252,17 +3252,6 @@ boolean P_AddWadFile(const char *wadfilename, boolean local) return true; } -boolean P_AddWadFileLocal(const char *wadfilename) -{ - UINT16 wadnum; - - if ((wadnum = P_PartialAddWadFile(wadfilename, true)) == UINT16_MAX) - return false; - - P_MultiSetupWadFiles(true); - return true; -} - // check for replacement votescreen backgrounds boolean wideracereplaced = false; boolean racereplaced = false; diff --git a/src/p_setup.h b/src/p_setup.h index 723b48d18..f0ae13e6c 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -65,8 +65,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate); #ifdef HWRENDER void HWR_LoadLevel(void); #endif + boolean P_AddWadFile(const char *wadfilename, boolean local); -boolean P_AddWadFileLocal(const char *wadfilename); extern boolean wideracereplaced; extern boolean racereplaced; From cd15c5d3803651b756a831ef39aae77a1acc6a07 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 24 Apr 2025 09:21:11 +0200 Subject: [PATCH 23/35] oops didnt think addskins would be used here lel --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 27902ce9c..b78e72ee5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6719,7 +6719,7 @@ static void M_HandleAddons(INT32 choice) { if (DumbStartsWith("KC_", dirmenu[dir_on[menudepthleft]]+DIR_STRING) || DumbStartsWith("kc_", dirmenu[dir_on[menudepthleft]]+DIR_STRING)) { M_StartMessage(va("%c%s\x80\nYou are loading a local skin.\nLocal skins will not be usable\nafter going back from\nthe title screen.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING); - COM_BufAddText(va("addskins \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); + COM_BufAddText(va("addfilelocal \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); } else S_StartSound(NULL, sfx_s26d); From 4f83d3b36bc9c72a7c24da90c53ea0d95656faa8 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 25 Apr 2025 15:02:36 +0200 Subject: [PATCH 24/35] whitespace crap --- src/d_clisrv.c | 3 ++- src/d_netcmd.c | 6 +++--- src/g_game.c | 7 ++++--- src/m_menu.c | 2 +- src/tables.c | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d76e67e88..51abad01d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6305,7 +6305,8 @@ static void Local_Maketic(INT32 realtics) D_ProcessEvents(); // menu responder, cons responder, // game responder calls HU_Responder, AM_Responder, F_Responder, // and G_MapEventsToControls - if (!dedicated) rendergametic = gametic; + if (!dedicated) + rendergametic = gametic; // translate inputs (keyboard/mouse/joystick) into game controls for (i = 0; i <= splitscreen; i++) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index cd9c354fe..4d41ada94 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2691,7 +2691,8 @@ static tic_t last_map_cmd = 0; // static void Command_Map_f(void) { - if (I_GetTime() - last_map_cmd < 20) { + if (I_GetTime() - last_map_cmd < 20) + { CONS_Alert(CONS_WARNING, "Map command is used too frequently!\n"); return; } @@ -2749,8 +2750,7 @@ static void Command_Map_f(void) { if (!multiplayer) { - CONS_Printf(M_GetText( - "You can't switch gametypes in single player!\n")); + CONS_Printf(M_GetText("You can't switch gametypes in single player!\n")); return; } else if (COM_Argc() < option_gametype + 2)/* no argument after? */ diff --git a/src/g_game.c b/src/g_game.c index 18b7f94c0..77257a6fb 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4010,7 +4010,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool unlocktriggers = 0; // clear itemfinder, just in case - if (!dedicated) // except in dedicated servers, where it is not registered and can actually I_Error debug builds + if (!dedicated) // except in dedicated servers, where it is not registered and can actually I_Error debug builds CV_StealthSetValue(&cv_itemfinder, 0); } @@ -4028,7 +4028,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool // gamemap changed; we assume that its map header is always valid, // so make it so - if(!mapheaderinfo[gamemap-1]) + if (!mapheaderinfo[gamemap-1]) P_AllocMapHeader(gamemap-1); maptol = mapheaderinfo[gamemap-1]->typeoflevel; @@ -5345,7 +5345,8 @@ void G_ConsGhostTic(INT32 playernum) void G_GhostTicker(void) { demoghost *g,*p; - for(g = ghosts, p = NULL; g; g = g->next) + + for (g = ghosts, p = NULL; g; g = g->next) { // Skip normal demo data. UINT8 ziptic = READUINT8(g->p); diff --git a/src/m_menu.c b/src/m_menu.c index b78e72ee5..283870f7c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9290,7 +9290,7 @@ static void M_TimeAttack(INT32 choice) if (M_CountLevelsToShowInList() == 0) { - M_StartMessage(M_GetText("No record-attackable levels found.\n"),NULL,MM_NOTHING); + M_StartMessage(M_GetText("No record-attackable levels found.\n"), NULL, MM_NOTHING); return; } diff --git a/src/tables.c b/src/tables.c index e293842bc..98a2c8a17 100644 --- a/src/tables.c +++ b/src/tables.c @@ -274,7 +274,7 @@ boolean FV2_InsidePolygon(const vector2_t *vIntersection, const vector2_t *Poly, // with floating point numbers. It usually won't always be perfectly 2 * PI, so we need // to use a little twiddling. I use .9999, but you can change this to fit your own desired accuracy. - if(Angle >= ANGLE_MAX) // If the angle is greater than 2 PI, (360 degrees) + if (Angle >= ANGLE_MAX) // If the angle is greater than 2 PI, (360 degrees) return 1; // The point is inside of the polygon return 0; // If you get here, it obviously wasn't inside the polygon. From a18e81ee186119efbd9418bb226cb358cdb5d1d9 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 25 Apr 2025 21:33:08 +0200 Subject: [PATCH 25/35] invert skywall offset also fixes the issue, but doesent draw skywalls over actual walls in rare cases lets hope this doesent draw walls over actual skywalls now (: --- 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 0fcb58a3d..d2e363079 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1557,7 +1557,7 @@ void GL_SetBlend(FBITFIELD PolyFlags) { if (PolyFlags & PF_Skydecal) { - pglPolygonOffset(-0.45f, -0.45f); // dont let skywalls draw over actual walls tho + pglPolygonOffset(0.45f, 0.45f); pglEnable(GL_POLYGON_OFFSET_FILL); } else From 8ad161f061af7c885e7fcd02f1fc17b3e1810aed Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 25 Apr 2025 21:34:02 +0200 Subject: [PATCH 26/35] add a few more branching hints also fix some indentation --- src/hardware/hw_main.c | 69 +++++++++++++++++++++--------------------- src/p_slopes.c | 5 ++- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 37d0e25cd..096e738c6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2437,8 +2437,8 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) // Find the corners of the box // that define the edges from current viewpoint. - const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT ] ? 1 : 2) + - (viewy >= bspcoord[BOXTOP ] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); + const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT] ? 1 : 2) + + (viewy >= bspcoord[BOXTOP] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); if (boxpos == 5) return true; @@ -2877,7 +2877,7 @@ static void HWR_Subsector(size_t num) gl_frontsector = R_FakeFlat(gl_frontsector, &tempsec, &floorlightlevel, &ceilinglightlevel, false); - if (gl_portal_state == GLPORTAL_SEARCH) + if (UNLIKELY(gl_portal_state == GLPORTAL_SEARCH)) { goto doaddline; } @@ -3003,37 +3003,37 @@ static void HWR_Subsector(size_t num) { UINT8 alpha; - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < bottomCullHeight)); alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, - &extrasubsectors[num], - false, - *rover->bottomheight, - *gl_frontsector->lightlist[light].lightlevel, - alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, - true, rover->master->frontsector->extra_colormap); + &extrasubsectors[num], + false, + *rover->bottomheight, + *gl_frontsector->lightlist[light].lightlevel, + alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, + true, rover->master->frontsector->extra_colormap); } else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient { - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < bottomCullHeight)); HWR_AddTransparentFloor(levelflats[*rover->bottompic].lumpnum, - &extrasubsectors[num], - false, - *rover->bottomheight, - *gl_frontsector->lightlist[light].lightlevel, - CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), - false, gl_frontsector->lightlist[light].extra_colormap); + &extrasubsectors[num], + false, + *rover->bottomheight, + *gl_frontsector->lightlist[light].lightlevel, + CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), + false, gl_frontsector->lightlist[light].extra_colormap); } else { HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gl_frontsector, false)); - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < bottomCullHeight)); HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, - rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); + rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); } } @@ -3049,21 +3049,21 @@ static void HWR_Subsector(size_t num) { UINT8 alpha; - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < topCullHeight)); alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, - &extrasubsectors[num], - true, - *rover->topheight, - *gl_frontsector->lightlist[light].lightlevel, - alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, - true, rover->master->frontsector->extra_colormap); + &extrasubsectors[num], + true, + *rover->topheight, + *gl_frontsector->lightlist[light].lightlevel, + alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, + true, rover->master->frontsector->extra_colormap); } else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < topCullHeight)); HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, &extrasubsectors[num], @@ -3076,10 +3076,10 @@ static void HWR_Subsector(size_t num) else { HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gl_frontsector, true)); - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < topCullHeight)); HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, - rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); + rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); } } } @@ -3459,7 +3459,7 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) sSurf.PolyColor.s.green = 0x01; // shadow is always half as translucent as the sprite itself - if (!cv_translucency.value) // use default translucency (main sprite won't have any translucency) + if (UNLIKELY(!cv_translucency.value)) // use default translucency (main sprite won't have any translucency) sSurf.PolyColor.s.alpha = 0x80; // default else if (spr->mobj->flags2 & MF2_SHADOW) sSurf.PolyColor.s.alpha = 0x20; @@ -3668,7 +3668,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) else blendmode = spr->mobj->blendmode; - if (!cv_translucency.value) // translucency disabled + if (UNLIKELY(!cv_translucency.value)) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; blend = PF_Translucent|PF_Occlude; @@ -3952,7 +3952,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else blendmode = spr->mobj->blendmode; - if (!cv_translucency.value) // translucency disabled + if (UNLIKELY(!cv_translucency.value)) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; blend = PF_Translucent|PF_Occlude; @@ -5316,6 +5316,7 @@ static void HWR_SetTransformAiming(FTransform *trans) trans->shearing = false; gl_aimingangle = aimingangle; } + trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(FINEDEGREE); } @@ -5451,7 +5452,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl validcount++; - if (cv_glbatching.value) + if (LIKELY(cv_glbatching.value)) HWR_StartBatching(); if (useportals && !rootportal && portallist.base && !skybox) // if portals have been drawn in the main view, then render skywalls differently @@ -5475,7 +5476,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl PS_STOP_TIMING(ps_bsptime); - if (cv_glbatching.value) + if (LIKELY(cv_glbatching.value)) HWR_RenderBatches(); if (skyWallVertexArraySize) // if there are skywalls to draw using the alternate method diff --git a/src/p_slopes.c b/src/p_slopes.c index e64cd6f6b..b4ebf0284 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -500,6 +500,7 @@ void P_SpawnSlope_Line(int linenum) P_CalculateSlopeNormal(cslope); } } + if (backfloor || backceil) { line->backsector->hasslope = true; // Tell the software renderer that we're sloped @@ -511,7 +512,7 @@ void P_SpawnSlope_Line(int linenum) extent = P_GetExtent(line->backsector, line); - if(extent < 0) + if (extent < 0) { CONS_Printf("P_SpawnSlope_Line failed to get backsector extent on line number %i\n", linenum); return; @@ -678,8 +679,6 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag return ret; } - - // // P_CopySectorSlope // From cf453bad5f292cffc5a11b9491b963f8e30ee6a8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 27 Apr 2025 00:24:52 +0200 Subject: [PATCH 27/35] make a struct for squishy this is horrid but should fix this speeding up when multiple players squish --- src/d_player.h | 12 +++++++++++- src/p_user.c | 44 +++++++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index a1e4a0b20..af24630c2 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -356,6 +356,16 @@ typedef enum LAP__MAX } laptime_e; +// yes i made a whole struct for this :chonkbuncle: +typedef struct squishdance_s +{ + tic_t countdown; // hold "custom 3" for 2 seconds to engange le dance + tic_t time; + fixed_t work; + fixed_t ang; + fixed_t bounce; // hehe squishy +} squishdance_t; + // ======================================================================== // PLAYER STRUCTURE // ======================================================================== @@ -555,7 +565,7 @@ typedef struct player_s fixed_t spinoutrot; // When a player spins out, this value increments modulus 360. - tic_t dancetime; + squishdance_t squishdance; fixed_t fovadd; // adjust FOV for hw rendering } player_t; diff --git a/src/p_user.c b/src/p_user.c index c9712048e..669ab0ef4 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4436,40 +4436,39 @@ DoABarrelRoll (player_t *player) player->tilt = slope; } -#define SPINOUTROTSPEED (24 * FRACUNIT) -#define MAXSPINROT (360 * FRACUNIT) - -static void P_DoFunnyDance (player_t *player) +// mhhm this is definitely not mostly copy pasted code from SRB2s music test (: +// TODO: make this sane lmao +static void P_DoFunnyDance(player_t *player) { - static tic_t time = 0; - fixed_t bounce; - fixed_t work, bpm; - angle_t ang; + fixed_t bpm; if (player->spectator || !player->mo || player->kartstuff[k_respawn] || player->mo->salty_jump) // this looks jank as hell during hop return; - bounce = 0; + player->squishdance.bounce = 0; // bpm = FLOAT_TO_FIXED(mapmusic.bpm) << maybe can get the tempo and beat detection lib to work for bpm autodetection bpm = FixedDiv((60*TICRATE)<squishdance.work = (player->squishdance.time << FRACBITS) % bpm; - if (time >= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes - time = (work>>FRACBITS); + if (player->squishdance.time >= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes + player->squishdance.time = (player->squishdance.work>>FRACBITS); - work = FixedDiv(work*180, bpm); + player->squishdance.work = FixedDiv(player->squishdance.work*180, bpm); - ang = (FixedAngle(work)>>ANGLETOFINESHIFT) & FINEMASK; - bounce = (FINESINE(ang) - FRACUNIT/2); + player->squishdance.ang = ((FixedAngle(player->squishdance.work)>>ANGLETOFINESHIFT) & FINEMASK); + player->squishdance.bounce = (FINESINE(player->squishdance.ang) - FRACUNIT/2); - player->mo->spritexscale -= bounce/2; - player->mo->spriteyscale += bounce/2; + player->mo->spritexscale -= player->squishdance.bounce/2; + player->mo->spriteyscale += player->squishdance.bounce/2; - time++; // bruh + player->squishdance.time++; } +#define SPINOUTROTSPEED (24 * FRACUNIT) +#define MAXSPINROT (360 * FRACUNIT) + // // P_PlayerThink // @@ -5009,13 +5008,16 @@ void P_PlayerThink(player_t *player) if (cv_squishdance.value && (cmd->buttons & BT_CUSTOM3)) { - player->dancetime++; + player->squishdance.countdown++; - if (player->dancetime > TICRATE*2) + if (player->squishdance.countdown > TICRATE*2) P_DoFunnyDance(player); } else - player->dancetime = 0; + { + player->squishdance.countdown = 0; + player->squishdance.time = 0; + } // Flash player after being hit. if (!(player->kartstuff[k_hyudorotimer] // SRB2kart - fixes Hyudoro not flashing when it should. From 9c8aee1befb6e3ba5b396134160558776885b3cf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 27 Apr 2025 00:57:43 +0200 Subject: [PATCH 28/35] tiny optimization we dont need to recalc the bpm stuff we can also divide the bounce in half just once --- src/p_user.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 669ab0ef4..31e6a52ef 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4440,28 +4440,27 @@ DoABarrelRoll (player_t *player) // TODO: make this sane lmao static void P_DoFunnyDance(player_t *player) { - fixed_t bpm; + static const fixed_t bpm = 983040; // 140bpm ish if (player->spectator || !player->mo || player->kartstuff[k_respawn] || player->mo->salty_jump) // this looks jank as hell during hop return; player->squishdance.bounce = 0; - // bpm = FLOAT_TO_FIXED(mapmusic.bpm) << maybe can get the tempo and beat detection lib to work for bpm autodetection - bpm = FixedDiv((60*TICRATE)<squishdance.work = (player->squishdance.time << FRACBITS) % bpm; - if (player->squishdance.time >= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes - player->squishdance.time = (player->squishdance.work>>FRACBITS); + if (player->squishdance.time >= (FRACUNIT >> 1)) // prevent overflow jump - takes about 15 minutes + player->squishdance.time = (player->squishdance.work >> FRACBITS); player->squishdance.work = FixedDiv(player->squishdance.work*180, bpm); - player->squishdance.ang = ((FixedAngle(player->squishdance.work)>>ANGLETOFINESHIFT) & FINEMASK); - player->squishdance.bounce = (FINESINE(player->squishdance.ang) - FRACUNIT/2); + player->squishdance.ang = ((FixedAngle(player->squishdance.work) >> ANGLETOFINESHIFT) & FINEMASK); + player->squishdance.bounce = ((FINESINE(player->squishdance.ang) - FRACUNIT/2) / 2); - player->mo->spritexscale -= player->squishdance.bounce/2; - player->mo->spriteyscale += player->squishdance.bounce/2; + player->mo->spritexscale -= player->squishdance.bounce; + player->mo->spriteyscale += player->squishdance.bounce; player->squishdance.time++; } From b960e3d84879714526ca0200688cbb7829cdfe9a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 27 Apr 2025 13:14:52 +0200 Subject: [PATCH 29/35] fix replay ghost double free kinda rare, but may happen when you resynch on the exact same time you got hit by something --- src/g_game.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 77257a6fb..0712a49e5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4833,6 +4833,7 @@ void G_GhostAddThok(INT32 playernum) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_THOK; } @@ -4840,6 +4841,7 @@ void G_GhostAddSpin(INT32 playernum) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_SPIN; } @@ -4847,6 +4849,7 @@ void G_GhostAddRev(INT32 playernum) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_REV; } @@ -4854,6 +4857,7 @@ void G_GhostAddFlip(INT32 playernum) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags |= EZT_FLIP; } @@ -4861,11 +4865,13 @@ void G_GhostAddColor(INT32 playernum, ghostcolor_t color) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + if (ghostext[playernum].lastcolor == (UINT8)color) { ghostext[playernum].flags &= ~EZT_COLOR; return; } + ghostext[playernum].flags |= EZT_COLOR; ghostext[playernum].color = (UINT8)color; } @@ -4874,11 +4880,13 @@ void G_GhostAddScale(INT32 playernum, fixed_t scale) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + if (ghostext[playernum].lastscale == scale) { ghostext[playernum].flags &= ~EZT_SCALE; return; } + ghostext[playernum].flags |= EZT_SCALE; ghostext[playernum].scale = scale; } @@ -4887,9 +4895,10 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags |= EZT_HIT; ghostext[playernum].hits++; - ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, NULL); + ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, &ghostext[playernum].hitlist); P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim); } @@ -4909,7 +4918,7 @@ void G_WriteAllGhostTics(void) if (!playeringame[i] || players[i].spectator) continue; - if (!players[i].mo) + if (P_MobjWasRemoved(players[i].mo)) continue; counter++; @@ -4993,6 +5002,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) // Store one full byte of movement, plus one byte of fractional movement. INT16 momx = (INT16)((ghost->x-oldghost[playernum].x + (1<<4))>>8); INT16 momy = (INT16)((ghost->y-oldghost[playernum].y + (1<<4))>>8); + if (momx != oldghost[playernum].momx || momy != oldghost[playernum].momy) { @@ -5005,7 +5015,9 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEINT16(demobuf.p,momx); WRITEINT16(demobuf.p,momy); } + momx = (INT16)((ghost->z-oldghost[playernum].z + (1<<4))>>8); + if (momx != oldghost[playernum].momz) { oldghost[playernum].momz = momx; @@ -5077,6 +5089,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) if (ghostext[playernum].color == ghostext[playernum].lastcolor) ghostext[playernum].flags &= ~EZT_COLOR; + if (ghostext[playernum].scale == ghostext[playernum].lastscale) ghostext[playernum].flags &= ~EZT_SCALE; @@ -5091,16 +5104,19 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEUINT8(demobuf.p,ghostext[playernum].color); ghostext[playernum].lastcolor = ghostext[playernum].color; } + if (ghostext[playernum].flags & EZT_SCALE) { CHECKSPACE(sizeof(fixed_t)); WRITEFIXED(demobuf.p,ghostext[playernum].scale); ghostext[playernum].lastscale = ghostext[playernum].scale; } + if (ghostext[playernum].flags & EZT_HIT) { CHECKSPACE(2); WRITEUINT16(demobuf.p,ghostext[playernum].hits); + for (i = 0; i < ghostext[playernum].hits; i++) { mobj_t *mo = ghostext[playernum].hitlist[i]; @@ -5116,23 +5132,24 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEANGLE(demobuf.p,mo->angle); P_SetTarget(ghostext[playernum].hitlist+i, NULL); } - Z_Free(ghostext[playernum].hitlist); + ghostext[playernum].hits = 0; - ghostext[playernum].hitlist = NULL; } + if (ghostext[playernum].flags & EZT_SPRITE) { CHECKSPACE(1); WRITEUINT8(demobuf.p,sprite); } + if (ghostext[playernum].flags & EZT_KART) { CHECKSPACE(12); - WRITEINT32(demobuf.p, ghostext[playernum].kartitem); WRITEINT32(demobuf.p, ghostext[playernum].kartamount); WRITEINT32(demobuf.p, ghostext[playernum].kartbumpers); } + ghostext[playernum].flags = 0; } @@ -5180,6 +5197,7 @@ void G_ConsGhostTic(INT32 playernum) // Grab ghost data. ziptic = READUINT8(demobuf.p); + if (ziptic & GZT_XYZ) { oldghost[playernum].x = READFIXED(demobuf.p); @@ -5194,17 +5212,22 @@ void G_ConsGhostTic(INT32 playernum) oldghost[playernum].momx = READINT16(demobuf.p)<<8; oldghost[playernum].momy = READINT16(demobuf.p)<<8; } + if (ziptic & GZT_MOMZ) oldghost[playernum].momz = READINT16(demobuf.p)<<8; + oldghost[playernum].x += oldghost[playernum].momx; oldghost[playernum].y += oldghost[playernum].momy; oldghost[playernum].z += oldghost[playernum].momz; syncleeway = FRACUNIT; } + if (ziptic & GZT_ANGLE) demobuf.p++; + if (ziptic & GZT_SPRITE) demobuf.p++; + if (ziptic & GZT_NIGHTS) { if (!testmo || !testmo->player || !(testmo->player->pflags & PF_NIGHTSMODE) || !testmo->tracer) @@ -5218,8 +5241,10 @@ void G_ConsGhostTic(INT32 playernum) ziptic = READUINT8(demobuf.p); if (ziptic & EZT_COLOR) demobuf.p++; + if (ziptic & EZT_SCALE) demobuf.p += sizeof(fixed_t); + if (ziptic & EZT_HIT) { // Resync mob damage. UINT16 i, count = READUINT16(demobuf.p); @@ -5252,6 +5277,7 @@ void G_ConsGhostTic(INT32 playernum) break; mobj = NULL; // wasn't this one, keep searching. } + if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { if (demosynced) @@ -5259,13 +5285,16 @@ void G_ConsGhostTic(INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (health)!\n")); CONS_Printf("expected health %d got %d\n", health, mobj->health); } + demosynced = false; P_DamageMobj(mobj, players[0].mo, players[0].mo, 1); } } } + if (ziptic & EZT_SPRITE) demobuf.p++; + if (ziptic & EZT_KART) { ghostext[playernum].kartitem = READINT32(demobuf.p); From 4f81349ea38d6eec35f038f64655674d079e80a7 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 28 Apr 2025 09:55:10 +0200 Subject: [PATCH 30/35] another tiny cleanup p_setup and p_saveg --- src/p_saveg.c | 18 +-- src/p_setup.c | 429 ++++++++++++++++++++++---------------------------- src/p_setup.h | 2 +- 3 files changed, 196 insertions(+), 253 deletions(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index c63887b69..c875272bd 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1009,13 +1009,13 @@ static inline UINT32 SaveMobjnum(const mobj_t *mobj) return 0; } -static UINT32 SaveSector(const sector_t *sector) +static inline UINT32 SaveSector(const sector_t *sector) { if (sector) return (UINT32)(sector - sectors); return 0xFFFFFFFF; } -static UINT32 SaveLine(const line_t *line) +static inline UINT32 SaveLine(const line_t *line) { if (line) return (UINT32)(line - lines); return 0xFFFFFFFF; @@ -1040,11 +1040,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 UINT16 diff2; // Ignore stationary hoops - these will be respawned from mapthings. - if (mobj->type == MT_HOOP) - return; - - // These are NEVER saved. - if (mobj->type == MT_HOOPCOLLIDE) + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE) // These are NEVER saved. return; // This hoop has already been collected. @@ -1905,13 +1901,13 @@ static inline mobj_t *LoadMobj(UINT32 mobjnum) return (mobj_t *)(size_t)mobjnum; } -static sector_t *LoadSector(UINT32 sector) +static inline sector_t *LoadSector(UINT32 sector) { if (sector >= numsectors) return NULL; return §ors[sector]; } -static line_t *LoadLine(UINT32 line) +static inline line_t *LoadLine(UINT32 line) { if (line >= numlines) return NULL; return &lines[line]; @@ -3022,7 +3018,7 @@ static void P_RelinkPointers(void) mobj = (mobj_t *)currentthinker; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + if (UNLIKELY(mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER)) continue; #define RELINK(obj, name) if ((obj) && !RelinkMobj(&(obj))) \ @@ -3439,7 +3435,7 @@ void P_SaveNetGame(savebuffer_t *save, boolean resending) mobj = (mobj_t *)th; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + if (UNLIKELY(mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER)) continue; mobj->mobjnum = i++; diff --git a/src/p_setup.c b/src/p_setup.c index 1ef81c3cb..973d37f82 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -357,6 +357,7 @@ void P_AllocMapHeader(INT16 i) mapheaderinfo[i] = Z_Malloc(sizeof(mapheader_t), PU_STATIC, NULL); mapheaderinfo[i]->grades = NULL; } + P_ClearSingleMapHeaderInfo(i + 1); } @@ -434,8 +435,10 @@ UINT8 P_GetGrade(UINT32 pscore, INT16 map, UINT8 mare) if (pscore >= mapheaderinfo[map-1]->grades[mare].grade[i]) ++pgrade; } + return (UINT8)pgrade; } + return 0; } @@ -443,10 +446,8 @@ UINT8 P_HasGrades(INT16 map, UINT8 mare) { // Determining the grade // Mare 0 is treated as overall and is true if ANY grades exist - if (mapheaderinfo[map-1] && mapheaderinfo[map-1]->grades - && (mare == 0 || mapheaderinfo[map-1]->numGradedMares >= mare)) - return true; - return false; + return (mapheaderinfo[map-1] && mapheaderinfo[map-1]->grades + && (mare == 0 || mapheaderinfo[map-1]->numGradedMares >= mare)); } UINT32 P_GetScoreForGrade(INT16 map, UINT8 mare, UINT8 grade) @@ -796,7 +797,7 @@ INT32 P_AddLevelFlatRuntime(const char *flatname) // first scan through the already found flats // for (i = 0; i < numlevelflats; i++, levelflat++) - if (strnicmp(levelflat->name,flatname,8)==0) + if (strnicmp(levelflat->name, flatname, 8) == 0) break; // that flat was already found in the level, return the id @@ -837,7 +838,7 @@ INT32 P_CheckLevelFlat(const char *flatname) // scan through the already found flats // for (i = 0; i < numlevelflats; i++, levelflat++) - if (strnicmp(levelflat->name,flatname,8)==0) + if (strnicmp(levelflat->name, flatname, 8) == 0) break; if (i == numlevelflats) @@ -1351,10 +1352,180 @@ static void P_LoadLineDefs2(void) } } +static void P_LoadSideColormaps(mapsidedef_t *msd, side_t *sd, sector_t *sec) +{ + INT32 num; + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + // for now, full support of toptexture only + if ((msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) + || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6])) + { + char *col; + RGBA_t color; + size_t j; + + sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->bottomtexture = 0; +#define HEX2INT(x) (x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) +#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) + sec->extra_colormap = &extra_colormaps[sec->midmap]; + + if (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) + { + col = msd->toptexture; + + // encore mode colormaps! + // do it like software by aproximating a color to a palette index, and then convert it to its encore variant and then back to a color code. + // do this for both the start and fade colormaps. + + color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); + color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); + color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); + +#ifdef GLENCORE + if (encoremap) + { + j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)]; + color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below + } +#endif + color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly + sec->extra_colormap->rgba = color.rgba; + + // alpha + if (msd->toptexture[7]) + sec->extra_colormap->rgba += (ALPHA2INT(col[7]) << 24); + else + sec->extra_colormap->rgba += (25 << 24); + } + else + sec->extra_colormap->rgba = 0; + + if (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) + { + col = msd->bottomtexture; + + // do the exact same thing as above here. + + color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); + color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); + color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); + +#ifdef GLENCORE + if (encoremap) + { + j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)]; + color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below + } +#endif + color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly + sec->extra_colormap->fadergba = color.rgba; + + // alpha + if (msd->bottomtexture[7]) + sec->extra_colormap->fadergba += (ALPHA2INT(col[7]) << 24); + else + sec->extra_colormap->fadergba += (25 << 24); + } + else + sec->extra_colormap->fadergba = 0x19000000; // default alpha, (25 << 24) +#undef ALPHA2INT +#undef HEX2INT + } + else + { + if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) + sd->toptexture = 0; + else + sd->toptexture = num; + + if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) + sd->midtexture = 0; + else + sd->midtexture = num; + + if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) + sd->bottomtexture = 0; + else + sd->bottomtexture = num; + } + } +#endif +#ifdef HWRENDER + else +#endif + { + if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#') + { + sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->bottomtexture = 0; + } + else + { + if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) + sd->toptexture = 0; + else + sd->toptexture = num; + if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) + sd->midtexture = 0; + else + sd->midtexture = num; + if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) + sd->bottomtexture = 0; + else + sd->bottomtexture = num; + } + } +} + +static void P_LoadSideChangeMusic(boolean firstside, mapsidedef_t *msd, side_t *sd) +{ + char process[8+1]; + + sd->toptexture = sd->midtexture = sd->bottomtexture = 0; + + if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') + { + M_Memcpy(process,msd->bottomtexture,8); + process[8] = '\0'; + sd->bottomtexture = get_number(process); + } + + if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0') + { + M_Memcpy(process,msd->midtexture,8); + process[8] = '\0'; + sd->midtexture = get_number(process); + } + + // always process if back sidedef, because we need that - symbol + sd->text = Z_Malloc(7, PU_LEVEL, NULL); + + if (firstside || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') + { + M_Memcpy(process,msd->toptexture,8); + process[8] = '\0'; + + // If they type in O_ or D_ and their music name, just shrug, + // then copy the rest instead. + if ((process[0] == 'O' || process[0] == 'D') && process[7]) + M_Memcpy(sd->text, process+2, 6); + else // Assume it's a proper music name. + M_Memcpy(sd->text, process, 6); + sd->text[6] = 0; + } + else + sd->text[0] = 0; +} + static void P_LoadRawSideDefs2(void *data) { UINT16 i; - INT32 num; for (i = 0; i < numsides; i++) { @@ -1388,186 +1559,11 @@ static void P_LoadRawSideDefs2(void *data) case 606: //SoM: 4/4/2000: Just colormap transfer // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. -#ifdef HWRENDER - if (rendermode != render_opengl) -#endif - { - if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#') - { - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } - break; - } -#ifdef HWRENDER - else - { - // for now, full support of toptexture only - if ((msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6])) - { - char *col; - RGBA_t color; - size_t j; - - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; -#define HEX2INT(x) (x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) -#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) - sec->extra_colormap = &extra_colormaps[sec->midmap]; - - if (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - { - col = msd->toptexture; - - // encore mode colormaps! - // do it like software by aproximating a color to a palette index, and then convert it to its encore variant and then back to a color code. - // do this for both the start and fade colormaps. - - color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); - color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); - color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); - -#ifdef GLENCORE - if (encoremap) - { - j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)]; - //CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); -- moved encoremap upwards for optimisation - color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below - } -#endif - color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly - sec->extra_colormap->rgba = color.rgba; - - // alpha - if (msd->toptexture[7]) - sec->extra_colormap->rgba += (ALPHA2INT(col[7]) << 24); - else - sec->extra_colormap->rgba += (25 << 24); - - /*nearest = NearestColor( - (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0), - (HEX2INT(col[3]) << 4) + (HEX2INT(col[4]) << 0), - (HEX2INT(col[5]) << 4) + (HEX2INT(col[6]) << 0) - ); - - sec->extra_colormap->rgba = - pLocalPalette[nearest].s.red + - (pLocalPalette[nearest].s.green << 8) + - (pLocalPalette[nearest].s.blue << 16);*/ - } - else - sec->extra_colormap->rgba = 0; - - if (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) - { - col = msd->bottomtexture; - - // do the exact same thing as above here. - - color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); - color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); - color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); - -#ifdef GLENCORE - if (encoremap) - { - j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)]; - //CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); -- moved encoremap upwards for optimisation - color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below - } -#endif - color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly - sec->extra_colormap->fadergba = color.rgba; - - // alpha - if (msd->bottomtexture[7]) - sec->extra_colormap->fadergba += (ALPHA2INT(col[7]) << 24); - else - sec->extra_colormap->fadergba += (25 << 24); - } - else - sec->extra_colormap->fadergba = 0x19000000; // default alpha, (25 << 24) -#undef ALPHA2INT -#undef HEX2INT - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } - break; - } -#endif - + P_LoadSideColormaps(msd, sd, sec); + break; case 413: // Change music - { - char process[8+1]; - - sd->toptexture = sd->midtexture = sd->bottomtexture = 0; - if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') - { - M_Memcpy(process,msd->bottomtexture,8); - process[8] = '\0'; - sd->bottomtexture = get_number(process); - } - - if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0') - { - M_Memcpy(process,msd->midtexture,8); - process[8] = '\0'; - sd->midtexture = get_number(process); - } - - // always process if back sidedef, because we need that - symbol - sd->text = Z_Malloc(7, PU_LEVEL, NULL); - if (i == 1 || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') - { - M_Memcpy(process,msd->toptexture,8); - process[8] = '\0'; - - // If they type in O_ or D_ and their music name, just shrug, - // then copy the rest instead. - if ((process[0] == 'O' || process[0] == 'D') && process[7]) - M_Memcpy(sd->text, process+2, 6); - else // Assume it's a proper music name. - M_Memcpy(sd->text, process, 6); - sd->text[6] = 0; - } - else - sd->text[0] = 0; + P_LoadSideChangeMusic((i == 1), msd, sd); break; - } - case 4: // Speed pad parameters case 414: // Play SFX { @@ -1581,7 +1577,6 @@ static void P_LoadRawSideDefs2(void *data) } break; } - case 9: // Mace parameters case 14: // Bustable block parameters case 15: // Fan particle spawner parameters @@ -1601,9 +1596,9 @@ static void P_LoadRawSideDefs2(void *data) if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') M_Memcpy(process+strlen(process), msd->bottomtexture, 8); sd->toptexture = get_number(process); + break; } - case 443: // Calls a named Lua function { char process[8*3+1]; @@ -1619,9 +1614,9 @@ static void P_LoadRawSideDefs2(void *data) M_Memcpy(process+strlen(process), msd->bottomtexture, 8); sd->text = Z_Malloc(strlen(process)+1, PU_LEVEL, NULL); M_Memcpy(sd->text, process, strlen(process)+1); + break; } - default: // normal cases if (msd->toptexture[0] == '#') { @@ -1641,6 +1636,7 @@ static void P_LoadRawSideDefs2(void *data) break; } } + R_ClearTextureNumCache(true); } @@ -2317,6 +2313,7 @@ static void P_LevelInitStuff(boolean reloadinggamestate) gamespeed = 0; else gamespeed = (UINT8)cv_kartspeed.value; + franticitems = (boolean)cv_kartfrantic.value; comeback = (boolean)cv_kartcomeback.value; } @@ -2325,43 +2322,6 @@ static void P_LevelInitStuff(boolean reloadinggamestate) battlewanted[i] = -1; } -// -// P_LoadThingsOnly -// -// "Reloads" a level, but only reloads all of the mobjs. -// -void P_LoadThingsOnly(void) -{ - // Search through all the thinkers. - mobj_t *mo; - thinker_t *think; - - virtres_t* virt = vres_GetMap(lastloadedmaplumpnum); - virtlump_t* vth = vres_Find(virt, "THINGS"); - - for (think = thinkercap.next; think != &thinkercap; think = think->next) - { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker - - mo = (mobj_t *)think; - - if (mo) - P_RemoveMobj(mo); - } - - P_LevelInitStuff(false); - - memset(localaiming, 0, sizeof(localaiming)); - - P_PrepareRawThings(vth->data); - P_LoadThings(); - - vres_Free(virt); - - P_SpawnSecretItems(true); -} - /** Compute MD5 message digest for bytes read from memory source * * The resulting message digest number will be written into the 16 bytes @@ -2672,11 +2632,6 @@ static void P_InitCamera(void) displayplayers[0] = consoleplayer; // Start with your OWN view, please! } -static boolean P_CanSave(void) -{ - return false; // SRB2Kart: no SP, no saving. -} - struct minimapinfo minimapinfo; static void P_InitMinimapInfo(void) { @@ -2824,13 +2779,7 @@ static void P_SetupPlayer(void) else // gametype is GT_COOP or GT_RACE { players[i].mo = NULL; - - if (players[i].starposttime) - { - G_SpawnPlayer(i, true); - } - else - G_SpawnPlayer(i, false); + G_SpawnPlayer(i, (players[i].starposttime)); } } } @@ -3169,9 +3118,6 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) P_RunCachedActions(); - if (P_CanSave()) - G_SaveGame((UINT32)cursaveslot); - if (savedata.lives > 0) { players[consoleplayer].continues = savedata.continues; @@ -3276,7 +3222,8 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), wadfilename); return UINT16_MAX; } - else wadnum = (UINT16)(numwadfiles-1); + + wadnum = (UINT16)(numwadfiles-1); if (wadfiles[wadnum]->important) partadd_important = true; diff --git a/src/p_setup.h b/src/p_setup.h index f0ae13e6c..47a9ea85b 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -60,8 +60,8 @@ extern size_t nummapthings; extern mapthing_t *mapthings; void P_SetupLevelSky(INT32 skynum, boolean global); -void P_LoadThingsOnly(void); boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate); + #ifdef HWRENDER void HWR_LoadLevel(void); #endif From e138d540c84efe7b562d2d800c6d7489dcda8760 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 28 Apr 2025 11:21:24 +0200 Subject: [PATCH 31/35] skip rechecking for horizonlines when reloading gamestate map remains the same during desynch, so safe some time --- src/hardware/hw_main.c | 5 +++-- src/p_setup.c | 5 ++--- src/p_setup.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 096e738c6..76313eb6d 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5690,7 +5690,7 @@ static void HWR_CheckForHorizonLines(void) } } -void HWR_LoadLevel(void) +void HWR_LoadLevel(boolean reloadinggamestate) { // Lactozilla (December 8, 2019) // Level setup used to free EVERY mipmap from memory. @@ -5709,7 +5709,8 @@ void HWR_LoadLevel(void) HWR_ClearSkyDome(); HWR_BuildSkyDome(); - HWR_CheckForHorizonLines(); + if (!reloadinggamestate) + HWR_CheckForHorizonLines(); if (HWR_ShouldUsePaletteRendering()) HWR_SetMapPalette(); diff --git a/src/p_setup.c b/src/p_setup.c index 973d37f82..399276474 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3073,9 +3073,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) if (rendermode == render_opengl) { HWR_FreeExtraSubsectors(); - - // stuff like HWR_CreatePlanePolygons is called there - HWR_LoadLevel(); + // Create plane polygons. + HWR_LoadLevel(reloadinggamestate); } #endif diff --git a/src/p_setup.h b/src/p_setup.h index 47a9ea85b..97209e154 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -63,7 +63,7 @@ void P_SetupLevelSky(INT32 skynum, boolean global); boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate); #ifdef HWRENDER -void HWR_LoadLevel(void); +void HWR_LoadLevel(boolean reloadinggamestate); #endif boolean P_AddWadFile(const char *wadfilename, boolean local); From 984d501ee1ab5429ea288b0b96671fb9fad90461 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 28 Apr 2025 11:29:35 +0200 Subject: [PATCH 32/35] move doaddline block slightly better branching since maps with portals are very uncommon in kart --- src/hardware/hw_main.c | 59 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 76313eb6d..c485b5a77 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2357,7 +2357,35 @@ static void HWR_AddLine(seg_t *line) gl_backsector = line->backsector; if (!cv_glportals.value || LIKELY(!gl_maphasportals)) - goto doaddline; + { +doaddline: + if (!line->backsector) + { + gld_clipper_SafeAddClipRange(angle2, angle1); + } + else + { + gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); + + if (CheckClip(gl_frontsector, gl_backsector)) + { + gld_clipper_SafeAddClipRange(angle2, angle1); + checkforemptylines = false; + } + + // Reject empty lines used for triggers and special events. + // Identical floor and ceiling on both sides, + // identical light levels on both sides, + // and no middle texture. + if (checkforemptylines && R_IsEmptyLine(line, gl_frontsector, gl_backsector)) + return; + } + + if (LIKELY(gl_portal_state != GLPORTAL_SEARCH && !dont_draw))// no need to do this during the portal check + HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D + + return; + } // do extra checks on the seg when rendering portals: // don't render segs that are behind the portal destination line @@ -2393,34 +2421,7 @@ static void HWR_AddLine(seg_t *line) return;// dont do anything with the other side i guess? } -doaddline: - - if (!line->backsector) - { - gld_clipper_SafeAddClipRange(angle2, angle1); - } - else - { - gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); - - if (CheckClip(gl_frontsector, gl_backsector)) - { - gld_clipper_SafeAddClipRange(angle2, angle1); - checkforemptylines = false; - } - - // Reject empty lines used for triggers and special events. - // Identical floor and ceiling on both sides, - // identical light levels on both sides, - // and no middle texture. - if (checkforemptylines && R_IsEmptyLine(line, gl_frontsector, gl_backsector)) - return; - } - - if (LIKELY(gl_portal_state != GLPORTAL_SEARCH && !dont_draw))// no need to do this during the portal check - HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D - - return; + goto doaddline; } // HWR_CheckBBox From 4c1cfc91daeafccd2d8200dc261a3f5cb86eae96 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 28 Apr 2025 13:25:30 +0100 Subject: [PATCH 33/35] quick and dirty gcc 15 compile fix need to fix this properly --- src/dehacked.c | 4 ++++ src/info.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index fd90c380e..1a84108fd 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1414,6 +1414,9 @@ static void readhuditem(MYFILE *f, INT32 num) // IMPORTANT! // DO NOT FORGET TO SYNC THIS LIST WITH THE ACTIONNUM ENUM IN INFO.H + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wincompatible-pointer-types" actionpointer_t actionpointers[] = { {{A_Explode}, "A_EXPLODE"}, @@ -1622,6 +1625,7 @@ actionpointer_t actionpointers[] = // This NULL entry must be the last in the list {{NULL}, NULL}, }; +#pragma GCC diagnostic pop static void readframe(MYFILE *f, INT32 num) { diff --git a/src/info.c b/src/info.c index 7afc76bf6..19183de52 100644 --- a/src/info.c +++ b/src/info.c @@ -69,6 +69,8 @@ char sprnames[NUMSPRITES + 1][5] = }; // Doesn't work with g++, needs actionf_p1 (don't modify this comment) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wincompatible-pointer-types" state_t states[NUMSTATES] = { // frame is masked through FF_FRAMEMASK @@ -3410,6 +3412,7 @@ state_t states[NUMSTATES] = {SPR_NULL, 0, 1, {NULL}, 0, 0, S_NULL}, // S_NAMECHECK #endif }; +#pragma GCC diagnostic pop mobjinfo_t mobjinfo[NUMMOBJTYPES] = { From 7ba21abacd37bb86a7abac7cbf54016b323af3a9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 28 Apr 2025 17:47:22 +0200 Subject: [PATCH 34/35] tiny more cleanup speedometer stuffs put check for color speedo into a function and precalc the xtra 3 scale --- src/k_kart.c | 59 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 1e2190c2f..222890332 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -230,6 +230,8 @@ static boolean K_SpeedLinesShouldBlend(player_t *player); // mapreset is set when enough players fill an empty server // nospectategrief is the players in-game needed to eliminate the person in last +#define XTRA3PSCALE 50135 //0.765 +#define XTRA3VSCALE 35344 //0.55 //{ SRB2kart Color Code @@ -774,6 +776,26 @@ static UINT8 K_GetSpeedometerStyle(void) return SPEEDO_VANILLA; } +static boolean K_UseColorSpeedo(int speedostyle) +{ + if (!K_UseColorHud()) + return false; + + switch (speedostyle) + { + case SPEEDO_EXTRA: + return xtra_speedo_clr; + case SPEEDO_ACHII: + return achi_speedo_clr; + case SPEEDO_DIAL: + return dial_speedo_clr; + case SPEEDO_EXTRA3: + return xtra_speedo_clr3; + default: + return false; + } +} + static boolean K_IsHighResolution(void) { return (vid.width >= 640 && vid.height >= 400); @@ -9739,33 +9761,33 @@ static void K_drawKartSpeedometer(void) } else if (speedostyle == SPEEDO_EXTRA) // why bother if we dont? { - if (K_UseColorHud() && xtra_speedo_clr) //Colourized hud + if (K_UseColorSpeedo(SPEEDO_EXTRA)) //Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallstickerclr), colormap); + V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerclr, colormap); } else - V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallsticker)); + V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallsticker); V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatches[cv_kartspeedometer.value]); } else if (speedostyle == SPEEDO_ACHII) // why bother if we dont? { - if (K_UseColorHud() && achi_speedo_clr) //Colourized hud + if (K_UseColorSpeedo(SPEEDO_ACHII)) //Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallstickerachiclr), colormap); + V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerachiclr, colormap); V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); V_DrawMappedPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachiclr[cv_kartspeedometer.value], colormap); } else { - V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallstickerachi)); + V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerachi); V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachi[cv_kartspeedometer.value]); } - } + } #ifdef ROTSPRITE else if (speedostyle == SPEEDO_DIAL) // why bother if we dont? { @@ -9774,18 +9796,18 @@ static void K_drawKartSpeedometer(void) splitflags, (boolean)(G_BattleGametype()), (LUA_HudEnabled(hud_gametypeinfo)), - (boolean)(K_UseColorHud() && dial_speedo_clr)); + (K_UseColorSpeedo(SPEEDO_DIAL))); } #endif else if (speedostyle == SPEEDO_EXTRA3) // why bother if we dont? { - if (K_UseColorHud() && xtra_speedo_clr3) //Colourized hud + if (K_UseColorSpeedo(SPEEDO_EXTRA3)) //Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((SPDM_X-1)< 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && !(leveltime & 4)) spdpatch = 23; - patch_t *patch = NULL; - - if (speedostyle == SPEEDO_PMETER) - patch = kp_kartzspeedo[spdpatch]; - else if (speedostyle == SPEEDO_PMETERSMOL) - patch = kp_kartzspeedo_smol[spdpatch]; - - V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, patch); + V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, (speedostyle == SPEEDO_PMETER) ? kp_kartzspeedo[spdpatch] : kp_kartzspeedo_smol[spdpatch]); } } @@ -10346,13 +10361,13 @@ skipcrap: if (usescaledpatch) // i hate hud code i hate hud code i hate hud code i hate hud code i hate hud code..... { - if (K_UseColorHud() && xtra_speedo_clr3) // Colourized hud + if (K_UseColorSpeedo(SPEEDO_EXTRA3)) // Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((basex - dup*30)< Date: Mon, 28 Apr 2025 22:19:59 +0200 Subject: [PATCH 35/35] Reapply "disable jit compilation for now" This reverts commit a662a0a68f52ddbf8851356353570ac93fdb2f9e. --- src/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Makefile b/src/Makefile index 4c3240dd1..5754a3724 100644 --- a/src/Makefile +++ b/src/Makefile @@ -93,7 +93,10 @@ ifeq ($(OS),Windows_NT) # all windows are Windows_NT... WINDOWSHELL=1 NOOBJDUMP=1 + NOBLUAJIT=1 + else # if you on the *nix + NOBLUAJIT=1 system:=$(shell uname -s) ifeq ($(system),Linux)