From c50c936b1f51b60f778bc2bb4ac43c4056c760b1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 30 Nov 2025 20:28:35 +0100 Subject: [PATCH 1/6] remove hwr_shutdown call honestly this didnt help with the issue i had, game should already release all the memory on quit anyways. this just makes it take longer to quit --- src/sdl/i_video.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 1aba4f109..c2d87e3f1 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1997,16 +1997,11 @@ void I_ShutdownGraphics(void) graphics_started = false; I_OutputMsg("shut down\n"); - #ifdef HWRENDER - if (vid.glstate == VID_GL_LIBRARY_LOADED) - HWR_Shutdown(); - if (sdlglcontext) SDL_GL_DeleteContext(sdlglcontext); sdlglcontext = NULL; #endif - if (texture) SDL_DestroyTexture(texture); texture = NULL; From bceda5beb407418664f8fd3e97e5f38705f73e5f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 1 Dec 2025 18:02:59 +0100 Subject: [PATCH 2/6] dont force awayview when in freecam --- src/r_main.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index af5e821b2..e055a7e09 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -567,6 +567,7 @@ static void R_InitTextureMapping(void) else if (t > viewwidth+1) t = viewwidth+1; } + viewangletox[i] = t; } @@ -1109,7 +1110,8 @@ static void R_SetupCommonFrame(player_t * player) static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) { - if (player->awayviewtics && player->awayviewmobj) + if (player->awayviewtics && player->awayviewmobj + && thiscam && !thiscam->freecam) // dont force this if we wanna freecam! { newview->aim = player->awayviewaiming; newview->angle = player->awayviewmobj->angle; @@ -1276,9 +1278,10 @@ void R_SetupFrame(UINT8 pnum, boolean skybox) R_SetupAimingFrame(player, thiscam); - if (player->awayviewtics && player->awayviewmobj) // cut-away view stuff + if (player->awayviewtics && player->awayviewmobj // cut-away view stuff + && thiscam && !thiscam->freecam) // dont force this when we wanna freecam! { - viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN + viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN whos altview man? I_Assert(viewmobj != NULL); newview->x = viewmobj->x; @@ -1337,7 +1340,7 @@ static void R_PortalFrame(portal_t *portal) } } -static void Mask_Pre (maskcount_t* m) +static void Mask_Pre(maskcount_t* m) { m->drawsegs[0] = ds_p - drawsegs; m->vissprites[0] = visspritecount; @@ -1347,7 +1350,7 @@ static void Mask_Pre (maskcount_t* m) m->viewsector = viewsector; } -static void Mask_Post (maskcount_t* m) +static void Mask_Post(maskcount_t* m) { m->drawsegs[1] = ds_p - drawsegs; m->vissprites[1] = visspritecount; @@ -1429,6 +1432,7 @@ void R_RenderPlayerView(player_t *player) // Clear buffers. R_ClearPlanes(); + if (viewmorph.use) { portalclipstart = viewmorph.x1; From 10c117f95fc681b0d369e12114455144526d9b23 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 1 Dec 2025 18:11:28 +0100 Subject: [PATCH 3/6] dont reset freecam if the player you are "supposed to be watching" specs in replays this aint pretty, but im too lazy to make it pretty sincerly --- src/g_demo.c | 36 +++++++++++++++++++----------------- src/g_game.c | 15 +++++++++++---- src/g_game.h | 2 +- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 7fff0e928..671db3844 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -246,10 +246,12 @@ void G_ReadDemoExtraData(void) { extradata = READUINT8(demobuf.p); + player_t *player = &players[p]; + if (extradata & DXD_RESPAWN) { - if (players[p].mo) - P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL); // Is this how this should work..? + if (player->mo) + P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL); // Is this how this should work..? } if (extradata & DXD_SKIN) @@ -264,11 +266,11 @@ void G_ReadDemoExtraData(void) kartspeed = READUINT8(demobuf.p); kartweight = READUINT8(demobuf.p); - if (!fasticmp(skins[players[p].skin].name, name)) + if (!fasticmp(skins[player->skin].name, name)) FindClosestSkinForStats(p, kartspeed, kartweight); - players[p].kartspeed = kartspeed; - players[p].kartweight = kartweight; + player->kartspeed = kartspeed; + player->kartweight = kartweight; } if (extradata & DXD_COLOR) @@ -279,9 +281,9 @@ void G_ReadDemoExtraData(void) for (i = 0; i < MAXSKINCOLORS; i++) if (fasticmp(KartColor_Names[i], name)) // SRB2kart { - players[p].skincolor = i; - if (players[p].mo) - players[p].mo->color = i; + player->skincolor = i; + if (player->mo) + player->mo->color = i; break; } } @@ -300,17 +302,17 @@ void G_ReadDemoExtraData(void) switch (extradata) { case DXD_PST_PLAYING: - players[p].pflags |= PF_WANTSTOJOIN; // fuck you + player->pflags |= PF_WANTSTOJOIN; // fuck you break; case DXD_PST_SPECTATING: - players[p].pflags &= ~PF_WANTSTOJOIN; // double-fuck you + player->pflags &= ~PF_WANTSTOJOIN; // double-fuck you if (!playeringame[p]) { CL_ClearPlayer(p); playeringame[p] = true; G_AddPlayer(p); - players[p].spectator = true; + player->spectator = true; // There's likely an off-by-one error in timing recording or playback of joins. This hacks around it so I don't have to find out where that is. \o/ if (oldcmd[p].forwardmove) @@ -318,11 +320,11 @@ void G_ReadDemoExtraData(void) } else { - players[p].spectator = true; - if (players[p].mo) - P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL); + player->spectator = true; + if (player->mo) + P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL); else - players[p].playerstate = PST_REBORN; + player->playerstate = PST_REBORN; } break; case DXD_PST_LEFT: @@ -330,7 +332,7 @@ void G_ReadDemoExtraData(void) break; } - G_ResetViews(); + G_ResetViews(false); // dont reset our freecam pls thx! // maybe these are necessary? if (G_BattleGametype()) @@ -1593,7 +1595,7 @@ void G_ConfirmRewind(tic_t rewindtime) displayplayers[2] = olddp3; displayplayers[3] = olddp4; R_ExecuteSetViewSize(); - G_ResetViews(); + G_ResetViews(true); for (i = splitscreen; i >= 0; i--) P_ResetCamera(&players[displayplayers[i]], &camera[i]); diff --git a/src/g_game.c b/src/g_game.c index 8960fc055..b479b61f8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1750,14 +1750,15 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) // Increment a viewpoint by offset from the current player. A negative value // decrements. // -void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive) +static void G_ActuallyAdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive, boolean resetfreecam) { INT32 *displayplayerp, oldview; displayplayerp = &displayplayers[viewnum-1]; oldview = (*displayplayerp); // turn off the freecam - camera[viewnum-1].freecam = false; + if (resetfreecam) + camera[viewnum-1].freecam = false; G_ResetView(viewnum, ( (*displayplayerp) + offset ), onlyactive); @@ -1766,12 +1767,18 @@ void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive) (*displayplayerp) = oldview; } +// im a lazy ass :chonkbuncle: +void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive) +{ + G_ActuallyAdjustView(viewnum, offset, onlyactive, true); +} + // // G_ResetViews // Ensures all viewpoints are valid // Also demotes splitscreen down to one player. // -void G_ResetViews(void) +void G_ResetViews(boolean resetfreecam) { UINT8 splits; UINT8 viewd; @@ -1795,7 +1802,7 @@ void G_ResetViews(void) */ for (viewd = 1; viewd <= splits; ++viewd) { - G_AdjustView(viewd, 0, false); + G_ActuallyAdjustView(viewd, 0, false, resetfreecam); } } diff --git a/src/g_game.h b/src/g_game.h index c16d02d4a..a8e2b5135 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -262,7 +262,7 @@ boolean G_CanView(INT32 playernum, UINT8 viewnum, boolean onlyactive); INT32 G_FindView(INT32 startview, UINT8 viewnum, boolean onlyactive, boolean reverse); INT32 G_CountPlayersPotentiallyViewable(boolean active); -void G_ResetViews(void); +void G_ResetViews(boolean resetfreecam); void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive); void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive); From fba070f82eb2f83ba27d1aff7ba6667f0e6fefa3 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 1 Dec 2025 21:08:14 +0300 Subject: [PATCH 4/6] Expose cameras to lua outside of hud hooks --- src/lua_hudlib.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 251a1013c..676f0b394 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -149,7 +149,8 @@ enum cameraf { camera_momx, camera_momy, camera_momz, - camera_pnum + camera_pnum, + camera_freecam, }; @@ -169,6 +170,7 @@ static const char *const camera_opt[] = { "momy", "momz", "pnum", + "freecam", NULL}; enum hudpatch { @@ -387,10 +389,43 @@ static int camera_get(lua_State *L) case camera_pnum: lua_pushinteger(L, camnum); break; + case camera_freecam: + lua_pushboolean(L, cam->freecam); + break; } return 1; } +static int lib_getCamera(lua_State *L) +{ + // No cameras on dedicated + if (dedicated) + return 0; + + if (lua_type(L, 2) == LUA_TNUMBER) + { + int i = lua_tonumber(L, 2); + + if (i < 0 || i > splitscreen) + return 0; + + LUA_PushUserdata(L, &camera[i], META_CAMERA); + return 1; + } + + return 0; +} + +static int lib_lenCamera(lua_State *L) +{ + if (dedicated) + lua_pushinteger(L, 0); + else + lua_pushinteger(L, splitscreen+1); // splitscreen == 0 -> 1 active camera, splitscreen == 1 -> 2 cameras and so on + + return 1; +} + // // lib_draw // @@ -1371,6 +1406,16 @@ int LUA_HudLib(lua_State *L) lua_setfield(L, -2, "__index"); lua_pop(L,1); + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, lib_getCamera); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_lenCamera); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "cameras"); + camera_fields_ref = Lua_CreateFieldTable(L, camera_opt); luaL_register(L, "hud", lib_hud); From a6a97b4c4f47951f677f03f70c839a09564dd827 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 1 Dec 2025 20:19:03 +0100 Subject: [PATCH 5/6] add gdb_history to gitignore --- src/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/src/.gitignore b/src/.gitignore index 156f6f65f..b1b48e2a2 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,3 +1,4 @@ /cscope.out *.json *.idx +*.gdb_history From c4898417326c6dbd7e2734541760d8cdda6410d3 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 1 Dec 2025 20:17:43 +0100 Subject: [PATCH 6/6] Fix record attack ghosts sometimes crashing due to ghosts occasionally ending to early and game interpreting them as still valid uhhhhh lets pray this wont explode or cause any weird issues...... credits to RR REVERT THIS ONCE I GO AND FIXUP THE REPLAY MESS --- src/g_demo.c | 76 +++++++++++++++++++++++++++++++++++----------------- src/g_demo.h | 1 + 2 files changed, 53 insertions(+), 24 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 671db3844..51f7dc334 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1134,7 +1134,29 @@ void G_GhostTicker(void) for (g = ghosts, p = NULL; g; g = g->next) { // Skip normal demo data. - UINT8 ziptic = READUINT8(g->p); + UINT8 ziptic; + + if (g->done) + { + continue; + } + + ziptic = READUINT8(g->p); + +fadeghost: + // Demo ends after ghost data. + if (ziptic == DEMOMARKER) + { + g->mo->momx = g->mo->momy = g->mo->momz = 0; + + g->done = true; + if (p) + { + p->next = g->next; + } + + continue; + } #ifdef DEMO_COMPAT_100 if (g->version != 0x0001) @@ -1142,8 +1164,14 @@ void G_GhostTicker(void) #endif while (ziptic != DW_END) // Get rid of extradata stuff { - if (ziptic == 0) // Only support player 0 info for now + if (ziptic < MAXPLAYERS) { +#ifdef DEVELOP + UINT8 playerid = ziptic; +#endif + // We want to skip *any* player extradata because some demos have extradata for bogus players, + // but if there is tic data later for those players *then* we'll consider it invalid. + ziptic = READUINT8(g->p); if (ziptic & DXD_SKIN) @@ -1155,13 +1183,26 @@ void G_GhostTicker(void) if (ziptic & DXD_NAME) g->p += 16; // yea - if (ziptic & DXD_PLAYSTATE && READUINT8(g->p) != DXD_PST_PLAYING) - I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this + if (ziptic & DXD_PLAYSTATE) + { + UINT8 playstate = READUINT8(g->p); + if (playstate != DXD_PST_PLAYING) + { +#ifdef DEVELOP + CONS_Alert(CONS_WARNING, "Ghost demo has non-playing playstate for player %d\n", playerid + 1); +#endif + ; + } + } } else if (ziptic == DW_RNG) + { g->p += 4; // RNG seed + } else - I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this + { + I_Error("Ghost is not a record attack ghost DXD (ziptic = %u)", ziptic); //@TODO lmao don't blow up like this + } ziptic = READUINT8(g->p); } @@ -1184,7 +1225,7 @@ void G_GhostTicker(void) if (ziptic & ZT_DRIFT) g->p += 2; if (ziptic & ZT_LATENCY) - g->p += 1; + g->p++; // Grab ghost data. ziptic = READUINT8(g->p); @@ -1193,10 +1234,12 @@ void G_GhostTicker(void) if (g->version != 0x0001) { #endif + if (ziptic == DEMOMARKER) // Had to end early for some reason + goto fadeghost; if (ziptic == 0xFF) goto skippedghosttic; // Didn't write ghost info this frame - else if (ziptic != 0) - I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this + if (ziptic != 0) + I_Error("Ghost is not a record attack ghost ZIPTIC"); //@TODO lmao don't blow up like this ziptic = READUINT8(g->p); #ifdef DEMO_COMPAT_100 } @@ -1367,7 +1410,7 @@ void G_GhostTicker(void) { #endif if (READUINT8(g->p) != 0xFF) // Make sure there isn't other ghost data here. - I_Error("Ghost is not a record attack ghost"); //@TODO lmao don't blow up like this + I_Error("Ghost is not a record attack ghost GHOSTEND"); //@TODO lmao don't blow up like this #ifdef DEMO_COMPAT_100 } #endif @@ -1387,20 +1430,6 @@ skippedghosttic: break; } - // Demo ends after ghost data. - if (*g->p == DEMOMARKER) - { - g->mo->momx = g->mo->momy = g->mo->momz = 0; - - if (p) - p->next = g->next; - else - ghosts = g->next; - - Z_Free(g); - continue; - } - p = g; } } @@ -3534,7 +3563,6 @@ void G_FreeGhosts(void) ghosts = NULL; } - boolean G_CheckDemoStatus(void) { G_FreeGhosts(); diff --git a/src/g_demo.h b/src/g_demo.h index 3ce32c054..5e430a2e8 100644 --- a/src/g_demo.h +++ b/src/g_demo.h @@ -149,6 +149,7 @@ typedef struct demoghost { UINT8 checksum[16]; UINT8 *buffer, *p, color; UINT16 version; + boolean done; mobj_t oldmo, *mo; struct demoghost *next; } demoghost;