From efb29e6be5d58e44a6c99c72833b1cfe33747906 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 2 Dec 2025 12:42:22 +0100 Subject: [PATCH 001/589] d_cliserv: do some cleanups - expose SAVEGAMESIZE - pass node number to SV_AddWaitingPlayers (saves iterating through all 128 net nodes everytime a player joins) lifted from RR - move all packet handling to the packet handlers - Reorder packethandling switches a little, so common/important packets get checked first - fix wrong clamp for realfirsttic that was too early - add nowtime division by NEWTICRATERATIO (no change unless ticrate changes) --- src/d_clisrv.c | 427 ++++++++++++++++++++++++------------------------- src/d_clisrv.h | 4 +- src/g_game.c | 5 +- 3 files changed, 215 insertions(+), 221 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index fa1536e72..33b69045e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1933,8 +1933,6 @@ static boolean SV_SendServerConfig(INT32 node) return waspacketsent; } -#define SAVEGAMESIZE (768*1024) - #ifdef SATURNPAK static boolean SV_ResendingSavegameToAnyone(void) { @@ -4565,71 +4563,69 @@ static void Got_RemovePlayer(const UINT8 **p, INT32 playernum) #endif } -static boolean SV_AddWaitingPlayers(void) +static boolean SV_AddWaitingPlayers(SINT8 node) { - INT32 node, n, newplayer = false; + INT32 n; UINT8 buf[2]; UINT8 newplayernum = 0; + boolean newplayer = false; // What is the reason for this? Why can't newplayernum always be 0? // Sal: Because the dedicated player is stupidly forced into players[0]..... if (dedicated) newplayernum = 1; - for (node = 0; node < MAXNETNODES; node++) + // splitscreen can allow 2+ players in one node + for (; nodewaiting[node] > 0; nodewaiting[node]--) { - // splitscreen can allow 2+ players in one node - for (; nodewaiting[node] > 0; nodewaiting[node]--) + newplayer = true; + + // search for a free playernum + // we can't use playeringame since it is not updated here + for (; newplayernum < MAXPLAYERS; newplayernum++) { - newplayer = true; - - // search for a free playernum - // we can't use playeringame since it is not updated here - for (; newplayernum < MAXPLAYERS; newplayernum++) - { - for (n = 0; n < MAXNETNODES; n++) - if (nodetoplayer[n] == newplayernum || nodetoplayer2[n] == newplayernum - || nodetoplayer3[n] == newplayernum || nodetoplayer4[n] == newplayernum) - break; - if (n == MAXNETNODES) + for (n = 0; n < MAXNETNODES; n++) + if (nodetoplayer[n] == newplayernum || nodetoplayer2[n] == newplayernum + || nodetoplayer3[n] == newplayernum || nodetoplayer4[n] == newplayernum) break; - } - - // should never happen since we check the playernum - // before accepting the join - I_Assert(newplayernum < MAXPLAYERS); - - playernode[newplayernum] = (UINT8)node; - - buf[0] = (UINT8)node; - buf[1] = newplayernum; - if (playerpernode[node] < 1) - { - nodetoplayer[node] = newplayernum; - } - else if (playerpernode[node] < 2) - { - nodetoplayer2[node] = newplayernum; - buf[1] += MAXPLAYERS; - } - else if (playerpernode[node] < 3) - { - nodetoplayer3[node] = newplayernum; - buf[1] += MAXPLAYERS*2; - } - else - { - nodetoplayer4[node] = newplayernum; - buf[1] += MAXPLAYERS*3; - } - playerpernode[node]++; - - SendNetXCmd(XD_ADDPLAYER, &buf, 2); - - DEBFILE(va("Server added player %d node %d\n", newplayernum, node)); - // use the next free slot (we can't put playeringame[newplayernum] = true here) - newplayernum++; + if (n == MAXNETNODES) + break; } + + // should never happen since we check the playernum + // before accepting the join + I_Assert(newplayernum < MAXPLAYERS); + + playernode[newplayernum] = (UINT8)node; + + buf[0] = (UINT8)node; + buf[1] = newplayernum; + if (playerpernode[node] < 1) + { + nodetoplayer[node] = newplayernum; + } + else if (playerpernode[node] < 2) + { + nodetoplayer2[node] = newplayernum; + buf[1] += MAXPLAYERS; + } + else if (playerpernode[node] < 3) + { + nodetoplayer3[node] = newplayernum; + buf[1] += MAXPLAYERS*2; + } + else + { + nodetoplayer4[node] = newplayernum; + buf[1] += MAXPLAYERS*3; + } + playerpernode[node]++; + + SendNetXCmd(XD_ADDPLAYER, &buf, 2); + + DEBFILE(va("Server added player %d node %d\n", newplayernum, node)); + // use the next free slot (we can't put playeringame[newplayernum] = true here) + newplayernum++; } return newplayer; @@ -4666,6 +4662,8 @@ boolean Playing(void) boolean SV_SpawnServer(void) { + boolean result = false; + if (demo.playback) G_StopDemo(); // reset engine parameter @@ -4686,7 +4684,15 @@ boolean SV_SpawnServer(void) else doomcom->numslots = 1; } - return SV_AddWaitingPlayers(); + // strictly speaking, i'm not convinced the following is necessary + // but I'm not confident enough to remove it entirely in case it breaks something + { + SINT8 node = 0; + for (; node < MAXNETNODES; node++) + result |= SV_AddWaitingPlayers(node); + } + + return result; } void SV_StopServer(void) @@ -4772,8 +4778,12 @@ static size_t TotalTextCmdPerTic(tic_t tic) * \param node The packet sender * */ -static void HandleConnect(SINT8 node) +static void PT_ClientJoin(SINT8 node) { + // Ignore duplicate packets + if (client || nodeingame[node]|| levelloading) + return; + doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); // Sal: Dedicated mode is INCREDIBLY hacked together. @@ -4783,8 +4793,17 @@ static void HandleConnect(SINT8 node) UINT8 connectedplayers = 0; for (UINT8 i = dedicated ? 1 : 0; i < MAXPLAYERS; i++) - if (playernode[i] != UINT8_MAX) // We use this to count players because it is affected by SV_AddWaitingPlayers when more than one client joins on the same tic, unlike playeringame and D_NumPlayers. UINT8_MAX denotes no node for that player + { + // We use this to count players because it is affected by SV_AddWaitingPlayers when + // more than one client joins on the same tic, unlike playeringame and D_NumPlayers. + // UINT8_MAX denotes no node for that player. + + if (playernode[i] != UINT8_MAX) + { connectedplayers++; + } + } + #ifdef SATURNJOIN const boolean issaturn = (((doomcom->datalength) == sizeof(clientconfig_pak)) && netbuffer->u.clientcfg.issaturn == ISSATURN); // Check the packet lenght to skip potential garbo data! @@ -4840,7 +4859,7 @@ static void HandleConnect(SINT8 node) else if (netbuffer->u.clientcfg.version != VERSION || netbuffer->u.clientcfg.subversion != SUBVERSION) { - SV_SendRefuse(node, va(M_GetText("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)"), VERSION, SUBVERSION)); + SV_SendRefuse(node, va("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)", VERSION, SUBVERSION)); } #ifdef SATURNJOIN else if (((!cv_allownewplayer.value && !issaturn) || (!cv_allownewsaturnplayer.value && issaturn)) && node) @@ -4848,71 +4867,61 @@ static void HandleConnect(SINT8 node) else if (!cv_allownewplayer.value && node) #endif { - SV_SendRefuse(node, M_GetText(cv_joinrefusemessage.string)); + SV_SendRefuse(node, cv_joinrefusemessage.string); } else if (connectedplayers >= maxplayers) { - SV_SendRefuse(node, va(M_GetText("Maximum players reached: %d"), maxplayers)); + SV_SendRefuse(node, va("Maximum players reached: %d", maxplayers)); } else if (netgame && netbuffer->u.clientcfg.localplayers > 4) // Hacked client? { - SV_SendRefuse(node, M_GetText("Too many players from\nthis node.")); + SV_SendRefuse(node, "Too many players from\nthis node."); } else if (netgame && connectedplayers + netbuffer->u.clientcfg.localplayers > maxplayers) { - SV_SendRefuse(node, va(M_GetText("Number of local players\nwould exceed maximum: %d"), maxplayers)); + SV_SendRefuse(node, va("Number of local players\nwould exceed maximum: %d", maxplayers)); } else if (netgame && !netbuffer->u.clientcfg.localplayers) // Stealth join? { - SV_SendRefuse(node, M_GetText("No players from\nthis node.")); + SV_SendRefuse(node, "No players from\nthis node."); } else { - boolean newnode = false; - // client authorised to join nodewaiting[node] = (UINT8)(netbuffer->u.clientcfg.localplayers - playerpernode[node]); - if (!nodeingame[node]) + gamestate_t backupstate = gamestate; + + SV_AddNode(node); + + /// \note Wait what??? + /// What if the gamestate takes more than one second to get downloaded? + /// Or if a lagspike happens? + // you get a free second before desynch checks. use it wisely. + SV_InitResynchVars(node); + + if (!SV_SendServerConfig(node)) { - gamestate_t backupstate = gamestate; - - newnode = true; - - SV_AddNode(node); - - /// \note Wait what??? - /// What if the gamestate takes more than one second to get downloaded? - /// Or if a lagspike happens? - // you get a free second before desynch checks. use it wisely. - SV_InitResynchVars(node); - - if (!SV_SendServerConfig(node)) - { - G_SetGamestate(backupstate); - /// \note Shouldn't SV_SendRefuse be called before ResetNode? - SV_SendRefuse(node, M_GetText("Server couldn't send info, please try again")); - ResetNode(node); // Yeah, lets try it! - /// \todo fix this !!! - return; // restart the while - } - - SV_SendServerInfo(node, 0); // Dunno if 0 time is good idea - //if (gamestate != GS_LEVEL) // GS_INTERMISSION, etc? - // SV_SendPlayerConfigs(node); // send bare minimum player info G_SetGamestate(backupstate); - DEBFILE("new node joined\n"); + /// \note Shouldn't SV_SendRefuse be called before ResetNode? + SV_SendRefuse(node, "Server couldn't send info, please try again"); + ResetNode(node); // Yeah, lets try it! + /// \todo fix this !!! + return; // restart the while } + SV_SendServerInfo(node, 0); // Dunno if 0 time is good idea + //if (gamestate != GS_LEVEL) // GS_INTERMISSION, etc? + // SV_SendPlayerConfigs(node); // send bare minimum player info + G_SetGamestate(backupstate); + DEBFILE("new node joined\n"); + if (nodewaiting[node]) { - if (node && newnode) - { - SV_SendSaveGame(node, false); // send a complete game state - DEBFILE("send savegame\n"); - } + SV_SendSaveGame(node, false); // send a complete game state + DEBFILE("send savegame\n"); - SV_AddWaitingPlayers(); + SV_AddWaitingPlayers(node); } } } @@ -4922,8 +4931,11 @@ static void HandleConnect(SINT8 node) * \param node The packet sender (should be the server) * */ -static void HandleShutdown(SINT8 node) +static void PT_ServerShutdown(SINT8 node) { + if (node != servernode || server || cl_mode == CL_SEARCHING) + return; + (void)node; D_QuitNetGame(); CL_Reset(); @@ -4951,7 +4963,7 @@ static void HandleTimeout(SINT8 node) * \note What happens if the packet comes from a client or something like that? * */ -static void HandleServerInfo(SINT8 node) +static void PT_ServerInfo(SINT8 node) { char servername[MAXSERVERNAME]; doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); @@ -4974,7 +4986,7 @@ static void HandleServerInfo(SINT8 node) memcpy(connectedservername, netbuffer->u.serverinfo.servername, MAXSERVERNAME); } -static void HandlePlayerInfo(void) +static void PT_PlayerInfo(void) { INT32 i; doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); @@ -5372,6 +5384,9 @@ static void HandlePacketFromAwayNode(SINT8 node) case PT_ASKINFOVIAMS: Net_CloseConnection(node); break; + case PT_SERVERINFO: + PT_ServerInfo(node); + break; case PT_TELLFILESNEEDED: PT_TellFilesNeeded(node); break; @@ -5402,7 +5417,7 @@ static void HandlePacketFromAwayNode(SINT8 node) case PT_CLIENTCMD: break; // This is not an "unknown packet" case PT_PLAYERINFO: - HandlePlayerInfo(); + PT_PlayerInfo(); break; case PT_MAPICON: PT_MapIcon(); @@ -5410,6 +5425,13 @@ static void HandlePacketFromAwayNode(SINT8 node) case PT_NEEDMAPICON: PT_NeedMapIcon(node); break; + case PT_CLIENTJOIN: + PT_ClientJoin(node); + break; + case PT_SERVERSHUTDOWN: + PT_ServerShutdown(node); + break; + case PT_SERVERTICS: // Do not remove my own server (we have just get a out of order packet) if (node == servernode) @@ -5659,6 +5681,10 @@ static void PT_BasicKeepAlive(INT32 netconsole, SINT8 node) static void PT_TextCmd(INT32 netconsole, SINT8 node) { + size_t j; + tic_t tic; + UINT8 *textcmd; + if (client) return; @@ -5680,79 +5706,84 @@ static void PT_TextCmd(INT32 netconsole, SINT8 node) } if (netconsole < 0 || netconsole >= MAXPLAYERS) - Net_UnAcknowledgePacket(node); - else { - size_t j; - tic_t tic = maketic; - UINT8 *textcmd; - - // ignore if the textcmd has a reported size of zero - // this shouldn't be sent at all - if (!netbuffer->u.textcmd[0]) - { - DEBFILE(va("GetPacket: Textcmd with size 0 detected! (node %u, player %d)\n", - node, netconsole)); - Net_UnAcknowledgePacket(node); - return; - } - - // ignore if the textcmd size var is actually larger than it should be - // BASEPACKETSIZE + 1 (for size) + textcmd[0] should == datalength - if (netbuffer->u.textcmd[0] > (size_t)doomcom->datalength-1) - { - DEBFILE(va("GetPacket: Bad Textcmd packet size! (expected %d, actual %s, node %u, player %d)\n", - netbuffer->u.textcmd[0], sizeu1((size_t)doomcom->datalength-1), - node, netconsole)); - Net_UnAcknowledgePacket(node); - return; - } - - // check if tic that we are making isn't too large else we cannot send it :( - // doomcom->numslots+1 "+1" since doomcom->numslots can change within this time and sent time - j = (software_MAXPACKETLENGTH - (netbuffer->u.textcmd[0]+2+BASESERVERTICSSIZE + (doomcom->numslots+1)*sizeof(ticcmd_t))); - - // search a tic that have enougth space in the ticcmd - while ((textcmd = D_GetExistingTextcmd(tic, netconsole)), - (TotalTextCmdPerTic(tic) > j || netbuffer->u.textcmd[0] + (textcmd ? textcmd[0] : 0) > MAXTEXTCMD) - && tic < firstticstosend + BACKUPTICS) - { - tic++; - } - - if (tic >= firstticstosend + BACKUPTICS) - { - DEBFILE(va("GetPacket: Textcmd too long (max %s, used %s, mak %d, " - "tosend %u, node %u, player %d)\n", sizeu1(j), sizeu2(TotalTextCmdPerTic(maketic)), - maketic, firstticstosend, node, netconsole)); - Net_UnAcknowledgePacket(node); - return; - } - - // Make sure we have a buffer - if (!textcmd) - textcmd = D_GetTextcmd(tic, netconsole); - - DEBFILE(va("textcmd put in tic %u at position %d (player %d) ftts %u mk %u\n", - tic, textcmd[0]+1, netconsole, firstticstosend, maketic)); - - memcpy(&textcmd[textcmd[0]+1], netbuffer->u.textcmd+1, netbuffer->u.textcmd[0]); - textcmd[0] += (UINT8)netbuffer->u.textcmd[0]; + Net_UnAcknowledgePacket(node); + return; } + + // ignore if the textcmd has a reported size of zero + // this shouldn't be sent at all + if (!netbuffer->u.textcmd[0]) + { + DEBFILE(va("GetPacket: Textcmd with size 0 detected! (node %u, player %d)\n", + node, netconsole)); + Net_UnAcknowledgePacket(node); + return; + } + + // ignore if the textcmd size var is actually larger than it should be + // BASEPACKETSIZE + 1 (for size) + textcmd[0] should == datalength + if (netbuffer->u.textcmd[0] > (size_t)doomcom->datalength-1) + { + DEBFILE(va("GetPacket: Bad Textcmd packet size! (expected %d, actual %s, node %u, player %d)\n", + netbuffer->u.textcmd[0], sizeu1((size_t)doomcom->datalength-1), + node, netconsole)); + Net_UnAcknowledgePacket(node); + return; + } + + // check if tic that we are making isn't too large else we cannot send it :( + // doomcom->numslots+1 "+1" since doomcom->numslots can change within this time and sent time + j = (software_MAXPACKETLENGTH - (netbuffer->u.textcmd[0]+2+BASESERVERTICSSIZE + (doomcom->numslots+1)*sizeof(ticcmd_t))); + + tic = maketic; + + // search a tic that have enougth space in the ticcmd + while ((textcmd = D_GetExistingTextcmd(tic, netconsole)), + (TotalTextCmdPerTic(tic) > j || netbuffer->u.textcmd[0] + (textcmd ? textcmd[0] : 0) > MAXTEXTCMD) + && tic < firstticstosend + BACKUPTICS) + { + tic++; + } + + if (tic >= firstticstosend + BACKUPTICS) + { + DEBFILE(va("GetPacket: Textcmd too long (max %s, used %s, mak %d, " + "tosend %u, node %u, player %d)\n", sizeu1(j), sizeu2(TotalTextCmdPerTic(maketic)), + maketic, firstticstosend, node, netconsole)); + Net_UnAcknowledgePacket(node); + return; + } + + // Make sure we have a buffer + if (!textcmd) + textcmd = D_GetTextcmd(tic, netconsole); + + DEBFILE(va("textcmd put in tic %u at position %d (player %d) ftts %u mk %u\n", + tic, textcmd[0]+1, netconsole, firstticstosend, maketic)); + + memcpy(&textcmd[textcmd[0]+1], netbuffer->u.textcmd+1, netbuffer->u.textcmd[0]); + textcmd[0] += (UINT8)netbuffer->u.textcmd[0]; } static void PT_ClientQuit(INT32 netconsole, SINT8 node) { + doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); + if (client) + { + if (node == servernode && cl_mode != CL_SEARCHING && netbuffer->packettype == PT_NODETIMEOUT) + HandleTimeout(node); return; + } // nodeingame will be put false in the execution of kick command // this allow to send some packets to the quitting client to have their ack back nodewaiting[node] = 0; if (netconsole != -1 && playeringame[netconsole]) { - doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); - SendKick(netconsole, (netbuffer->packettype == PT_NODETIMEOUT) ? KICK_MSG_TIMEOUT : KICK_MSG_PLAYER_QUIT); + const int quitreason = ((netbuffer->packettype == PT_NODETIMEOUT) ? KICK_MSG_TIMEOUT : KICK_MSG_PLAYER_QUIT); + SendKick(netconsole, quitreason); } Net_CloseConnection(node); nodeingame[node] = false; @@ -5938,9 +5969,6 @@ static void HandlePacketFromPlayer(SINT8 node) switch (netbuffer->packettype) { // -------------------------------------------- SERVER RECEIVE ---------- - case PT_RESYNCHGET: - SV_AcknowledgeResynchAck(node, netbuffer->u.resynchgot); - break; case PT_CLIENTCMD: case PT_CLIENT2CMD: case PT_CLIENT3CMD: @@ -5966,16 +5994,13 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_CLIENTQUIT: PT_ClientQuit(netconsole, node); break; -// -------------------------------------------- CLIENT RECEIVE ---------- - case PT_RESYNCHEND: - PT_Resynched(node); + case PT_RESYNCHGET: + SV_AcknowledgeResynchAck(node, netbuffer->u.resynchgot); break; +// -------------------------------------------- CLIENT RECEIVE ---------- case PT_SERVERTICS: PT_ServerTics(node); break; - case PT_RESYNCHING: - PT_Resynching(node); - break; case PT_PING: PT_Ping(node); break; @@ -5999,6 +6024,12 @@ static void HandlePacketFromPlayer(SINT8 node) is_client_saturn[node] = true; break; #endif + case PT_RESYNCHING: + PT_Resynching(node); + break; + case PT_RESYNCHEND: + PT_Resynched(node); + break; default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", netbuffer->packettype, node)); } @@ -6019,36 +6050,6 @@ static void GetPackets(void) { node = (SINT8)doomcom->remotenode; - if (server && netbuffer->packettype == PT_CLIENTJOIN) - { - if (!levelloading) // Otherwise just ignore - { - HandleConnect(node); - } - - continue; - } - - if (client && node == servernode && cl_mode != CL_SEARCHING) - { - if (netbuffer->packettype == PT_SERVERSHUTDOWN) - { - HandleShutdown(node); - continue; - } - if (netbuffer->packettype == PT_NODETIMEOUT) - { - HandleTimeout(node); - continue; - } - } - - if (netbuffer->packettype == PT_SERVERINFO) - { - HandleServerInfo(node); - continue; - } - /*if (netbuffer->packettype == PT_PLAYERINFO) continue; // We do nothing with PLAYERINFO, that's for the MS browser. Not quite true anymore :p*/ @@ -6367,21 +6368,7 @@ static void CL_SendClientCmd(void) { if (localtextcmd[i][0]) { - switch (i) - { - case 3: - netbuffer->packettype = PT_TEXTCMD4; - break; - case 2: - netbuffer->packettype = PT_TEXTCMD3; - break; - case 1: - netbuffer->packettype = PT_TEXTCMD2; - break; - default: - netbuffer->packettype = PT_TEXTCMD; - break; - } + netbuffer->packettype = PT_TEXTCMD + i; memcpy(netbuffer->u.textcmd, localtextcmd[i], localtextcmd[i][0]+1); @@ -6425,7 +6412,7 @@ static void SV_SendTics(void) continue; // assert supposedtics[n]>=nettics[n] - realfirsttic = max(supposedtics[n], firstticstosend); + realfirsttic = supposedtics[n]; lasttictosend = min(maketic, nettics[n] + CLIENTBACKUPTICS); if (realfirsttic >= lasttictosend) @@ -7164,6 +7151,8 @@ void NetUpdate(void) Net_AckTicker(); HandleNodeTimeouts(); + nowtime /= NEWTICRATERATIO; + if (nowtime > resptime) { resptime = nowtime; @@ -7189,9 +7178,15 @@ void NetUpdate(void) INT32 D_NumPlayers(void) { INT32 num = 0, ix; + for (ix = 0; ix < MAXPLAYERS; ix++) + { if (playeringame[ix]) + { num++; + } + } + return num; } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 430729bc2..08bccf845 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -660,9 +660,11 @@ extern UINT8 hu_redownloadinggamestate; #endif extern boolean hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player +#define SAVEGAMESIZE (768*1024) + typedef struct rewind_s { - UINT8 savebuffer[(768*1024)]; + UINT8 savebuffer[SAVEGAMESIZE]; tic_t leveltime; size_t demopos; diff --git a/src/g_game.c b/src/g_game.c index 55c2c6c1a..14acd7f62 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -69,9 +69,6 @@ UINT8 botcolor = 0; JoyType_t Joystick[MAXSPLITSCREENPLAYERS] = {}; -// 1024 bytes is plenty for a savegame -#define SAVEGAMESIZE (1024) - // SRB2kart char gamedatafilename[64] = "kartdata.dat"; char timeattackfolder[64] = "kart"; @@ -3837,7 +3834,7 @@ void G_SaveGame(UINT32 savegameslot) char name[VERSIONSIZE]; size_t length; - save.p = save.buffer = (UINT8 *)Z_Malloc(SAVEGAMESIZE, PU_STATIC, NULL); + save.p = save.buffer = (UINT8 *)Z_Malloc(1024, PU_STATIC, NULL); // 1024 bytes is plenty for a savegame if (!save.p) { CONS_Alert(CONS_ERROR, M_GetText("No more free memory for saving game data\n")); From 96aaaf52615cd010f68a49b12a33b3b04ffa6c41 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 2 Dec 2025 12:45:47 +0100 Subject: [PATCH 002/589] merge SendNameAndColor & SendWeaponPref TODO: make a bunch of player specific cvars arrays for splitscreen handling - also cleanup some strlen usage --- src/d_clisrv.c | 2 +- src/d_netcmd.c | 626 ++++++++++++------------------------------------- src/d_netcmd.h | 7 +- src/r_main.cpp | 8 +- 4 files changed, 151 insertions(+), 492 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 33b69045e..ccb8d092b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4495,7 +4495,7 @@ static void Got_AddPlayer(const UINT8 **p, INT32 playernum) P_ForceLocalAngle(&players[newplayernum], (angle_t)(players[newplayernum].cmd.angleturn << TICCMD_REDUCE)); - D_SendPlayerConfig(); + D_SendPlayerConfig(splitscreenplayer); addedtogame = true; } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 00760e4a4..246702a4d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1197,11 +1197,11 @@ static boolean AllowedPlayerNameChar(char ch) static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum) { - INT32 ix; + size_t ix, len = strlen(name); - if (strlen(name) == 0 || strlen(name) > MAXPLAYERNAME) + if (len == 0 || len > MAXPLAYERNAME) return false; // Empty or too long. - if (name[0] == ' ' || name[strlen(name)-1] == ' ') + if (name[0] == ' ' || name[len-1] == ' ') return false; // Starts or ends with a space. if (isdigit(name[0])) return false; // Starts with a digit. @@ -1215,20 +1215,19 @@ static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum) // Also, anything over 0x80 is disallowed too, since compilers love to // differ on whether they're printable characters or not. - for (ix = 0; name[ix] != '\0'; ix++) + for (ix = 0; ix < len; ix++) if (!AllowedPlayerNameChar(name[ix])) return false; // Check if a player is currently using the name, case-insensitively. for (ix = 0; ix < MAXPLAYERS; ix++) { - if (ix != playernum && playeringame[ix] + if (ix != (size_t)playernum && playeringame[ix] && fasticmp(name, player_names[ix])) { // We shouldn't kick people out just because // they joined the game with the same name // as someone else -- modify the name instead. - size_t len = strlen(name); // Recursion! // Slowly strip characters off the end of the @@ -1447,7 +1446,9 @@ UINT8 CanChangeSkin(INT32 playernum) return true; } - if (players[playernum].spectator || players[playernum].playerstate == PST_DEAD || players[playernum].playerstate == PST_REBORN) + if (players[playernum].spectator || + players[playernum].playerstate == PST_DEAD || + players[playernum].playerstate == PST_REBORN) return true; return false; @@ -1481,445 +1482,144 @@ static void ForceAllSkins(INT32 forcedskin) } } -static INT32 snacpending = 0, snac2pending = 0, snac3pending = 0, snac4pending = 0, chmappending = 0; +static INT32 chmappending; +static INT32 snacpending[MAXSPLITSCREENPLAYERS]; + +// wonky compat, idk if anything uses this.... +#define playerisbot (splitplayer == 1 && botingame) // name, color, or skin has changed // -static void SendNameAndColor(void) +static void SendNameAndColor(UINT8 splitplayer) { char buf[MAXPLAYERNAME+2]; char *p; p = buf; + // splitscreen + if (splitscreen < splitplayer && !playerisbot) + return; + + const INT32 pnum = P_GetLocalPlayerNumForNum(splitplayer); + + player_t *player = &players[pnum]; + + // TODO: make those cvars arrays + consvar_t *playercolor, *playername, *playerskin; + consvar_t *colorvars[] = {&cv_playercolor, &cv_playercolor2, &cv_playercolor3, &cv_playercolor4}; + consvar_t *namevars[] = {&cv_playername, &cv_playername2, &cv_playername3, &cv_playername4}; + consvar_t *skinvars[] = {&cv_skin, &cv_skin2, &cv_skin3, &cv_skin4}; + + playercolor = colorvars[splitplayer]; + playername = namevars[splitplayer]; + playerskin = skinvars[splitplayer]; + // normal player colors if (G_GametypeHasTeams()) { - if (players[consoleplayer].ctfteam == 1 && cv_playercolor.value != skincolor_redteam) - CV_StealthSetValue(&cv_playercolor, skincolor_redteam); - else if (players[consoleplayer].ctfteam == 2 && cv_playercolor.value != skincolor_blueteam) - CV_StealthSetValue(&cv_playercolor, skincolor_blueteam); + if (player->ctfteam == 1 && playercolor->value != skincolor_redteam) + CV_StealthSetValue(playercolor, skincolor_redteam); + else if (player->ctfteam == 2 && playercolor->value != skincolor_blueteam) + CV_StealthSetValue(playercolor, skincolor_blueteam); } // never allow the color "none" - if (!cv_playercolor.value) + if (!playercolor->value) { - if (players[consoleplayer].skincolor) - CV_StealthSetValue(&cv_playercolor, players[consoleplayer].skincolor); - else if (skins[players[consoleplayer].skin].prefcolor) - CV_StealthSetValue(&cv_playercolor, skins[players[consoleplayer].skin].prefcolor); + if (player->skincolor) + CV_StealthSetValue(playercolor, player->skincolor); + else if (skins[player->skin].prefcolor) + CV_StealthSetValue(playercolor, skins[player->skin].prefcolor); else - CV_StealthSet(&cv_playercolor, cv_playercolor.defaultvalue); + CV_StealthSet(playercolor, playercolor->defaultvalue); } - if (fastcmp(cv_playername.string, player_names[consoleplayer]) - && cv_playercolor.value == players[consoleplayer].skincolor - && fastcmp(cv_skin.string, skins[players[consoleplayer].skin].name)) - return; - // We'll handle it later if we're not playing. if (!Playing()) return; + if (fastcmp(playername->string, player_names[pnum]) + && playercolor->value == player->skincolor + && fastcmp(playerskin->string, skins[player->skin].name)) + return; + + if (playerisbot) + { + players[pnum].skincolor = botcolor; + if (players[pnum].mo) + players[pnum].mo->color = players[pnum].skincolor; + SetPlayerSkinByNum(pnum, botskin-1); + return; + } + // If you're not in a netgame, merely update the skin, color, and name. if (!netgame) { INT32 foundskin; - CleanupPlayerName(consoleplayer, cv_playername.zstring); - strcpy(player_names[consoleplayer], cv_playername.zstring); + CleanupPlayerName(pnum, playername->zstring); + strcpy(player_names[pnum], playername->zstring); - players[consoleplayer].skincolor = cv_playercolor.value; + player->skincolor = playercolor->value; - if (players[consoleplayer].mo) - players[consoleplayer].mo->color = players[consoleplayer].skincolor; + if (player->mo) + player->mo->color = player->skincolor; - if ((foundskin = R_SkinAvailable(cv_skin.string)) != -1) + if ((foundskin = R_SkinAvailable(playerskin->string)) != -1) { - cv_skin.value = foundskin; - SetPlayerSkin(consoleplayer, cv_skin.string); - CV_StealthSet(&cv_skin, skins[cv_skin.value].name); + playerskin->value = foundskin; + SetPlayerSkin(pnum, playerskin->string); + CV_StealthSet(playerskin, skins[playerskin->value].name); } else { - cv_skin.value = players[consoleplayer].skin; - CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); + playerskin->value = player->skin; + CV_StealthSet(playerskin, skins[player->skin].name); // will always be same as current - SetPlayerSkin(consoleplayer, cv_skin.string); + SetPlayerSkin(pnum, playerskin->string); } return; } - snacpending++; + snacpending[splitplayer]++; // Don't change name if muted - if (player_name_changes[consoleplayer] >= MAXNAMECHANGES) + if (player_name_changes[pnum] >= MAXNAMECHANGES) { - CV_StealthSet(&cv_playername, player_names[consoleplayer]); + CV_StealthSet(playername, player_names[pnum]); HU_AddChatText("\x85*You must wait to change your name again", false); } - else if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer))) - CV_StealthSet(&cv_playername, player_names[consoleplayer]); + else if (cv_mute.value && !(server || IsPlayerAdmin(pnum))) + CV_StealthSet(playername, player_names[pnum]); else // Cleanup name if changing it - CleanupPlayerName(consoleplayer, cv_playername.zstring); + CleanupPlayerName(pnum, playername->zstring); // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(consoleplayer)) - CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name); + if (!CanChangeSkin(pnum)) + CV_StealthSet(playerskin, skins[player->skin].name); // check if player has the skin loaded (cv_skin may have // the name of a skin that was available in the previous game) - cv_skin.value = R_SkinAvailable(cv_skin.string); - if (cv_skin.value < 0) + playerskin->value = R_SkinAvailable(playerskin->string); + if (playerskin->value < 0) { - INT32 skinnum = players[consoleplayer].skin; - CV_StealthSet(&cv_skin, skins[skinnum].name); - cv_skin.value = skinnum; + INT32 skinnum = player->skin; + CV_StealthSet(playerskin, skins[skinnum].name); + playerskin->value = skinnum; } // Finally write out the complete packet and send it off. - WRITESTRINGN(p, cv_playername.zstring, MAXPLAYERNAME); - WRITEUINT8(p, (UINT8)cv_playercolor.value); - WRITEUINT8(p, (UINT8)cv_skin.value); - SendNetXCmdForPlayer(0, XD_NAMEANDCOLOR, buf, p - buf); -} - -// splitscreen -static void SendNameAndColor2(void) -{ - INT32 secondplaya = -1; - char buf[MAXPLAYERNAME+2]; - char *p; - - if (splitscreen < 1 && !botingame) - return; // can happen if skin2/color2/name2 changed - - if (displayplayers[1] != consoleplayer) - secondplaya = displayplayers[1]; - else if (!netgame) // HACK - secondplaya = 1; - - if (secondplaya == -1) - return; - - p = buf; - - // normal player colors - if (G_GametypeHasTeams()) - { - if (players[secondplaya].ctfteam == 1 && cv_playercolor2.value != skincolor_redteam) - CV_StealthSetValue(&cv_playercolor2, skincolor_redteam); - else if (players[secondplaya].ctfteam == 2 && cv_playercolor2.value != skincolor_blueteam) - CV_StealthSetValue(&cv_playercolor2, skincolor_blueteam); - } - - // never allow the color "none" - if (!cv_playercolor2.value) - { - if (players[secondplaya].skincolor) - CV_StealthSetValue(&cv_playercolor2, players[secondplaya].skincolor); - else if (skins[players[secondplaya].skin].prefcolor) - CV_StealthSetValue(&cv_playercolor2, skins[players[secondplaya].skin].prefcolor); - else - CV_StealthSet(&cv_playercolor2, cv_playercolor2.defaultvalue); - } - - // We'll handle it later if we're not playing. - if (!Playing()) - return; - - // If you're not in a netgame, merely update the skin, color, and name. - if (botingame) - { - players[secondplaya].skincolor = botcolor; - if (players[secondplaya].mo) - players[secondplaya].mo->color = players[secondplaya].skincolor; - SetPlayerSkinByNum(secondplaya, botskin-1); - return; - } - else if (!netgame) - { - INT32 foundskin; - - CleanupPlayerName(secondplaya, cv_playername2.zstring); - strcpy(player_names[secondplaya], cv_playername2.zstring); - - // don't use displayplayers[1]: the second player must be 1 - players[secondplaya].skincolor = cv_playercolor2.value; - if (players[secondplaya].mo) - players[secondplaya].mo->color = players[secondplaya].skincolor; - - if ((foundskin = R_SkinAvailable(cv_skin2.string)) != -1) - { - cv_skin2.value = foundskin; - SetPlayerSkin(secondplaya, cv_skin2.string); - } - else - { - cv_skin2.value = players[secondplaya].skin; - CV_StealthSet(&cv_skin2, skins[players[secondplaya].skin].name); - // will always be same as current - SetPlayerSkin(secondplaya, cv_skin2.string); - } - return; - } - - snac2pending++; - - // Don't change name if muted - if (player_name_changes[displayplayers[1]] >= MAXNAMECHANGES) - { - CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]); - HU_AddChatText("\x85*You must wait to change your name again", false); - } - else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[1]))) - CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]); - else // Cleanup name if changing it - CleanupPlayerName(displayplayers[1], cv_playername2.zstring); - - // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(displayplayers[1])) - CV_StealthSet(&cv_skin2, skins[players[displayplayers[1]].skin].name); - - // check if player has the skin loaded (cv_skin2 may have - // the name of a skin that was available in the previous game) - cv_skin2.value = R_SkinAvailable(cv_skin2.string); - if (cv_skin2.value < 0) - { - INT32 skinnum = players[displayplayers[1]].skin; - CV_StealthSet(&cv_skin2, skins[skinnum].name); - cv_skin2.value = skinnum; - } - - // Finally write out the complete packet and send it off. - WRITESTRINGN(p, cv_playername2.zstring, MAXPLAYERNAME); - WRITEUINT8(p, (UINT8)cv_playercolor2.value); - WRITEUINT8(p, (UINT8)cv_skin2.value); - SendNetXCmdForPlayer(1, XD_NAMEANDCOLOR, buf, p - buf); -} - -static void SendNameAndColor3(void) -{ - INT32 thirdplaya = -1; - char buf[MAXPLAYERNAME+2]; - char *p; - - if (splitscreen < 2) - return; // can happen if skin3/color3/name3 changed - - if (displayplayers[2] != consoleplayer) - thirdplaya = displayplayers[2]; - else if (!netgame) // HACK - thirdplaya = 2; - - if (thirdplaya == -1) - return; - - p = buf; - - // normal player colors - if (G_GametypeHasTeams()) - { - if (players[thirdplaya].ctfteam == 1 && cv_playercolor3.value != skincolor_redteam) - CV_StealthSetValue(&cv_playercolor3, skincolor_redteam); - else if (players[thirdplaya].ctfteam == 2 && cv_playercolor3.value != skincolor_blueteam) - CV_StealthSetValue(&cv_playercolor3, skincolor_blueteam); - } - - // never allow the color "none" - if (!cv_playercolor3.value) - { - if (players[thirdplaya].skincolor) - CV_StealthSetValue(&cv_playercolor3, players[thirdplaya].skincolor); - else if (skins[players[thirdplaya].skin].prefcolor) - CV_StealthSetValue(&cv_playercolor3, skins[players[thirdplaya].skin].prefcolor); - else - CV_StealthSet(&cv_playercolor3, cv_playercolor3.defaultvalue); - } - - // We'll handle it later if we're not playing. - if (!Playing()) - return; - - // If you're not in a netgame, merely update the skin, color, and name. - if (!netgame) - { - INT32 foundskin; - - CleanupPlayerName(thirdplaya, cv_playername3.zstring); - strcpy(player_names[thirdplaya], cv_playername3.zstring); - - // don't use displayplayers[2]: the third player must be 2 - players[thirdplaya].skincolor = cv_playercolor3.value; - if (players[thirdplaya].mo) - players[thirdplaya].mo->color = players[thirdplaya].skincolor; - - if ((foundskin = R_SkinAvailable(cv_skin3.string)) != -1) - { - cv_skin3.value = foundskin; - SetPlayerSkin(thirdplaya, cv_skin3.string); - } - else - { - cv_skin3.value = players[thirdplaya].skin; - CV_StealthSet(&cv_skin3, skins[players[thirdplaya].skin].name); - // will always be same as current - SetPlayerSkin(thirdplaya, cv_skin3.string); - } - return; - } - - snac3pending++; - - // Don't change name if muted - if (player_name_changes[displayplayers[2]] >= MAXNAMECHANGES) - { - CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]); - HU_AddChatText("\x85*You must wait to change your name again", false); - } - else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[2]))) - CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]); - else // Cleanup name if changing it - CleanupPlayerName(displayplayers[2], cv_playername3.zstring); - - // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(displayplayers[2])) - CV_StealthSet(&cv_skin3, skins[players[displayplayers[2]].skin].name); - - // check if player has the skin loaded (cv_skin3 may have - // the name of a skin that was available in the previous game) - cv_skin3.value = R_SkinAvailable(cv_skin3.string); - if (cv_skin3.value < 0) - { - INT32 skinnum = players[displayplayers[2]].skin; - CV_StealthSet(&cv_skin3, skins[skinnum].name); - cv_skin3.value = skinnum; - } - - // Finally write out the complete packet and send it off. - WRITESTRINGN(p, cv_playername3.zstring, MAXPLAYERNAME); - WRITEUINT8(p, (UINT8)cv_playercolor3.value); - WRITEUINT8(p, (UINT8)cv_skin3.value); - SendNetXCmdForPlayer(2, XD_NAMEANDCOLOR, buf, p - buf); -} - -static void SendNameAndColor4(void) -{ - INT32 fourthplaya = -1; - char buf[MAXPLAYERNAME+2]; - char *p; - - if (splitscreen < 3) - return; // can happen if skin4/color4/name4 changed - - if (displayplayers[3] != consoleplayer) - fourthplaya = displayplayers[3]; - else if (!netgame) // HACK - fourthplaya = 3; - - if (fourthplaya == -1) - return; - - p = buf; - - // normal player colors - if (G_GametypeHasTeams()) - { - if (players[fourthplaya].ctfteam == 1 && cv_playercolor4.value != skincolor_redteam) - CV_StealthSetValue(&cv_playercolor4, skincolor_redteam); - else if (players[fourthplaya].ctfteam == 2 && cv_playercolor4.value != skincolor_blueteam) - CV_StealthSetValue(&cv_playercolor4, skincolor_blueteam); - } - - // never allow the color "none" - if (!cv_playercolor4.value) - { - if (players[fourthplaya].skincolor) - CV_StealthSetValue(&cv_playercolor4, players[fourthplaya].skincolor); - else if (skins[players[fourthplaya].skin].prefcolor) - CV_StealthSetValue(&cv_playercolor4, skins[players[fourthplaya].skin].prefcolor); - else - CV_StealthSet(&cv_playercolor4, cv_playercolor4.defaultvalue); - } - - // We'll handle it later if we're not playing. - if (!Playing()) - return; - - // If you're not in a netgame, merely update the skin, color, and name. - if (botingame) - { - players[fourthplaya].skincolor = botcolor; - if (players[fourthplaya].mo) - players[fourthplaya].mo->color = players[fourthplaya].skincolor; - SetPlayerSkinByNum(fourthplaya, botskin-1); - return; - } - else if (!netgame) - { - INT32 foundskin; - - CleanupPlayerName(fourthplaya, cv_playername4.zstring); - strcpy(player_names[fourthplaya], cv_playername4.zstring); - - // don't use displayplayers[3]: the second player must be 4 - players[fourthplaya].skincolor = cv_playercolor4.value; - if (players[fourthplaya].mo) - players[fourthplaya].mo->color = players[fourthplaya].skincolor; - - if ((foundskin = R_SkinAvailable(cv_skin4.string)) != -1) - { - cv_skin4.value = foundskin; - SetPlayerSkin(fourthplaya, cv_skin4.string); - } - else - { - cv_skin4.value = players[fourthplaya].skin; - CV_StealthSet(&cv_skin4, skins[players[fourthplaya].skin].name); - // will always be same as current - SetPlayerSkin(fourthplaya, cv_skin4.string); - } - return; - } - - snac4pending++; - - // Don't change name if muted - if (player_name_changes[displayplayers[3]] >= MAXNAMECHANGES) - { - CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]); - HU_AddChatText("\x85*You must wait to change your name again", false); - } - else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[3]))) - CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]); - else // Cleanup name if changing it - CleanupPlayerName(displayplayers[3], cv_playername4.zstring); - - // Don't change skin if the server doesn't want you to. - if (!CanChangeSkin(displayplayers[3])) - CV_StealthSet(&cv_skin4, skins[players[displayplayers[3]].skin].name); - - // check if player has the skin loaded (cv_skin4 may have - // the name of a skin that was available in the previous game) - cv_skin4.value = R_SkinAvailable(cv_skin4.string); - if (cv_skin4.value < 0) - { - INT32 skinnum = players[displayplayers[3]].skin; - CV_StealthSet(&cv_skin4, skins[skinnum].name); - cv_skin4.value = skinnum; - } - - // Finally write out the complete packet and send it off. - WRITESTRINGN(p, cv_playername4.zstring, MAXPLAYERNAME); - WRITEUINT8(p, (UINT8)cv_playercolor4.value); - WRITEUINT8(p, (UINT8)cv_skin4.value); - SendNetXCmdForPlayer(3, XD_NAMEANDCOLOR, buf, p - buf); + WRITESTRINGN(p, playername->zstring, MAXPLAYERNAME); + WRITEUINT8(p, (UINT8)playercolor->value); + WRITEUINT8(p, (UINT8)playerskin->value); + SendNetXCmdForPlayer(splitplayer, XD_NAMEANDCOLOR, buf, p - buf); } static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) { - player_t *p = &players[playernum]; + player_t *player = &players[playernum]; char name[MAXPLAYERNAME+1]; UINT8 color, skin; @@ -1928,19 +1628,14 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) I_Error("There is no player %d!", playernum); #endif - if (playernum == consoleplayer) - snacpending--; // TODO: make snacpending an array instead of 4 separate vars? - else if (playernum == displayplayers[1]) - snac2pending--; - else if (playernum == displayplayers[2]) - snac3pending--; - else if (playernum == displayplayers[3]) - snac4pending--; - + if (P_IsLocalPlayer(player)) + { + snacpending[playernum]--; #ifdef PARANOIA - if (snacpending < 0 || snac2pending < 0 || snac3pending < 0 || snac4pending < 0) - I_Error("snacpending negative!"); + if (snacpending[playernum] < 0) + I_Error("snacpending negative!"); #endif + } READSTRINGN(*cp, name, MAXPLAYERNAME); color = READUINT8(*cp); @@ -1954,33 +1649,32 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) } // set color - p->skincolor = color % MAXSKINCOLORS; - if (p->mo) - p->mo->color = (UINT8)p->skincolor; + player->skincolor = color % MAXSKINCOLORS; + if (player->mo) + player->mo->color = (UINT8)player->skincolor; demo_extradata[playernum] |= DXD_COLOR; // normal player colors - if (server && (p != &players[consoleplayer] && p != &players[displayplayers[1]] - && p != &players[displayplayers[2]] && p != &players[displayplayers[3]])) + if (server && !P_IsLocalPlayer(player)) { boolean kick = false; // team colors if (G_GametypeHasTeams()) { - if (p->ctfteam == 1 && p->skincolor != skincolor_redteam) + if (player->ctfteam == 1 && player->skincolor != skincolor_redteam) kick = true; - else if (p->ctfteam == 2 && p->skincolor != skincolor_blueteam) + else if (player->ctfteam == 2 && player->skincolor != skincolor_blueteam) kick = true; } // don't allow color "none" - if (!p->skincolor) + if (!player->skincolor) kick = true; if (kick) { - CONS_Alert(CONS_WARNING, M_GetText("Illegal color change received from %s (team: %d), color: %d)\n"), player_names[playernum], p->ctfteam, p->skincolor); + CONS_Alert(CONS_WARNING, M_GetText("Illegal color change received from %s (team: %d), color: %d)\n"), player_names[playernum], player->ctfteam, player->skincolor); SendKick(playernum, KICK_MSG_CON_FAIL); return; } @@ -1992,6 +1686,7 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) const INT32 forcedskin = cv_forceskin.value; SetPlayerSkinByNum(playernum, forcedskin); + // TODO: make cv_skin an array if (playernum == consoleplayer) CV_StealthSet(&cv_skin, skins[forcedskin].name); else if (playernum == displayplayers[1]) @@ -2005,44 +1700,16 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) SetPlayerSkinByNum(playernum, skin); } -void SendWeaponPref(void) +void SendWeaponPref(UINT8 splitplayer) { UINT8 buf[1]; buf[0] = 0; - if (cv_flipcam[0].value) + + if (cv_flipcam[splitplayer].value) buf[0] |= 1; - SendNetXCmdForPlayer(0, XD_WEAPONPREF, buf, 1); -} -void SendWeaponPref2(void) -{ - UINT8 buf[1]; - - buf[0] = 0; - if (cv_flipcam[1].value) - buf[0] |= 1; - SendNetXCmdForPlayer(1, XD_WEAPONPREF, buf, 1); -} - -void SendWeaponPref3(void) -{ - UINT8 buf[1]; - - buf[0] = 0; - if (cv_flipcam[2].value) - buf[0] |= 1; - SendNetXCmdForPlayer(2, XD_WEAPONPREF, buf, 1); -} - -void SendWeaponPref4(void) -{ - UINT8 buf[1]; - - buf[0] = 0; - if (cv_flipcam[3].value) - buf[0] |= 1; - SendNetXCmdForPlayer(3, XD_WEAPONPREF, buf, 1); + SendNetXCmdForPlayer(splitplayer, XD_WEAPONPREF, buf, 1); } static void Got_WeaponPref(const UINT8 **cp, INT32 playernum) @@ -2058,23 +1725,10 @@ static void Got_WeaponPref(const UINT8 **cp, INT32 playernum) player->pflags |= PF_ANALOGMODE; } -void D_SendPlayerConfig(void) +void D_SendPlayerConfig(UINT8 splitplayer) { - SendNameAndColor(); - if (splitscreen || botingame) - SendNameAndColor2(); - if (splitscreen > 1) - SendNameAndColor3(); - if (splitscreen > 2) - SendNameAndColor4(); - - SendWeaponPref(); - if (splitscreen) - SendWeaponPref2(); - if (splitscreen > 1) - SendWeaponPref3(); - if (splitscreen > 2) - SendWeaponPref4(); + SendNameAndColor(splitplayer); + SendWeaponPref(splitplayer); } // Only works for displayplayer, sorry! @@ -2097,10 +1751,12 @@ INT32 D_LookupPlayer(const char *s) return playernum; } + const size_t len = strlen(s); + for (playernum = 0; playernum < MAXPLAYERS; ++playernum) { /* Match name case-insensitively: fully, or partially the start. */ - if (playeringame[playernum] && (strnicmp(player_names[playernum], s, strlen(s)) == 0)) + if (playeringame[playernum] && (strnicmp(player_names[playernum], s, len) == 0)) { return playernum; } @@ -2140,13 +1796,15 @@ static void GetViewablePlayerPlaceRange(INT32 *first, INT32 *last) (*last) = 0; for (i = 0; i < MAXPLAYERS; ++i) - if (G_CouldView(i)) { - place = players[i].kartstuff[k_position]; - if (place < (*first)) - (*first) = place; - if (place > (*last)) - (*last) = place; + if (G_CouldView(i)) + { + place = players[i].kartstuff[k_position]; + if (place < (*first)) + (*first) = place; + if (place > (*last)) + (*last) = place; + } } } @@ -2480,7 +2138,7 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r displayplayers[1] = 1; playeringame[1] = true; players[1].bot = 1; - SendNameAndColor2(); + SendNameAndColor(1); } } @@ -5735,50 +5393,54 @@ static void ForceSkin_OnChange(void) } } -//Allows the player's name to be changed if cv_mute is off. +// Allows the player's name to be changed if cv_mute is off. static void Name_OnChange(void) { if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer))) { CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n")); CV_StealthSet(&cv_playername, player_names[consoleplayer]); + return; } - else - SendNameAndColor(); + + SendNameAndColor(0); } static void Name2_OnChange(void) { - if (cv_mute.value) //Secondary player can't be admin. + if (cv_mute.value) // Secondary player can't be admin. { CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n")); CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]); + return; } - else - SendNameAndColor2(); + + SendNameAndColor(1); } static void Name3_OnChange(void) { - if (cv_mute.value) //Third player can't be admin. + if (cv_mute.value) // Third player can't be admin. { CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n")); CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]); + return; } - else - SendNameAndColor3(); + + SendNameAndColor(2); } static void Name4_OnChange(void) { - if (cv_mute.value) //Secondary player can't be admin. + if (cv_mute.value) // Secondary player can't be admin. { CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n")); CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]); + return; } - else - SendNameAndColor4(); + + SendNameAndColor(3); } /** Sends a skin change for the console player, unless that player is moving. @@ -5800,7 +5462,7 @@ static void Skin_OnChange(void) } if (CanChangeSkin(consoleplayer) && !P_PlayerMoving(consoleplayer)) - SendNameAndColor(); + SendNameAndColor(0); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); @@ -5821,7 +5483,7 @@ static void Skin2_OnChange(void) return; // do whatever you want if (CanChangeSkin(displayplayers[1]) && !P_PlayerMoving(displayplayers[1])) - SendNameAndColor2(); + SendNameAndColor(1); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); @@ -5837,7 +5499,7 @@ static void Skin3_OnChange(void) return; // do whatever you want if (CanChangeSkin(displayplayers[2]) && !P_PlayerMoving(displayplayers[2])) - SendNameAndColor3(); + SendNameAndColor(2); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); @@ -5853,7 +5515,7 @@ static void Skin4_OnChange(void) return; // do whatever you want if (CanChangeSkin(displayplayers[3]) && !P_PlayerMoving(displayplayers[3])) - SendNameAndColor4(); + SendNameAndColor(3); else { CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); @@ -5966,7 +5628,7 @@ static void Color_OnChange(void) if (!P_PlayerMoving(consoleplayer)) { // Color change menu scrolling fix is no longer necessary - SendNameAndColor(); + SendNameAndColor(0); } else { @@ -5988,7 +5650,7 @@ static void Color2_OnChange(void) if (!P_PlayerMoving(displayplayers[1])) { // Color change menu scrolling fix is no longer necessary - SendNameAndColor2(); + SendNameAndColor(1); } else { @@ -6005,7 +5667,7 @@ static void Color3_OnChange(void) if (!P_PlayerMoving(displayplayers[2])) { // Color change menu scrolling fix is no longer necessary - SendNameAndColor3(); + SendNameAndColor(2); } else { @@ -6022,7 +5684,7 @@ static void Color4_OnChange(void) if (!P_PlayerMoving(displayplayers[3])) { // Color change menu scrolling fix is no longer necessary - SendNameAndColor4(); + SendNameAndColor(3); } else { diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 6b7382403..f22fe33a8 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -21,10 +21,7 @@ extern "C" { #include "command.h" -void SendWeaponPref(void); -void SendWeaponPref2(void); -void SendWeaponPref3(void); -void SendWeaponPref4(void); +void SendWeaponPref(UINT8 splitplayer); // console vars extern consvar_t cv_playername; @@ -295,7 +292,7 @@ typedef union { // add game commands, needs cleanup void D_RegisterServerCommands(void); void D_RegisterClientCommands(void); -void D_SendPlayerConfig(void); +void D_SendPlayerConfig(UINT8 splitplayer); void Command_ExitGame_f(void); void Command_Retry_f(void); void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore diff --git a/src/r_main.cpp b/src/r_main.cpp index 1ad8e8be9..fe9edc9eb 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -277,22 +277,22 @@ static void Fov_OnChange(void) static void FlipCam_OnChange(void) { - SendWeaponPref(); + SendWeaponPref(0); } static void FlipCam2_OnChange(void) { - SendWeaponPref2(); + SendWeaponPref(1); } static void FlipCam3_OnChange(void) { - SendWeaponPref3(); + SendWeaponPref(2); } static void FlipCam4_OnChange(void) { - SendWeaponPref4(); + SendWeaponPref(3); } static void Precipstuff_OnChange(void) From c680dd3222667b4f948d0c01a05925e65b63f63a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 2 Dec 2025 20:24:39 +0100 Subject: [PATCH 003/589] fix some packet types not being correctly handled --- src/d_clisrv.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ccb8d092b..f622b4802 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5994,6 +5994,9 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_CLIENTQUIT: PT_ClientQuit(netconsole, node); break; + case PT_SERVERINFO: + PT_ServerInfo(node); + break; case PT_RESYNCHGET: SV_AcknowledgeResynchAck(node, netbuffer->u.resynchgot); break; @@ -6024,6 +6027,12 @@ static void HandlePacketFromPlayer(SINT8 node) is_client_saturn[node] = true; break; #endif + case PT_CLIENTJOIN: + PT_ClientJoin(node); + break; + case PT_SERVERSHUTDOWN: + PT_ServerShutdown(node); + break; case PT_RESYNCHING: PT_Resynching(node); break; From e83e2659a7567cf219c4d9ff0b86b3e31a470402 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 2 Dec 2025 21:50:44 +0100 Subject: [PATCH 004/589] reorder packets again --- src/d_clisrv.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f622b4802..5d1566f47 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4804,7 +4804,6 @@ static void PT_ClientJoin(SINT8 node) } } - #ifdef SATURNJOIN const boolean issaturn = (((doomcom->datalength) == sizeof(clientconfig_pak)) && netbuffer->u.clientcfg.issaturn == ISSATURN); // Check the packet lenght to skip potential garbo data! #endif @@ -5425,19 +5424,17 @@ static void HandlePacketFromAwayNode(SINT8 node) case PT_NEEDMAPICON: PT_NeedMapIcon(node); break; - case PT_CLIENTJOIN: - PT_ClientJoin(node); - break; case PT_SERVERSHUTDOWN: PT_ServerShutdown(node); break; - + case PT_CLIENTJOIN: + PT_ClientJoin(node); + break; case PT_SERVERTICS: // Do not remove my own server (we have just get a out of order packet) if (node == servernode) break; /* FALLTHRU */ - default: DEBFILE(va("unknown packet received (%d) from unknown host\n", netbuffer->packettype)); Net_CloseConnection(node); @@ -5994,6 +5991,14 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_CLIENTQUIT: PT_ClientQuit(netconsole, node); break; +#ifdef SATURNPAK + case PT_CANRECEIVEGAMESTATE: + PT_CanReceiveGamestate(node); + break; + case PT_RECEIVEDGAMESTATE: + PT_ReceivedGamestate(node); + break; +#endif case PT_SERVERINFO: PT_ServerInfo(node); break; @@ -6007,18 +6012,11 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_PING: PT_Ping(node); break; - case PT_SERVERCFG: - break; + case PT_FILEFRAGMENT: PT_FileFragmentFromPlayer(node); break; #ifdef SATURNPAK - case PT_CANRECEIVEGAMESTATE: - PT_CanReceiveGamestate(node); - break; - case PT_RECEIVEDGAMESTATE: - PT_ReceivedGamestate(node); - break; case PT_WILLRESENDGAMESTATE: PT_WillResendGamestate(); break; @@ -6027,12 +6025,14 @@ static void HandlePacketFromPlayer(SINT8 node) is_client_saturn[node] = true; break; #endif - case PT_CLIENTJOIN: - PT_ClientJoin(node); - break; case PT_SERVERSHUTDOWN: PT_ServerShutdown(node); break; + case PT_SERVERCFG: + break; + case PT_CLIENTJOIN: + PT_ClientJoin(node); + break; case PT_RESYNCHING: PT_Resynching(node); break; From 265f4a50ef6eb414572d16096cf50c1f837b6a7f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 2 Dec 2025 22:04:18 +0100 Subject: [PATCH 005/589] readd check for node before SV_SendSaveGame Apparently in some cases the server will connect to itself, in this case the server tries to send itself the savegame, leading to a crash in some cases. oops --- src/d_clisrv.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5d1566f47..a7745242d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4781,7 +4781,7 @@ static size_t TotalTextCmdPerTic(tic_t tic) static void PT_ClientJoin(SINT8 node) { // Ignore duplicate packets - if (client || nodeingame[node]|| levelloading) + if (client || nodeingame[node] || levelloading) return; doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); @@ -4917,8 +4917,11 @@ static void PT_ClientJoin(SINT8 node) if (nodewaiting[node]) { - SV_SendSaveGame(node, false); // send a complete game state - DEBFILE("send savegame\n"); + if (node) + { + SV_SendSaveGame(node, false); // send a complete game state + DEBFILE("send savegame\n"); + } SV_AddWaitingPlayers(node); } From f49e57a38c29e845e62032528a1e01a08ea1988f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 2 Dec 2025 23:16:35 +0100 Subject: [PATCH 006/589] d_cliserv: Cleanup PT_ClientJoin move refuse message handling into its own function --- src/d_clisrv.c | 168 +++++++++++++++++++++++++++---------------------- 1 file changed, 92 insertions(+), 76 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a7745242d..653dae05e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4746,17 +4746,6 @@ void SV_StartSinglePlayerServer(void) multiplayer = true; } -static void SV_SendRefuse(INT32 node, const char *reason) -{ - doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); - - strcpy(netbuffer->u.serverrefuse.reason, reason); - - netbuffer->packettype = PT_SERVERREFUSE; - HSendPacket(node, false, 0, strlen(netbuffer->u.serverrefuse.reason) + 1); - Net_CloseConnection(node); -} - // used at txtcmds received to check packetsize bound static size_t TotalTextCmdPerTic(tic_t tic) { @@ -4773,19 +4762,25 @@ static size_t TotalTextCmdPerTic(tic_t tic) return total; } -/** Called when a PT_CLIENTJOIN packet is received - * - * \param node The packet sender - * - */ -static void PT_ClientJoin(SINT8 node) +static void SV_SendRefuse(INT32 node, const char *reason) { - // Ignore duplicate packets - if (client || nodeingame[node] || levelloading) - return; - doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); + strcpy(netbuffer->u.serverrefuse.reason, reason); + + netbuffer->packettype = PT_SERVERREFUSE; + HSendPacket(node, false, 0, strlen(netbuffer->u.serverrefuse.reason) + 1); + Net_CloseConnection(node); +} + +static const char *GetRefuseMessage(SINT8 node) +{ + doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); + clientconfig_pak *cc = &netbuffer->u.clientcfg; + + if (!node) /* server connecting to itself */ + return NULL; + // Sal: Dedicated mode is INCREDIBLY hacked together. // If a server filled out, then it'd overwrite the host and turn everyone into weird husks..... // It's too much effort to legimately fix right now. Just prevent it from reaching that state. @@ -4805,7 +4800,7 @@ static void PT_ClientJoin(SINT8 node) } #ifdef SATURNJOIN - const boolean issaturn = (((doomcom->datalength) == sizeof(clientconfig_pak)) && netbuffer->u.clientcfg.issaturn == ISSATURN); // Check the packet lenght to skip potential garbo data! + const boolean issaturn = (((doomcom->datalength) == sizeof(clientconfig_pak)) && (cc->issaturn == ISSATURN)); // Check the packet length to skip garbo data! #endif if (bannednode && bannednode[node].banid != SIZE_MAX) @@ -4818,47 +4813,44 @@ static void PT_ClientJoin(SINT8 node) if (bannednode[node].timeleft != NO_BAN_TIME) { - // these are fudged a little to allow it to sink in for impatient rejoiners + // these are fudged a little to allow it to sink in for impatient rejoiners int minutes = (bannednode[node].timeleft + 30) / 60; int hours = (minutes + 1) / 60; int days = (hours + 1) / 24; if (days) { - SV_SendRefuse(node, va("K|%s\n(Time remaining: %d day%s)", reason, days, days > 1 ? "s" : "")); + return va("K|%s\n(Time remaining: %d day%s)", reason, days, days > 1 ? "s" : ""); } else if (hours) { - SV_SendRefuse(node, va("K|%s\n(Time remaining: %d hour%s)", reason, hours, hours > 1 ? "s" : "")); + return va("K|%s\n(Time remaining: %d hour%s)", reason, hours, hours > 1 ? "s" : ""); } else if (minutes) { - SV_SendRefuse(node, va("K|%s\n(Time remaining: %d minute%s)", reason, minutes, minutes > 1 ? "s" : "")); + return va("K|%s\n(Time remaining: %d minute%s)", reason, minutes, minutes > 1 ? "s" : ""); } else { - SV_SendRefuse(node, va("K|%s\n(Time remaining: <1 minute)", reason)); + return va("K|%s\n(Time remaining: <1 minute)", reason); } } else { - SV_SendRefuse(node, va("B|%s", reason)); + return va("B|%s", reason); } } - else if (netbuffer->u.clientcfg._255 != 255 || - netbuffer->u.clientcfg.packetversion != PACKETVERSION) + else if (cc->_255 != 255 || cc->packetversion != PACKETVERSION) { - SV_SendRefuse(node, "Incompatible packet formats."); + return "Incompatible packet formats."; } - else if (strncmp(netbuffer->u.clientcfg.application, SRB2APPLICATION, - sizeof netbuffer->u.clientcfg.application)) + else if (strncmp(cc->application, SRB2APPLICATION, sizeof(cc->application))) { - SV_SendRefuse(node, "Different SRB2Kart modifications\nare not compatible."); + return "Different SRB2Kart modifications\nare not compatible."; } - else if (netbuffer->u.clientcfg.version != VERSION - || netbuffer->u.clientcfg.subversion != SUBVERSION) + else if (cc->version != VERSION || cc->subversion != SUBVERSION) { - SV_SendRefuse(node, va("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)", VERSION, SUBVERSION)); + return va("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)", VERSION, SUBVERSION); } #ifdef SATURNJOIN else if (((!cv_allownewplayer.value && !issaturn) || (!cv_allownewsaturnplayer.value && issaturn)) && node) @@ -4866,65 +4858,89 @@ static void PT_ClientJoin(SINT8 node) else if (!cv_allownewplayer.value && node) #endif { - SV_SendRefuse(node, cv_joinrefusemessage.string); + return cv_joinrefusemessage.string; } else if (connectedplayers >= maxplayers) { - SV_SendRefuse(node, va("Maximum players reached: %d", maxplayers)); + return va("Maximum players reached: %d", maxplayers); } - else if (netgame && netbuffer->u.clientcfg.localplayers > 4) // Hacked client? + else if (cc->localplayers != 1) { - SV_SendRefuse(node, "Too many players from\nthis node."); + return "Wrong player count."; } - else if (netgame && connectedplayers + netbuffer->u.clientcfg.localplayers > maxplayers) + else if (netgame && !cc->localplayers) // Stealth join? { - SV_SendRefuse(node, va("Number of local players\nwould exceed maximum: %d", maxplayers)); + return "No players from\nthis node."; } - else if (netgame && !netbuffer->u.clientcfg.localplayers) // Stealth join? + else if (netgame && cc->localplayers > 4) // Hacked client? { - SV_SendRefuse(node, "No players from\nthis node."); + return "Too many players from\nthis node."; } - else + else if (netgame && connectedplayers + cc->localplayers > maxplayers) { - // client authorised to join - nodewaiting[node] = (UINT8)(netbuffer->u.clientcfg.localplayers - playerpernode[node]); + return va("Number of local players\nwould exceed maximum: %d", maxplayers); + } - gamestate_t backupstate = gamestate; + return NULL; +} - SV_AddNode(node); +/** Called when a PT_CLIENTJOIN packet is received + * + * \param node The packet sender + * + */ +static void PT_ClientJoin(SINT8 node) +{ + // Ignore duplicate packets + if (client || nodeingame[node] || levelloading) + return; - /// \note Wait what??? - /// What if the gamestate takes more than one second to get downloaded? - /// Or if a lagspike happens? - // you get a free second before desynch checks. use it wisely. - SV_InitResynchVars(node); + doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); - if (!SV_SendServerConfig(node)) - { - G_SetGamestate(backupstate); - /// \note Shouldn't SV_SendRefuse be called before ResetNode? - SV_SendRefuse(node, "Server couldn't send info, please try again"); - ResetNode(node); // Yeah, lets try it! - /// \todo fix this !!! - return; // restart the while - } + const char *refuse = GetRefuseMessage(node); - SV_SendServerInfo(node, 0); // Dunno if 0 time is good idea - //if (gamestate != GS_LEVEL) // GS_INTERMISSION, etc? - // SV_SendPlayerConfigs(node); // send bare minimum player info + if (refuse) + { + SV_SendRefuse(node, refuse); + return; + } + + // client authorised to join + nodewaiting[node] = (UINT8)(netbuffer->u.clientcfg.localplayers - playerpernode[node]); + + gamestate_t backupstate = gamestate; + + SV_AddNode(node); + + /// \note Wait what??? + /// What if the gamestate takes more than one second to get downloaded? + /// Or if a lagspike happens? + // you get a free second before desynch checks. use it wisely. + SV_InitResynchVars(node); + + if (!SV_SendServerConfig(node)) + { G_SetGamestate(backupstate); - DEBFILE("new node joined\n"); + /// \note Shouldn't SV_SendRefuse be called before ResetNode? + SV_SendRefuse(node, "Server couldn't send info, please try again"); + ResetNode(node); // Yeah, lets try it! + /// \todo fix this !!! + return; // restart the while + } - if (nodewaiting[node]) + SV_SendServerInfo(node, 0); // Dunno if 0 time is good idea + G_SetGamestate(backupstate); + DEBFILE("new node joined\n"); + + if (nodewaiting[node]) + { + if (node) { - if (node) - { - SV_SendSaveGame(node, false); // send a complete game state - DEBFILE("send savegame\n"); - } - - SV_AddWaitingPlayers(node); + SV_SendSaveGame(node, false); // send a complete game state + DEBFILE("send savegame\n"); } + + SV_AddWaitingPlayers(node); } } From 7eb2ad1e35669293a4a35afd493bcfd967f97032 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 2 Dec 2025 23:20:17 +0100 Subject: [PATCH 007/589] slightly cleanup SV_AddWaitingPlayers --- src/d_clisrv.c | 52 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 653dae05e..1117112cb 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4445,18 +4445,21 @@ static inline void SV_AddNode(INT32 node) // Xcmd XD_ADDPLAYER static void Got_AddPlayer(const UINT8 **p, INT32 playernum) { + UINT8 i; INT16 node, newplayernum; UINT8 splitscreenplayer = 0; - UINT8 i; + player_t *newplayer; if (playernum != serverplayer && !IsPlayerAdmin(playernum)) { // protect against hacked/buggy client CONS_Alert(CONS_WARNING, M_GetText("Illegal add player command received from %s\n"), player_names[playernum]); + if (server) { SendKick(playernum, KICK_MSG_CON_FAIL); } + return; } @@ -4465,14 +4468,19 @@ static void Got_AddPlayer(const UINT8 **p, INT32 playernum) splitscreenplayer = newplayernum/MAXPLAYERS; newplayernum %= MAXPLAYERS; + CONS_Debug(DBG_NETPLAY, "addplayer: %d %d\n", node, newplayernum); + // Clear player before joining, lest some things get set incorrectly CL_ClearPlayer(newplayernum); playeringame[newplayernum] = true; G_AddPlayer(newplayernum); + if (newplayernum+1 > doomcom->numslots) doomcom->numslots = (INT16)(newplayernum+1); + newplayer = &players[newplayernum]; + // the server is creating my player if (node == mynode) { @@ -4483,7 +4491,7 @@ static void Got_AddPlayer(const UINT8 **p, INT32 playernum) displayplayers[splitscreenplayer] = newplayernum; DEBFILE(va("spawning one of my sister number %d\n", splitscreenplayer)); if (splitscreenplayer == 1 && botingame) - players[newplayernum].bot = 1; + newplayer->bot = 1; // do we really want this löl } else { @@ -4493,13 +4501,13 @@ static void Got_AddPlayer(const UINT8 **p, INT32 playernum) DEBFILE("spawning me\n"); } - P_ForceLocalAngle(&players[newplayernum], (angle_t)(players[newplayernum].cmd.angleturn << TICCMD_REDUCE)); + P_ForceLocalAngle(newplayer, (angle_t)(newplayer->cmd.angleturn << TICCMD_REDUCE)); D_SendPlayerConfig(splitscreenplayer); addedtogame = true; } - players[newplayernum].splitscreenindex = splitscreenplayer; + newplayer->splitscreenindex = splitscreenplayer; if (netgame) { @@ -4570,24 +4578,27 @@ static boolean SV_AddWaitingPlayers(SINT8 node) UINT8 newplayernum = 0; boolean newplayer = false; - // What is the reason for this? Why can't newplayernum always be 0? - // Sal: Because the dedicated player is stupidly forced into players[0]..... - if (dedicated) - newplayernum = 1; - // splitscreen can allow 2+ players in one node for (; nodewaiting[node] > 0; nodewaiting[node]--) { newplayer = true; // search for a free playernum - // we can't use playeringame since it is not updated here - for (; newplayernum < MAXPLAYERS; newplayernum++) + // we can't solely use playeringame since it is not updated here + for (newplayernum = dedicated ? 1 : 0; newplayernum < MAXPLAYERS; newplayernum++) { + if (playeringame[newplayernum]) + continue; + for (n = 0; n < MAXNETNODES; n++) - if (nodetoplayer[n] == newplayernum || nodetoplayer2[n] == newplayernum - || nodetoplayer3[n] == newplayernum || nodetoplayer4[n] == newplayernum) + { + if (nodetoplayer[n] == newplayernum || + nodetoplayer2[n] == newplayernum || + nodetoplayer3[n] == newplayernum || + nodetoplayer4[n] == newplayernum) break; + } + if (n == MAXNETNODES) break; } @@ -4596,10 +4607,9 @@ static boolean SV_AddWaitingPlayers(SINT8 node) // before accepting the join I_Assert(newplayernum < MAXPLAYERS); - playernode[newplayernum] = (UINT8)node; - buf[0] = (UINT8)node; buf[1] = newplayernum; + if (playerpernode[node] < 1) { nodetoplayer[node] = newplayernum; @@ -4614,11 +4624,21 @@ static boolean SV_AddWaitingPlayers(SINT8 node) nodetoplayer3[node] = newplayernum; buf[1] += MAXPLAYERS*2; } - else + else if (playerpernode[node] < 4) { nodetoplayer4[node] = newplayernum; buf[1] += MAXPLAYERS*3; } + else + { + // I don't know if it's safe to assert here, + // but I do know this should not be allowed + // to be reached. + return newplayer; + } + + playernode[newplayernum] = (UINT8)node; + playerpernode[node]++; SendNetXCmd(XD_ADDPLAYER, &buf, 2); From 3996abef3638dfb09c86021254a876bd7133b32e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 4 Dec 2025 18:55:05 +0100 Subject: [PATCH 008/589] convert w_wad to ceepeepee prep for smth i might try --- src/Sourcefile | 2 +- src/console.h | 8 ++ src/dehacked.h | 9 ++ src/lzf.h | 8 ++ src/md5.h | 8 ++ src/{w_wad.c => w_wad.cpp} | 190 +++++++++++++++++++------------------ src/w_wad.h | 2 +- 7 files changed, 134 insertions(+), 93 deletions(-) rename src/{w_wad.c => w_wad.cpp} (90%) diff --git a/src/Sourcefile b/src/Sourcefile index 761806e6b..cd5a44c86 100644 --- a/src/Sourcefile +++ b/src/Sourcefile @@ -45,7 +45,7 @@ st_stuff.c string.c tables.c v_video.c -w_wad.c +w_wad.cpp y_inter.c z_zone.cpp r_bsp.cpp diff --git a/src/console.h b/src/console.h index a16ef47b6..3292bc6e3 100644 --- a/src/console.h +++ b/src/console.h @@ -13,6 +13,10 @@ #ifndef __CONSOLE__ #define __CONSOLE__ +#ifdef __cplusplus +extern "C" { +#endif + #include "d_event.h" #include "command.h" #include "i_threads.h" @@ -63,4 +67,8 @@ boolean CON_Ready(void); void CON_LogMessage(const char *msg); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/dehacked.h b/src/dehacked.h index eb22c5f6a..0db20ee56 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -13,6 +13,10 @@ #ifndef __DEHACKED_H__ #define __DEHACKED_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include "m_fixed.h" // for get_number #include "info.h" @@ -71,4 +75,9 @@ typedef struct } MYFILE; #define myfeof(a) (a->data + a->size <= a->curpos) char *myfgets(char *buf, size_t bufsize, MYFILE *f); + +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/lzf.h b/src/lzf.h index 85daf255e..995e4ebd6 100644 --- a/src/lzf.h +++ b/src/lzf.h @@ -13,6 +13,10 @@ #define LZF_H #include +#ifdef __cplusplus +extern "C" { +#endif + /*********************************************************************** ** ** lzf -- an extremely fast/free compression/decompression-method @@ -71,5 +75,9 @@ size_t lzf_decompress (const void *const in_data, size_t in_len, void *out_data, size_t out_len); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/src/md5.h b/src/md5.h index f09d865ab..85384c479 100644 --- a/src/md5.h +++ b/src/md5.h @@ -16,6 +16,10 @@ #ifndef _MD5_H #define _MD5_H 1 +#ifdef __cplusplus +extern "C" { +#endif + #include #if defined (HAVE_LIMITS_H) || (defined (_LIBC) && _LIBC) || defined (_WIN32) @@ -52,4 +56,8 @@ int md5_stream(FILE *stream, void *resblock) THROWFUNC; digest. */ extern void *md5_buffer(const char *buffer, size_t len, void *resblock) THROWFUNC; +#ifdef __cplusplus +} // extern "C" +#endif + #endif /* md5.h */ diff --git a/src/w_wad.c b/src/w_wad.cpp similarity index 90% rename from src/w_wad.c rename to src/w_wad.cpp index 640ee0367..114e5c77c 100644 --- a/src/w_wad.c +++ b/src/w_wad.cpp @@ -257,7 +257,7 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) lumpinfo_t *lump_p = &wadfiles[wadnum]->lumpinfo[posStart]; size_t length = len + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name - char *name = malloc(length + 1); + char *name = static_cast(malloc(length + 1)); if (!name) I_Error("W_LoadDehackedLumpsPK3: Out of memory!\n"); @@ -293,7 +293,7 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) if (memcmp(lump_p->name, "SOC_", 4) == 0) // Check for generic SOC lump { // shameless copy+paste of code from LUA_LoadLump size_t length = len + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name - char *name = malloc(length + 1); + char *name = static_cast(malloc(length + 1)); if (!name) I_Error("W_LoadDehackedLumps: Out of memory!\n"); @@ -389,24 +389,24 @@ static restype_t ResourceFileDetect(const char* filename) */ static lumpinfo_t* ResGetLumpsStandalone(FILE* handle, UINT16* numlumps, const char* lumpname) { - lumpinfo_t* lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL); + lumpinfo_t* lumpinfo = static_cast(Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL)); lumpinfo->position = 0; fseek(handle, 0, SEEK_END); - lumpinfo->size = ftell(handle); + lumpinfo->size = static_cast(ftell(handle)); fseek(handle, 0, SEEK_SET); strlcpy(lumpinfo->name, lumpname, sizeof(lumpinfo->name)); lumpinfo->namelength = strlen(lumpinfo->name); lumpinfo->hash.name = W_HashLumpName(lumpname); // Allocate the lump's long name. - lumpinfo->longname = Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL); + lumpinfo->longname = static_cast(Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL)); strcpy(lumpinfo->longname, lumpname); lumpinfo->longname[lumpinfo->namelength] = '\0'; lumpinfo->longnamelength = lumpinfo->namelength; lumpinfo->hash.longname = lumpinfo->hash.name; // Allocate the lump's full name. - lumpinfo->fullname = Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL); + lumpinfo->fullname = static_cast(Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL)); strcpy(lumpinfo->fullname, lumpname); lumpinfo->fullname[lumpinfo->namelength] = '\0'; lumpinfo->fullnamelength = lumpinfo->namelength; @@ -454,7 +454,7 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena // read wad file directory i = header.numlumps * sizeof (*fileinfo); - fileinfov = fileinfo = malloc(i); + fileinfov = fileinfo = static_cast(malloc(i)); if (fseek(handle, header.infotableofs, SEEK_SET) == -1 || fread(fileinfo, 1, i, handle) < i) @@ -466,7 +466,7 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena numlumps = header.numlumps; // fill in lumpinfo for this wad - lump_p = lumpinfo = Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL); + lump_p = lumpinfo = static_cast(Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL)); for (i = 0; i < numlumps; i++, lump_p++, fileinfo++) { @@ -510,14 +510,14 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena lump_p->hash.name = W_HashLumpName(lump_p->name); // Allocate the lump's long name. - lump_p->longname = Z_Malloc(9 * sizeof(char), PU_STATIC, NULL); + lump_p->longname = static_cast(Z_Malloc(9 * sizeof(char), PU_STATIC, NULL)); strncpy(lump_p->longname, fileinfo->name, 8); lump_p->longname[8] = '\0'; lump_p->longnamelength = lump_p->namelength; lump_p->hash.longname = lump_p->hash.name; // Allocate the lump's full name. - lump_p->fullname = Z_Malloc(9 * sizeof(char), PU_STATIC, NULL); + lump_p->fullname = static_cast(Z_Malloc(9 * sizeof(char), PU_STATIC, NULL)); strncpy(lump_p->fullname, fileinfo->name, 8); lump_p->fullname[8] = '\0'; lump_p->fullnamelength = lump_p->namelength; @@ -538,24 +538,24 @@ static boolean ResFindSignature(FILE* handle, const char endPat[], UINT32 startp int c; fseek(handle, 0, SEEK_END); - size_t len = ftell(handle); + size_t len = static_cast(ftell(handle)); fseek(handle, startpos, SEEK_SET); - size_t remaining = len - startpos; - size_t chunkpos = startpos; + size_t remaining = static_cast(len - startpos); + size_t chunkpos = static_cast(startpos); s = endPat; //128k buffers - size_t buffer_size = min(128 * 1024 * sizeof(char), remaining); - CLEANUP(pfree) char* buffer = (char*)(malloc(buffer_size)); + size_t buffer_size = std::min(128 * 1024 * sizeof(char), remaining); + CLEANUP(pfree) char* buffer = static_cast(malloc(buffer_size)); size_t bytes_read = 0; while ((bytes_read = fread(buffer, 1, buffer_size, handle)) > 0) { for (size_t i = 0; i < bytes_read; i++) { - c = (int)buffer[i]; + c = static_cast(buffer[i]); if (*s != c && s > endPat) // No match? s = endPat; // We "reset" the counter by sending the s pointer back to the start of the array. @@ -567,7 +567,7 @@ static boolean ResFindSignature(FILE* handle, const char endPat[], UINT32 startp if (*s == 0x00) // The array pointer has reached the key char which marks the end. It means we have matched the signature. { //the original function would leave the FILE* seeked to the end of the match - size_t foundpos = chunkpos + i + 1; + size_t foundpos = static_cast(chunkpos + i + 1); fseek(handle, foundpos, SEEK_SET); return true; } @@ -644,8 +644,8 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) // Contains entry number (number of lumps), and central directory start offset. fseek(handle, 0, SEEK_END); - const long startpos = (ftell(handle) - (22 + 65536)); - if (!ResFindSignature(handle, pat_end, max(0l, startpos))) + const long startpos = ftell(handle) - (22 + 65536); + if (!ResFindSignature(handle, pat_end, std::max(0l, startpos))) { CONS_Alert(CONS_ERROR, "Missing central directory\n"); return NULL; @@ -660,11 +660,11 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) numlumps = SHORT(zend.entries); - lump_p = lumpinfo = Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL); + lump_p = lumpinfo = static_cast(Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL)); fseek(handle, LONG(zend.cdiroffset), SEEK_SET); - CLEANUP(Z_Pfree) char *cdir = Z_Malloc(LONG(zend.cdirsize), PU_STATIC, &cdir); + CLEANUP(Z_Pfree) char *cdir = static_cast(Z_Malloc(LONG(zend.cdirsize), PU_STATIC, &cdir)); if (fread(cdir, 1, LONG(zend.cdirsize), handle) < (UINT32)(LONG(zend.cdirsize))) { @@ -677,7 +677,7 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) for (i = 0; i < numlumps; i++, lump_p++) { - zentry_t *zentry = (zentry_t*)(cdir + offset); + zentry_t *zentry = reinterpret_cast(cdir + offset); char* fullname; char* trimname; char* dotpos; @@ -693,8 +693,8 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) lump_p->disksize = LONG(zentry->compsize); lump_p->size = LONG(zentry->size); - fullname = (char*)(malloc(SHORT(zentry->namelen) + 1)); - strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); + fullname = static_cast(malloc(SHORT(zentry->namelen) + 1)); + strlcpy(fullname, reinterpret_cast(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != 0) @@ -706,16 +706,16 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lump_p->name, '\0', 9); // Making sure they're initialized to 0. Is it necessary? - strncpy(lump_p->name, trimname, min(8, dotpos - trimname)); + strncpy(lump_p->name, trimname, std::min(8, dotpos - trimname)); lump_p->namelength = strlen(lump_p->name); lump_p->hash.name = W_HashLumpName(lump_p->name); - lump_p->longname = Z_Calloc(dotpos - trimname + 1, PU_STATIC, NULL); + lump_p->longname = static_cast(Z_Calloc(dotpos - trimname + 1, PU_STATIC, NULL)); strlcpy(lump_p->longname, trimname, dotpos - trimname + 1); lump_p->longnamelength = strlen(lump_p->longname); lump_p->hash.longname = W_HashLumpName(lump_p->longname); - lump_p->fullname = (char*)(Z_Calloc(SHORT(zentry->namelen) + 1, PU_STATIC, NULL)); + lump_p->fullname = static_cast(Z_Calloc(SHORT(zentry->namelen) + 1, PU_STATIC, NULL)); strncpy(lump_p->fullname, fullname, SHORT(zentry->namelen)); lump_p->fullnamelength = zentry->namelen; lump_p->hash.fullname = W_HashLumpName(lump_p->fullname); @@ -893,14 +893,14 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup) // // link wad file to search files // - wadfile = Z_Calloc(sizeof (*wadfile), PU_STATIC, NULL); + wadfile = static_cast(Z_Calloc(sizeof (*wadfile), PU_STATIC, NULL)); wadfile->filename = Z_StrDup(filename); wadfile->handle = handle; - wadfile->numlumps = (UINT16)numlumps; + wadfile->numlumps = static_cast(numlumps); wadfile->lumpinfo = lumpinfo; wadfile->important = important; fseek(handle, 0, SEEK_END); - wadfile->filesize = (unsigned)ftell(handle); + wadfile->filesize = static_cast(ftell(handle)); wadfile->type = type; wadfile->startfolders = M_AATreeAlloc(AATREE_STRING); wadfile->endfolders = M_AATreeAlloc(AATREE_STRING); @@ -928,7 +928,7 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup) #ifdef HWRENDER // Read shaders from file if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) - HWR_LoadCustomShadersFromFile(numwadfiles - 1, (type == RET_PK3)); + HWR_LoadCustomShadersFromFile(numwadfiles - 1, static_cast(type == RET_PK3)); #endif // TODO: HACK ALERT - Load Lua & SOC stuff right here. I feel like this should be out of this place, but... Let's stick with this for now. @@ -1028,7 +1028,7 @@ INT32 W_AddAutoloadedLocalFiles(char **filenames) /** Make sure a lump number is valid. * Compiles away to nothing if PARANOIA is not defined. */ -static boolean TestValidLump(UINT16 wad, UINT16 lump) +static inline boolean TestValidLump(UINT16 wad, UINT16 lump) { I_Assert(wad < MAX_WADFILES); if (!wadfiles[wad]) // make sure the wad file exists @@ -1051,7 +1051,7 @@ const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump) const char *W_CheckNameForNum(lumpnum_t lumpnum) { - return W_CheckNameForNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum)); + return W_CheckNameForNumPwad(WADFILENUM(lumpnum), LUMPNUM(lumpnum)); } // @@ -1142,9 +1142,11 @@ UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump) UINT16 W_CheckNumForMarkerStartPwad(const char *name, UINT16 wad, UINT16 startlump) { UINT16 marker; + marker = W_CheckNumForNamePwad(name, wad, startlump); if (marker != INT16_MAX) marker++; // Do not count the first marker + return marker; } @@ -1152,13 +1154,13 @@ UINT16 W_CheckNumForMarkerStartPwad(const char *name, UINT16 wad, UINT16 startlu UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlump) { size_t name_length; - INT32 i; + UINT16 i; lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; name_length = strlen(name); void *val = M_AATreeGetString(wadfiles[wad]->startfolders, name); if (val != NULL) - return (uintptr_t)val; + return static_cast(reinterpret_cast(val)); for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++) { @@ -1168,12 +1170,12 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum if (strlen(lump_p->fullname) == name_length) i++; - M_AATreeSetString(wadfiles[wad]->startfolders, name, (void *)(uintptr_t)i); + M_AATreeSetString(wadfiles[wad]->startfolders, name, reinterpret_cast(static_cast(i))); return i; } } - M_AATreeSetString(wadfiles[wad]->startfolders, name, (void *)INT16_MAX); + M_AATreeSetString(wadfiles[wad]->startfolders, name, reinterpret_cast(INT16_MAX)); return INT16_MAX; } @@ -1182,13 +1184,13 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum // Returns the position of the lumpinfo entry. UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump) { - INT32 i; + UINT16 i; lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; size_t name_length = strlen(name); void *val = M_AATreeGetString(wadfiles[wad]->endfolders, name); if (val != NULL) - return (uintptr_t)val; + return static_cast(reinterpret_cast(val)); for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++) { @@ -1196,7 +1198,7 @@ UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump) break; } - M_AATreeSetString(wadfiles[wad]->endfolders, name, (void *)(uintptr_t)i); + M_AATreeSetString(wadfiles[wad]->endfolders, name, reinterpret_cast(static_cast(i))); return i; } @@ -1204,7 +1206,7 @@ UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump) // Returns lump position in PK3's lumpinfo, or INT16_MAX if not found. UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump) { - INT32 i; + UINT16 i; lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; size_t name_length = strlen(name); @@ -1297,7 +1299,7 @@ lumpnum_t W_CheckNumForName(const char *name) // scan wad files backwards so patch lump files take precedence for (i = numwadfiles - 1; i >= 0; i--) { - check = W_CheckNumForNamePwad(name, (UINT16)i, 0); + check = W_CheckNumForNamePwad(name, static_cast(i), 0); if (check != INT16_MAX) break; //found it @@ -1339,7 +1341,7 @@ lumpnum_t W_CheckNumForLongName(const char *name) // scan wad files backwards so patch lump files take precedence for (i = numwadfiles - 1; i >= 0; i--) { - check = W_CheckNumForLongNamePwad(name, (UINT16)i, 0); + check = W_CheckNumForLongNamePwad(name, static_cast(i), 0); if (check != INT16_MAX) break; //found it @@ -1409,25 +1411,27 @@ lumpnum_t W_CheckNumForNameInBlock(const char *name, const char *blockstart, con { if (wadfiles[i]->type == RET_WAD) { - bsid = W_CheckNumForNamePwad(blockstart, (UINT16)i, 0); + bsid = W_CheckNumForNamePwad(blockstart, static_cast(i), 0); if (bsid == INT16_MAX) continue; // Start block doesn't exist? - beid = W_CheckNumForNamePwad(blockend, (UINT16)i, 0); + beid = W_CheckNumForNamePwad(blockend, static_cast(i), 0); if (beid == INT16_MAX) continue; // End block doesn't exist? - check = W_CheckNumForNamePwad(name, (UINT16)i, bsid); + check = W_CheckNumForNamePwad(name, static_cast(i), bsid); if (check < beid) - return (i<<16)+check; // found it, in our constraints + return (i << 16)+check; // found it, in our constraints } } + return LUMPERROR; } // Used by Lua. Case sensitive lump checking, quickly... UINT8 W_LumpExists(const char *name) { - INT32 i,j; + INT32 i, j; + for (i = numwadfiles - 1; i >= 0; i--) { lumpinfo_t *lump_p = wadfiles[i]->lumpinfo; @@ -1435,6 +1439,7 @@ UINT8 W_LumpExists(const char *name) if (fastcmp(lump_p->name, name)) return true; } + return false; } @@ -1594,13 +1599,13 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si fseek(handle, (long)(l->position + offset), SEEK_SET); // But let's not copy it yet. We support different compression formats on lumps, so we need to take that into account. - switch(wadfiles[wad]->lumpinfo[lump].compression) + switch (wadfiles[wad]->lumpinfo[lump].compression) { case CM_NOCOMPRESSION: // If it's uncompressed, we directly write the data into our destination, and return the bytes read. #ifdef NO_PNG_LUMPS { size_t bytesread = fread(dest, 1, size, handle); - ErrorIfPNG((UINT8 *)dest, bytesread, wadfiles[wad]->filename, l->fullname); + ErrorIfPNG(static_cast(dest), bytesread, wadfiles[wad]->filename, l->fullname); return bytesread; } #else @@ -1613,8 +1618,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si char *decData; // Lump's decompressed real data. size_t retval; // Helper var, lzf_decompress returns 0 when an error occurs. - rawData = Z_Malloc(l->disksize, PU_STATIC, NULL); - decData = Z_Malloc(l->size, PU_STATIC, NULL); + rawData = static_cast(Z_Malloc(l->disksize, PU_STATIC, NULL)); + decData = static_cast(Z_Malloc(l->size, PU_STATIC, NULL)); if (fread(rawData, 1, l->disksize, handle) < l->disksize) I_Error("wad %d, lump %d: cannot read compressed data", wad, lump); @@ -1641,7 +1646,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si Z_Free(rawData); Z_Free(decData); #ifdef NO_PNG_LUMPS - ErrorIfPNG((UINT8 *)dest, size, wadfiles[wad]->filename, l->fullname); + ErrorIfPNG(static_cast(dest), size, wadfiles[wad]->filename, l->fullname); #endif return size; #else @@ -1661,8 +1666,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si unsigned long rawSize = l->disksize; unsigned long decSize = size; - rawData = Z_Malloc(rawSize, PU_STATIC, NULL); - decData = dest; + rawData = static_cast(Z_Malloc(rawSize, PU_STATIC, NULL)); + decData = static_cast(dest); if (fread(rawData, 1, rawSize, handle) < rawSize) I_Error("wad %d, lump %d: cannot read compressed data", wad, lump); @@ -1698,7 +1703,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si Z_Free(rawData); #ifdef NO_PNG_LUMPS - ErrorIfPNG((UINT8 *)dest, size, wadfiles[wad]->filename, l->fullname); + ErrorIfPNG(static_cast(dest), size, wadfiles[wad]->filename, l->fullname); #endif return size; } @@ -1886,7 +1891,7 @@ void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) W_ReadLumpHeaderPwad(wad, lump, lumpdata, 0, 0); dest = Z_Calloc(sizeof(patch_t), tag, &lumpcache[lump]); - Patch_Create((softwarepatch_t*)lumpdata, len, dest); + Patch_Create(static_cast(lumpdata), len, dest); Z_Free(lumpdata); } @@ -1908,7 +1913,7 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) if (!TestValidLump(wad, lump)) return NULL; - patch = (patch_t *)W_CacheSoftwarePatchNumPwad(wad, lump, tag); + patch = static_cast(W_CacheSoftwarePatchNumPwad(wad, lump, tag)); if (patch == NULL) return NULL; @@ -1919,7 +1924,7 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) Patch_CreateGL(patch); #endif - return (void *)patch; + return static_cast(patch); } void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag) @@ -1937,17 +1942,20 @@ void *W_GetCachedPatchNumPwad(UINT16 wad, UINT16 lump) #ifdef ROTSPRITE // Caches a rotsprite for patch rotation. -void *W_GetCachedRotPatchPwad(UINT16 wadnum, UINT16 lumpnum) +void *W_GetCachedRotPatchPwad(UINT16 wad, UINT16 lump) { - lumpcache_t *rotcache = wadfiles[wadnum]->rotcache; + if (!TestValidLump(wad, lump)) + return NULL; - if (!rotcache[lumpnum]) + lumpcache_t *rotcache = wadfiles[wad]->rotcache; + + if (!rotcache[lump]) { rotsprite_t *rspr = RotatedPatch_Create(ROTANGLES); - Z_SetUser(rspr, (void **)(&rotcache[lumpnum])); + Z_SetUser(rspr, static_cast(&rotcache[lump])); } - return (void *)(rotcache[lumpnum]); + return static_cast(rotcache[lump]); } #endif // ROTSPRITE @@ -1960,7 +1968,7 @@ void W_UnlockCachedPatch(void *patch) // have different lifetimes from software's. #ifdef HWRENDER if (rendermode == render_opengl) - HWR_UnlockCachedPatch((GLPatch_t *)((patch_t *)patch)->hardware); + HWR_UnlockCachedPatch(static_cast((static_cast(patch))->hardware)); else #endif Z_ChangeTag(patch, PU_PATCH); @@ -1995,13 +2003,13 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag) if (rotationangle < 1 || rotationangle >= ROTANGLES) return W_CachePatchNum(num, tag); - rspr = (rotsprite_t *)W_GetCachedRotPatchPwad(WADFILENUM(num),LUMPNUM(num)); + rspr = static_cast(W_GetCachedRotPatchPwad(WADFILENUM(num), LUMPNUM(num))); if (rspr->patches[idx] == NULL) { INT32 xpivot = 0, ypivot = 0; - ptr = (patch_t *)W_CachePatchNum(num, PU_PATCH); + ptr = static_cast(W_CachePatchNum(num, PU_PATCH)); // >y pivot centered // >x pivot not centered @@ -2192,8 +2200,8 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) fseek(fp, 0, SEEK_END); file_size = ftell(fp); - const long startpos = (file_size - (22 + 65536)); - if (!ResFindSignature(fp, pat_end, max(0l, startpos))) + const long startpos = file_size - (22 + 65536); + if (!ResFindSignature(fp, pat_end, std::max(0l, startpos))) return true; fseek(fp, -4, SEEK_CUR); @@ -2206,7 +2214,7 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) fseek(fp, LONG(zend.cdiroffset), SEEK_SET); - CLEANUP(pfree) char *cdir = (char*)(malloc(LONG(zend.cdirsize))); + CLEANUP(pfree) char *cdir = static_cast(malloc(LONG(zend.cdirsize))); if (fread(cdir, 1, LONG(zend.cdirsize), fp) < (UINT32)(LONG(zend.cdirsize))) { @@ -2217,7 +2225,7 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) for (i = 0; i < numlumps; i++) { - zentry_t *zentry = (zentry_t*)(cdir + offset); + zentry_t *zentry = reinterpret_cast(cdir + offset); char* fullname; char* trimname; char* dotpos; @@ -2229,8 +2237,8 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) if (verified == true) { - fullname = (char*)(malloc(SHORT(zentry->namelen) + 1)); - strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); + fullname = static_cast(malloc(SHORT(zentry->namelen) + 1)); + strlcpy(fullname, reinterpret_cast(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != 0) @@ -2244,7 +2252,7 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? - strncpy(lumpname, trimname, min(8, dotpos - trimname)); + strncpy(lumpname, trimname, std::min(8, dotpos - trimname)); if (!W_VerifyName(lumpname, checklist, status)) verified = false; @@ -2439,8 +2447,8 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) fseek(fp, 0, SEEK_END); file_size = ftell(fp); - const long startpos = (file_size - (22 + 65536)); - if (!ResFindSignature(fp, pat_end, max(0l, startpos))) + const long startpos = file_size - (22 + 65536); + if (!ResFindSignature(fp, pat_end, std::max(0l, startpos))) return true; fseek(fp, -4, SEEK_CUR); @@ -2453,7 +2461,7 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) fseek(fp, LONG(zend.cdiroffset), SEEK_SET); - CLEANUP(pfree) char *cdir = (char*)(malloc(LONG(zend.cdirsize))); + CLEANUP(pfree) char *cdir = static_cast(malloc(LONG(zend.cdirsize))); if (fread(cdir, 1, LONG(zend.cdirsize), fp) < (UINT32)(LONG(zend.cdirsize))) { @@ -2464,7 +2472,7 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) for (i = 0; i < numlumps; i++) { - zentry_t *zentry = (zentry_t*)(cdir + offset); + zentry_t *zentry = reinterpret_cast(cdir + offset); CLEANUP(pfree) char* fullname = NULL; char* trimname; char* dotpos; @@ -2474,8 +2482,8 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) return false; } - fullname = (char*)(malloc(SHORT(zentry->namelen) + 1)); - strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); + fullname = static_cast(malloc(SHORT(zentry->namelen) + 1)); + strlcpy(fullname, reinterpret_cast(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != 0) @@ -2489,7 +2497,7 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? - strncpy(lumpname, trimname, min(8, dotpos - trimname)); + strncpy(lumpname, trimname, std::min(8, dotpos - trimname)); if (W_NameStartsWith(lumpname, checklist)) { @@ -2611,15 +2619,15 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) size_t *vsizecache; // Remember that we're assuming that the WAD will have a specific set of lumps in a specific order. - UINT8 *wadData = (UINT8*)(W_CacheLumpNum(lumpnum, PU_LEVEL)); - filelump_t *fileinfo = (filelump_t *)(wadData + LONG(((wadinfo_t *)wadData)->infotableofs)); + UINT8 *wadData = static_cast(W_CacheLumpNum(lumpnum, PU_LEVEL)); + filelump_t *fileinfo = reinterpret_cast(wadData + LONG((reinterpret_cast(wadData))->infotableofs)); - i = LONG(((wadinfo_t *)wadData)->numlumps); - vsizecache = (size_t*)(Z_Malloc(sizeof(size_t)*i, PU_LEVEL, NULL)); + i = LONG((reinterpret_cast(wadData))->numlumps); + vsizecache = static_cast(Z_Malloc(sizeof(size_t)*i, PU_LEVEL, NULL)); for (realentry = 0; realentry < i; realentry++) { - vsizecache[realentry] = (size_t)(LONG(((filelump_t *)(fileinfo + realentry))->size)); + vsizecache[realentry] = static_cast(LONG((reinterpret_cast(fileinfo + realentry))->size)); if (!vsizecache[realentry]) continue; @@ -2627,7 +2635,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) numlumps++; } - vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL)); + vlumps = static_cast(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL)); // Build the lumps, skipping over empty entries. for (i = 0, realentry = 0; i < numlumps; realentry++) @@ -2647,7 +2655,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) // Play it safe with the name in this case. memcpy(vlumps[i].name, name, 8); vlumps[i].name[8] = '\0'; - vlumps[i].data = (UINT8*)( + vlumps[i].data = static_cast( Z_Malloc(vlumps[i].size, PU_LEVEL, NULL) // This is memory inefficient, sorry about that. ); memcpy(vlumps[i].data, wadData + LONG((fileinfo + realentry)->filepos), vlumps[i].size); @@ -2670,7 +2678,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) } numlumps++; - vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL)); + vlumps = static_cast(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL)); for (i = 0; i < numlumps; i++, lumpnum++) { // Check if it is map marker. It is not always first lump sadly, so we need to expect it anywhere @@ -2686,11 +2694,11 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) vlumps[i].size = W_LumpLength(lumpnum); memcpy(vlumps[i].name, name, 8); vlumps[i].name[8] = '\0'; - vlumps[i].data = (UINT8*)(W_CacheLumpNum(lumpnum, PU_LEVEL)); + vlumps[i].data = static_cast(W_CacheLumpNum(lumpnum, PU_LEVEL)); } } - vres = (virtres_t*)(Z_Malloc(sizeof(virtres_t), PU_LEVEL, NULL)); + vres = static_cast(Z_Malloc(sizeof(virtres_t), PU_LEVEL, NULL)); vres->vlumps = vlumps; vres->numlumps = numlumps; diff --git a/src/w_wad.h b/src/w_wad.h index 6240c31f3..9122df1b7 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -233,7 +233,7 @@ void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag); void *W_CacheSoftwarePatchNum(lumpnum_t lumpnum, INT32 tag); #ifdef ROTSPRITE -void *W_GetCachedRotPatchPwad(UINT16 wadnum, UINT16 lumpnum); // Get patch-based rotsprites from the cache. +void *W_GetCachedRotPatchPwad(UINT16 wad, UINT16 lump); // Get patch-based rotsprites from the cache. void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag); #endif From 699113fb25cdc4462de7e181b3e659c7d34e5d91 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 4 Dec 2025 20:31:54 +0100 Subject: [PATCH 009/589] w_wad: replace lumpnumcache with unordered_map hash lookup needs testing if actually better but the old lumpnumcache was basically useless due to being incredibly small even just booting up the game we have around 1000 entries already this hopefully should still be faster than potentially going through ALL lumps in ALL wads we have loaded to find the lumpnums not sure if longnames should get any special handling like before, but i dont think it really matters if theyre long honestly thanks ceepeepeereference for the basis of this --- src/w_wad.cpp | 97 ++++++++++++++++++--------------------------------- 1 file changed, 34 insertions(+), 63 deletions(-) diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 114e5c77c..3adf929a8 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -87,18 +87,32 @@ typedef struct } lumpchecklist_t; // Must be a power of two -#define LUMPNUMCACHESIZE 64 +#define LUMPNUMCACHESIZE 2048 // should be reasonable ig #define LUMPNUMCACHENAME 32 -typedef struct lumpnum_cache_s -{ - char lumpname[LUMPNUMCACHENAME]; - lumpnum_t lumpnum; - UINT32 hash; -} lumpnum_cache_t; +#include +#include +#include -static lumpnum_cache_t lumpnumcache[LUMPNUMCACHESIZE]; -static UINT16 lumpnumcacheindex = 0; +struct LumpnumNameHash +{ + std::size_t operator()(const std::string& str) const + { + // hopefully this is fast enough but should be + return static_cast(quickncasehash(str.c_str(), str.length())); + } +}; + +struct LumpnumStringEquals +{ + bool operator()(const std::string& str1, const std::string& str2) const + { + // fasticmp should be plenty fast and ignores case + return fasticmp(str1.c_str(), str2.c_str()); + } +}; + +static std::unordered_map lumpnumcache(LUMPNUMCACHESIZE); static const char pat_central[] = {0x50, 0x4b, 0x01, 0x02, 0x00}; static const char pat_end[] = {0x50, 0x4b, 0x05, 0x06, 0x00}; @@ -360,7 +374,7 @@ static inline INT32 W_MakeFileMD5(const char *filename, void *resblock) // Invalidates the cache of lump numbers. Call this whenever a wad is added. static void W_InvalidateLumpnumCache(void) { - memset(lumpnumcache, 0, sizeof(lumpnumcache)); + lumpnumcache.clear(); } UINT32 W_HashLumpName(const char *name) @@ -1222,61 +1236,18 @@ UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump) return INT16_MAX; } -static lumpnum_t CheckLumpInCache(const char *name, boolean longname) +static lumpnum_t CheckLumpInCache(const char *name) { - if (longname) - { - UINT32 hash = quickncasehash(name, 32); - - // Loop backwards so that we check most recent entries first - for (INT32 i = lumpnumcacheindex + LUMPNUMCACHESIZE; i > lumpnumcacheindex; i--) - { - if (lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].hash == hash - && fasticmp(lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname, name)) - { - lumpnumcacheindex = i & (LUMPNUMCACHESIZE - 1); - return lumpnumcache[lumpnumcacheindex].lumpnum; - } - } - } - else - { - UINT32 hash = quickncasehash(name, 8); - - // Loop backwards so that we check most recent entries first - for (INT32 i = lumpnumcacheindex + LUMPNUMCACHESIZE; i > lumpnumcacheindex; i--) - { - if (lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].hash == hash - && lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname[8] == '\0' - && strnicmp(lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname, name, 8) == 0) - { - lumpnumcacheindex = i & (LUMPNUMCACHESIZE - 1); - return lumpnumcache[lumpnumcacheindex].lumpnum; - } - } - } + auto it = lumpnumcache.find(name); + if (it != lumpnumcache.end()) + return it->second; return LUMPERROR; } -static void AddLumpToCache(lumpnum_t lumpnum, const char *name, boolean longname) +static void AddLumpToCache(lumpnum_t lumpnum, const char *name) { - if (longname && strlen(name) >= LUMPNUMCACHENAME) - return; - - lumpnumcacheindex = (lumpnumcacheindex + 1) & (LUMPNUMCACHESIZE - 1); - memset(lumpnumcache[lumpnumcacheindex].lumpname, '\0', LUMPNUMCACHENAME); - if (longname) - { - strlcpy(lumpnumcache[lumpnumcacheindex].lumpname, name, LUMPNUMCACHENAME); - lumpnumcache[lumpnumcacheindex].hash = quickncasehash(name, LUMPNUMCACHENAME); - } - else - { - strncpy(lumpnumcache[lumpnumcacheindex].lumpname, name, 8); - lumpnumcache[lumpnumcacheindex].hash = quickncasehash(name, 8); - } - lumpnumcache[lumpnumcacheindex].lumpnum = lumpnum; + lumpnumcache.insert({name, lumpnum}); } // @@ -1292,7 +1263,7 @@ lumpnum_t W_CheckNumForName(const char *name) return LUMPERROR; // Check the lumpnumcache first. - lumpnum_t cachenum = CheckLumpInCache(name, false); + lumpnum_t cachenum = CheckLumpInCache(name); if (cachenum != LUMPERROR) return cachenum; @@ -1313,7 +1284,7 @@ lumpnum_t W_CheckNumForName(const char *name) { // Update the cache. lumpnum_t lumpnum = (i << 16) | check; - AddLumpToCache(lumpnum, name, false); + AddLumpToCache(lumpnum, name); return lumpnum; } @@ -1334,7 +1305,7 @@ lumpnum_t W_CheckNumForLongName(const char *name) return LUMPERROR; // Check the lumpnumcache first. - lumpnum_t cachenum = CheckLumpInCache(name, true); + lumpnum_t cachenum = CheckLumpInCache(name); if (cachenum != LUMPERROR) return cachenum; @@ -1355,7 +1326,7 @@ lumpnum_t W_CheckNumForLongName(const char *name) { // Update the cache. lumpnum_t lumpnum = (i << 16) | check; - AddLumpToCache(lumpnum, name, true); + AddLumpToCache(lumpnum, name); return lumpnum; } From 8091d825d5e942a86d9f25e71faaa52ff04e1bbd Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Dec 2025 13:45:24 +0100 Subject: [PATCH 010/589] w_wad: use our lump fullnamelenght in W_CheckNumForFolderStartPK3 --- src/w_wad.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 3adf929a8..6d0353b98 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -1167,21 +1167,22 @@ UINT16 W_CheckNumForMarkerStartPwad(const char *name, UINT16 wad, UINT16 startlu // Look for the first lump from a folder. UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlump) { - size_t name_length; UINT16 i; + size_t namelen; lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; - name_length = strlen(name); + void *val = M_AATreeGetString(wadfiles[wad]->startfolders, name); if (val != NULL) return static_cast(reinterpret_cast(val)); + namelen = strlen(name); for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++) { - if (strnicmp(name, lump_p->fullname, name_length) == 0) + if (strnicmp(name, lump_p->fullname, namelen) == 0) { /* SLADE is special and puts a single directory entry. Skip that. */ - if (strlen(lump_p->fullname) == name_length) + if (lump_p->fullnamelength == namelen) i++; M_AATreeSetString(wadfiles[wad]->startfolders, name, reinterpret_cast(static_cast(i))); @@ -1199,16 +1200,18 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump) { UINT16 i; + size_t namelen; lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; - size_t name_length = strlen(name); void *val = M_AATreeGetString(wadfiles[wad]->endfolders, name); if (val != NULL) return static_cast(reinterpret_cast(val)); + namelen = strlen(name); + for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++) { - if (strnicmp(name, lump_p->fullname, name_length)) + if (strnicmp(name, lump_p->fullname, namelen)) break; } @@ -1221,12 +1224,14 @@ UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump) UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump) { UINT16 i; + size_t namelen; lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; - size_t name_length = strlen(name); + + namelen = strlen(name); for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++) { - if (!strnicmp(name, lump_p->fullname, name_length)) + if (!strnicmp(name, lump_p->fullname, namelen)) { return i; } From 41c887f2bf5038917a479c9f9de61d8ec800e19c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Dec 2025 13:47:21 +0100 Subject: [PATCH 011/589] w_wad: comment out fullname lump hash for now its unused and not particulary useful eitherway, save us a few hash generates and a struct field lul --- src/w_wad.cpp | 6 +++--- src/w_wad.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 6d0353b98..09d74f993 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -424,7 +424,7 @@ static lumpinfo_t* ResGetLumpsStandalone(FILE* handle, UINT16* numlumps, const c strcpy(lumpinfo->fullname, lumpname); lumpinfo->fullname[lumpinfo->namelength] = '\0'; lumpinfo->fullnamelength = lumpinfo->namelength; - lumpinfo->hash.fullname = lumpinfo->hash.name; + //lumpinfo->hash.fullname = lumpinfo->hash.name; *numlumps = 1; return lumpinfo; @@ -535,7 +535,7 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena strncpy(lump_p->fullname, fileinfo->name, 8); lump_p->fullname[8] = '\0'; lump_p->fullnamelength = lump_p->namelength; - lump_p->hash.fullname = lump_p->hash.name; + //lump_p->hash.fullname = lump_p->hash.name; } *nlmp = numlumps; @@ -732,7 +732,7 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) lump_p->fullname = static_cast(Z_Calloc(SHORT(zentry->namelen) + 1, PU_STATIC, NULL)); strncpy(lump_p->fullname, fullname, SHORT(zentry->namelen)); lump_p->fullnamelength = zentry->namelen; - lump_p->hash.fullname = W_HashLumpName(lump_p->fullname); + //lump_p->hash.fullname = W_HashLumpName(lump_p->fullname); switch(SHORT(zentry->compression)) { diff --git a/src/w_wad.h b/src/w_wad.h index 9122df1b7..b045b9673 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -81,7 +81,7 @@ typedef struct struct { UINT32 name; // hash of name UINT32 longname; // hash of longname - UINT32 fullname; // hash of fullname + //UINT32 fullname; // hash of fullname } hash; } lumpinfo_t; From fd1e41573170ce60dce049aedd981f1e009ddc94 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Dec 2025 14:00:04 +0100 Subject: [PATCH 012/589] w_wad: use unordered map to cache wad start and end folders --- src/w_wad.cpp | 31 ++++++++++++++++++------------- src/w_wad.h | 4 ++-- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 09d74f993..8488fe4d6 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -114,6 +114,11 @@ struct LumpnumStringEquals static std::unordered_map lumpnumcache(LUMPNUMCACHESIZE); +// gotta wrap this in a struct due to external C linkage +struct FolderCache { + std::unordered_map map; +}; + static const char pat_central[] = {0x50, 0x4b, 0x01, 0x02, 0x00}; static const char pat_end[] = {0x50, 0x4b, 0x05, 0x06, 0x00}; @@ -143,8 +148,8 @@ void W_Shutdown(void) Z_Free(wad->lumpinfo[wad->numlumps].fullname); } - M_AATreeFree(wad->startfolders); - M_AATreeFree(wad->endfolders); + delete wad->startfolders; + delete wad->endfolders; Z_Free(wad->lumpinfo); Z_Free(wad); @@ -916,8 +921,8 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup) fseek(handle, 0, SEEK_END); wadfile->filesize = static_cast(ftell(handle)); wadfile->type = type; - wadfile->startfolders = M_AATreeAlloc(AATREE_STRING); - wadfile->endfolders = M_AATreeAlloc(AATREE_STRING); + wadfile->startfolders = new FolderCache(); + wadfile->endfolders = new FolderCache(); // already generated, just copy it over memcpy(&wadfile->md5sum, &md5sum, 16); @@ -1171,10 +1176,10 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum size_t namelen; lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; + auto it = wadfiles[wad]->startfolders->map.find(name); + if (it != wadfiles[wad]->startfolders->map.end()) + return it->second; - void *val = M_AATreeGetString(wadfiles[wad]->startfolders, name); - if (val != NULL) - return static_cast(reinterpret_cast(val)); namelen = strlen(name); for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++) @@ -1185,12 +1190,12 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum if (lump_p->fullnamelength == namelen) i++; - M_AATreeSetString(wadfiles[wad]->startfolders, name, reinterpret_cast(static_cast(i))); + wadfiles[wad]->startfolders->map[name] = i; return i; } } - M_AATreeSetString(wadfiles[wad]->startfolders, name, reinterpret_cast(INT16_MAX)); + wadfiles[wad]->startfolders->map[name] = INT16_MAX; return INT16_MAX; } @@ -1203,9 +1208,9 @@ UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump) size_t namelen; lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; - void *val = M_AATreeGetString(wadfiles[wad]->endfolders, name); - if (val != NULL) - return static_cast(reinterpret_cast(val)); + auto it = wadfiles[wad]->endfolders->map.find(name); + if (it != wadfiles[wad]->endfolders->map.end()) + return it->second; namelen = strlen(name); @@ -1215,7 +1220,7 @@ UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump) break; } - M_AATreeSetString(wadfiles[wad]->endfolders, name, reinterpret_cast(static_cast(i))); + wadfiles[wad]->endfolders->map[name] = i; return i; } diff --git a/src/w_wad.h b/src/w_wad.h index b045b9673..9ed733f78 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -137,8 +137,8 @@ typedef struct wadfile_s #ifdef ROTSPRITE lumpcache_t *rotcache; // Cache rotsprites for rotating patches. #endif - aatree_t *startfolders; - aatree_t *endfolders; + struct FolderCache *startfolders; + struct FolderCache *endfolders; UINT16 numlumps; // this wad's number of resources FILE *handle; UINT32 filesize; // for network From b76ce836a0b0e54c3395707584927cfb78ff3fb1 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Dec 2025 14:51:58 +0100 Subject: [PATCH 013/589] w_wad: optimize W_LumpExists in two parts: - Use our lumpcache lookup first (our unordered map), BUT since it is case insensitive we extract our lump out of it to do another case sensitive name compare - In the manual lump seach falltthrough case, we can also check against the string lenghts and hash (its case insensitive but will still reject differing names, same with stringlenght) this improves the performance of the leaderboard map browser quite a bit and everything else using v.patchExists --- src/w_wad.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 8488fe4d6..27de24789 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -1412,13 +1412,38 @@ lumpnum_t W_CheckNumForNameInBlock(const char *name, const char *blockstart, con UINT8 W_LumpExists(const char *name) { INT32 i, j; + UINT32 hash; + size_t namelen; + + lumpnum_t cachenum = CheckLumpInCache(name); + if (cachenum != LUMPERROR) + { + // ok ok, we did find a lump in our lumpcache BUTT + // the lumpcache map is case insensitive + // extract the lumpinfo out of the lumpnum + // so we can do one more extra case ~sensitive~ name compare + // otherwise we gotta fall through to our manual lump search below + // lumpnum == (wadnum << 16) | lumpinfo id + UINT16 wadnum = (cachenum >> 16) & 0xFFFF; + UINT16 lumpid = cachenum & 0xFFFF; + lumpinfo_t *lump_p = &wadfiles[wadnum]->lumpinfo[lumpid]; + if (fastcmp(lump_p->name, name)) + return true; + } + + namelen = strlen(name); + hash = W_HashLumpName(name); for (i = numwadfiles - 1; i >= 0; i--) { lumpinfo_t *lump_p = wadfiles[i]->lumpinfo; for (j = 0; j < wadfiles[i]->numlumps; ++j, ++lump_p) - if (fastcmp(lump_p->name, name)) + { + if (lump_p->namelength == namelen + && lump_p->hash.name == hash + && fastcmp(lump_p->name, name)) return true; + } } return false; From 3bdc745bd15f5742c41f560c5f7c397bc5ca8a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Sat, 6 Dec 2025 14:05:06 +0100 Subject: [PATCH 014/589] Fix use-after-free when mobj is removed while still playing sounds --- src/p_setup.c | 2 ++ src/s_sound.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index b7b8f03d5..2993bb5d2 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -812,6 +812,8 @@ static void P_LoadSectors(UINT8 *data) ss->tag = SHORT(ms->tag); ss->flags |= SF_FLIPSPECIAL_FLOOR; + + ss->soundorg.thinker.function = (actionf_p1)P_MobjThinker; } // set the sky flat num diff --git a/src/s_sound.c b/src/s_sound.c index 5bc830252..651d579b8 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -772,9 +772,14 @@ void S_UpdateSounds(void) volume = c->volume; // 8 bits internal volume precision sep = NORM_SEP; + if (P_MobjWasRemoved(c->origin)) + { + // origin was removed, stop the music + S_StopChannel(cnum); + } // check non-local sounds for distance clipping // or modify their params - if (c->origin) + else { boolean itsUs = false; From 3f2e0bd3495ed3828ff9beae5967c8bdddb5bb1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Sat, 6 Dec 2025 15:37:02 +0100 Subject: [PATCH 015/589] Fix memory leak in AATree string trees --- src/m_aatree.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/m_aatree.c b/src/m_aatree.c index f78355eaf..7fb847aab 100644 --- a/src/m_aatree.c +++ b/src/m_aatree.c @@ -49,17 +49,19 @@ aatree_t *M_AATreeAlloc(UINT32 flags) return aatree; } -static void M_AATreeFree_Node(aatree_node_t *node) +static void M_AATreeFree_Node(aatree_node_t *node, bool is_string) { - if (node->left) M_AATreeFree_Node(node->left); - if (node->right) M_AATreeFree_Node(node->right); + if (node->left) M_AATreeFree_Node(node->left, is_string); + if (node->right) M_AATreeFree_Node(node->right, is_string); + if (is_string) + Z_Free(node->value); Z_Free(node); } void M_AATreeFree(aatree_t *aatree) { if (aatree->root) - M_AATreeFree_Node(aatree->root); + M_AATreeFree_Node(aatree->root, (aatree->flags & AATREE_STRING) == AATREE_STRING); Z_Free(aatree); } From a191c8b71ebc2c73794a586423684d6c94e78b29 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 7 Dec 2025 19:03:26 +0100 Subject: [PATCH 016/589] g_demo: screw you LF2_EXISTSHACK --- src/g_demo.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/g_demo.c b/src/g_demo.c index f828d0343..4c3219368 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2795,7 +2795,7 @@ void G_DoPlayDemo(char *defdemoname) demobuf.p += 4; // Extrainfo location // ...*map* not loaded? - if (!gamemap || (gamemap > NUMMAPS) || !mapheaderinfo[gamemap-1] || !(mapheaderinfo[gamemap-1]->menuflags & LF2_EXISTSHACK)) + if (!gamemap || (gamemap > NUMMAPS) || !mapheaderinfo[gamemap-1]) { snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); @@ -2836,6 +2836,16 @@ void G_DoPlayDemo(char *defdemoname) return; } + // ...*map* not loaded? + if (!(mapheaderinfo[gamemap-1]->menuflags & LF2_EXISTSHACK)) + { + snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); + CONS_Alert(CONS_ERROR, "%s", msg); + M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); + G_ResetDemoPlayback(); + return; + } + // Set color for (i = 0; i < MAXSKINCOLORS; i++) { From 8f3b7158e3b574591aa739320c7fe7b7acf92a3a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 7 Dec 2025 18:57:56 +0100 Subject: [PATCH 017/589] w_wad: kill longname support we dont use it for anything, we also cannot use it for anything. Due to massive amounts of unterminated string being passed to everything So we dont need to waste memory and resources --- src/w_wad.cpp | 26 +++++++++++++------------- src/w_wad.h | 12 ++++++------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 27de24789..8afb38cab 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -144,7 +144,7 @@ void W_Shutdown(void) Z_Free(wad->filename); while (wad->numlumps--) { - Z_Free(wad->lumpinfo[wad->numlumps].longname); + //Z_Free(wad->lumpinfo[wad->numlumps].longname); Z_Free(wad->lumpinfo[wad->numlumps].fullname); } @@ -418,11 +418,11 @@ static lumpinfo_t* ResGetLumpsStandalone(FILE* handle, UINT16* numlumps, const c lumpinfo->hash.name = W_HashLumpName(lumpname); // Allocate the lump's long name. - lumpinfo->longname = static_cast(Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL)); + /*lumpinfo->longname = static_cast(Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL)); strcpy(lumpinfo->longname, lumpname); lumpinfo->longname[lumpinfo->namelength] = '\0'; lumpinfo->longnamelength = lumpinfo->namelength; - lumpinfo->hash.longname = lumpinfo->hash.name; + lumpinfo->hash.longname = lumpinfo->hash.name;*/ // Allocate the lump's full name. lumpinfo->fullname = static_cast(Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL)); @@ -529,11 +529,11 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena lump_p->hash.name = W_HashLumpName(lump_p->name); // Allocate the lump's long name. - lump_p->longname = static_cast(Z_Malloc(9 * sizeof(char), PU_STATIC, NULL)); + /*lump_p->longname = static_cast(Z_Malloc(9 * sizeof(char), PU_STATIC, NULL)); strncpy(lump_p->longname, fileinfo->name, 8); lump_p->longname[8] = '\0'; lump_p->longnamelength = lump_p->namelength; - lump_p->hash.longname = lump_p->hash.name; + lump_p->hash.longname = lump_p->hash.name;*/ // Allocate the lump's full name. lump_p->fullname = static_cast(Z_Malloc(9 * sizeof(char), PU_STATIC, NULL)); @@ -729,10 +729,10 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) lump_p->namelength = strlen(lump_p->name); lump_p->hash.name = W_HashLumpName(lump_p->name); - lump_p->longname = static_cast(Z_Calloc(dotpos - trimname + 1, PU_STATIC, NULL)); + /*lump_p->longname = static_cast(Z_Calloc(dotpos - trimname + 1, PU_STATIC, NULL)); strlcpy(lump_p->longname, trimname, dotpos - trimname + 1); lump_p->longnamelength = strlen(lump_p->longname); - lump_p->hash.longname = W_HashLumpName(lump_p->longname); + lump_p->hash.longname = W_HashLumpName(lump_p->longname);*/ lump_p->fullname = static_cast(Z_Calloc(SHORT(zentry->namelen) + 1, PU_STATIC, NULL)); strncpy(lump_p->fullname, fullname, SHORT(zentry->namelen)); @@ -1124,7 +1124,7 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump) // Should be the only version, but that's not possible until we fix // all the instances of non null-terminated strings in the codebase... // -UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump) +/*UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump) { UINT16 i; UINT32 hash; @@ -1156,7 +1156,7 @@ UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump) // not found. return INT16_MAX; -} +}*/ UINT16 W_CheckNumForMarkerStartPwad(const char *name, UINT16 wad, UINT16 startlump) { @@ -1306,7 +1306,7 @@ lumpnum_t W_CheckNumForName(const char *name) // Should be the only version, but that's not possible until we fix // all the instances of non null-terminated strings in the codebase... // -lumpnum_t W_CheckNumForLongName(const char *name) +/*lumpnum_t W_CheckNumForLongName(const char *name) { INT32 i; lumpnum_t check = INT16_MAX; @@ -1340,7 +1340,7 @@ lumpnum_t W_CheckNumForLongName(const char *name) return lumpnum; } -} +}*/ // // W_GetNumForName @@ -1365,7 +1365,7 @@ lumpnum_t W_GetNumForName(const char *name) // Should be the only version, but that's not possible until we fix // all the instances of non null-terminated strings in the codebase... // -lumpnum_t W_GetNumForLongName(const char *name) +/*lumpnum_t W_GetNumForLongName(const char *name) { lumpnum_t i; @@ -1375,7 +1375,7 @@ lumpnum_t W_GetNumForLongName(const char *name) I_Error("W_GetNumForLongName: %s not found!\n", name); return i; -} +}*/ // // W_CheckNumForNameInBlock diff --git a/src/w_wad.h b/src/w_wad.h index 9ed733f78..75c7e9c04 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -68,11 +68,11 @@ typedef struct unsigned long position; // filelump_t filepos unsigned long disksize; // filelump_t size char name[9]; // filelump_t name[] e.g. "LongEntr" - char *longname; // e.g. "LongEntryName" + //char *longname; // e.g. "LongEntryName" char *fullname; // e.g. "Folder/Subfolder/LongEntryName.extension" size_t namelength; // length of name - size_t longnamelength; // length of longname + //size_t longnamelength; // length of longname size_t fullnamelength; // length of fullname size_t size; // real (uncompressed) size @@ -80,7 +80,7 @@ typedef struct struct { UINT32 name; // hash of name - UINT32 longname; // hash of longname + //UINT32 longname; // hash of longname //UINT32 fullname; // hash of fullname } hash; } lumpinfo_t; @@ -180,7 +180,7 @@ const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump); const char *W_CheckNameForNum(lumpnum_t lumpnum); UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump); // checks only in one pwad -UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump); +//UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump); /* Find the first lump after F_START for instance. */ UINT16 W_CheckNumForMarkerStartPwad(const char *name, UINT16 wad, UINT16 startlump); @@ -190,9 +190,9 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump); lumpnum_t W_CheckNumForName(const char *name); -lumpnum_t W_CheckNumForLongName(const char *name); +//lumpnum_t W_CheckNumForLongName(const char *name); lumpnum_t W_GetNumForName(const char *name); // like W_CheckNumForName but I_Error on LUMPERROR -lumpnum_t W_GetNumForLongName(const char *name); +//lumpnum_t W_GetNumForLongName(const char *name); lumpnum_t W_CheckNumForNameInBlock(const char *name, const char *blockstart, const char *blockend); UINT8 W_LumpExists(const char *name); // Lua uses this. UINT8 W_CheckMultipleLumps(const char* lump, ...); // variadic version of above lmao From ed758fc9217361a6904158800646c70d7041fa6f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 7 Dec 2025 20:23:47 +0100 Subject: [PATCH 018/589] g_demo: check for maplump existance directly cant really rely on mapheaderinfo to tell us if some map exists or not --- src/g_demo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 4c3219368..a714f8e48 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2795,7 +2795,7 @@ void G_DoPlayDemo(char *defdemoname) demobuf.p += 4; // Extrainfo location // ...*map* not loaded? - if (!gamemap || (gamemap > NUMMAPS) || !mapheaderinfo[gamemap-1]) + if (!gamemap || (gamemap > NUMMAPS) || (W_CheckNumForName(G_BuildMapName(gamemap)) == LUMPERROR)) { snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); @@ -2837,7 +2837,7 @@ void G_DoPlayDemo(char *defdemoname) } // ...*map* not loaded? - if (!(mapheaderinfo[gamemap-1]->menuflags & LF2_EXISTSHACK)) + if (!gamemap || (gamemap > NUMMAPS) || !mapheaderinfo[gamemap-1] || !(mapheaderinfo[gamemap-1]->menuflags & LF2_EXISTSHACK)) { snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); From 3cb4e86b480000bdfab1f75c46e2c63b1c0452f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 7 Dec 2025 19:51:29 +0100 Subject: [PATCH 019/589] i_system: "fix" recursive i_quit well this still aint working all to great, but atleast this allows me to quit the game if it gets stuck without having to always send a kill signal to it copy pasted from what the dedicated build does --- src/sdl/i_system.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 00250bf4f..8cb67c9d6 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1851,17 +1851,20 @@ INT32 I_StartupSystem(void) return 0; } +boolean is_quitting = false; + // // I_Quit // FUNCNORETURN void ATTRNORETURN I_Quit(void) { - static SDL_bool quiting = SDL_FALSE; - /* prevent recursive I_Quit() */ - if (quiting) goto death; + if (is_quitting) + abort(); + + is_quitting = true; SDL_ShowCursor(SDL_TRUE); - quiting = SDL_FALSE; + I_ShutdownConsole(); M_SaveConfig(NULL); //save game config, cvars.. D_SaveBan(); // save the ban list @@ -1888,7 +1891,7 @@ FUNCNORETURN void ATTRNORETURN I_Quit(void) } if (myargmalloc) free(myargv); // Deallocate allocated memory -death: + W_Shutdown(); exit(0); } From a2feaa7fde4c2d3138cf21c40c2f8f671fac78ad Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 7 Dec 2025 20:22:25 +0100 Subject: [PATCH 020/589] dont call I_Quit from within "quit_handler", let it signal main loop to quit fixes an issue for me which led to having the game threads getting stuck when sending an interrupt signal to the game due to some thread issues with the sdl subsystems shoutout to dsda doom for this --- src/d_main.c | 3 +++ src/dedicated/i_system.c | 12 ++++++++++-- src/i_system.h | 3 ++- src/sdl/i_system.cpp | 22 ++++++++++------------ src/sdl/i_video.c | 3 ++- src/sdl/mixer_sound.c | 3 ++- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index c46ef0c44..ab10af215 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -679,6 +679,9 @@ void D_SRB2Loop(void) for (;;) { + if (I_Interrupted()) + I_Quit(); + // capbudget is the minimum precise_t duration of a single loop iteration precise_t capbudget; precise_t elapsed; diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 31eaf0346..5edb71a99 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1075,11 +1075,19 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -FUNCNORETURN static ATTRNORETURN void quit_handler(int num) +static volatile sig_atomic_t interrupted = 0; + +boolean I_Interrupted(void) +{ + return interrupted; +} + +static void quit_handler(int num) { signal(num, SIG_DFL); //default signal action raise(num); - I_Quit(); + //I_Quit(); + interrupted = true; } #ifdef HAVE_LIBBACKTRACE diff --git a/src/i_system.h b/src/i_system.h index 7084c655f..68d51f022 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -29,7 +29,6 @@ extern "C" { */ #define MAX_QUIT_FUNCS 16 - /** \brief Graphic system had started up */ extern UINT8 graphics_started; @@ -191,6 +190,8 @@ INT32 I_StartupSystem(void); */ void I_ShutdownSystem(void); +boolean I_Interrupted(void); + /** \brief The I_GetDiskFreeSpace function \param freespace a INT64 pointer to hold the free space amount diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 8cb67c9d6..60e5108ac 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1670,21 +1670,19 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -FUNCNORETURN static ATTRNORETURN void quit_handler(int num) -{ -#ifdef HAVE_THREADS - if (g_main_thread_id != std::this_thread::get_id()) - { - // Do not attempt any sort of recovery if this signal triggers off the main thread - signal(num, SIG_DFL); - raise(num); - exit(-2); - } -#endif +static volatile sig_atomic_t interrupted = 0; +boolean I_Interrupted(void) +{ + return interrupted; +} + +static void quit_handler(int num) +{ signal(num, SIG_DFL); //default signal action raise(num); - I_Quit(); + //I_Quit(); + interrupted = true; } static void I_RegisterSignals(void) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c2d87e3f1..ae2691359 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -2012,7 +2012,8 @@ void I_ShutdownGraphics(void) SDL_DestroyWindow(window); window = NULL; - SDL_QuitSubSystem(SDL_INIT_VIDEO); + if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO) + SDL_QuitSubSystem(SDL_INIT_VIDEO); framebuffer = SDL_FALSE; } diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 529b47399..c455aab01 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -237,7 +237,8 @@ void I_ShutdownSound(void) Mix_Quit(); #endif - SDL_QuitSubSystem(SDL_INIT_AUDIO); + if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO) + SDL_QuitSubSystem(SDL_INIT_AUDIO); #ifdef HAVE_LIBGME if (gme) From c19c80d79744671e5984364ecbb027f3d7d55448 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 7 Dec 2025 20:40:30 +0100 Subject: [PATCH 021/589] command.c: fix "alias" command crashing when no aliases were registered if we dont have aliases list how do we check the next alias in the list aswell? --- src/command.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/command.c b/src/command.c index 0cf1c85ff..7e0c34d03 100644 --- a/src/command.c +++ b/src/command.c @@ -652,7 +652,7 @@ static void COM_Alias_f(void) CONS_Printf(M_GetText("All aliases that start with \x87'%s'\x80 are:\n"), begin); int count = 0; - for (cmdalias_t *head = com_alias; head->next != NULL; head = head->next) + for (cmdalias_t *head = com_alias; head != NULL; head = head->next) { if (strncmp(begin, head->name, szBegin) == 0) { @@ -673,7 +673,7 @@ static void COM_Alias_f(void) /* Display alias subtext, show all aliases. */ CONS_Printf(M_GetText("alias : create a shortcut command that executes other command(s)\n")); - for (cmdalias_t *head = com_alias; head->next != NULL; head = head->next) + for (cmdalias_t *head = com_alias; head != NULL; head = head->next) { CONS_Printf(alias_format, head->name, head->value); } From eb4d9bbdd531710b51d90e2ec5aed610a4931ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Mon, 8 Dec 2025 21:14:54 +0100 Subject: [PATCH 022/589] Fix decompression warning when starting a server --- src/d_clisrv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index fa1536e72..8f2cc5afb 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1775,6 +1775,9 @@ static void SV_SendPlayerInfo(INT32 node) static void SV_SendMapIcon(INT32 node) { + if (node == 0) + return; + doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); const char *map = va("%sP", G_BuildMapName(gamemap)); From 37eba186f5621895112320878026e26bddb93cb9 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 9 Dec 2025 18:06:48 +0100 Subject: [PATCH 023/589] netcode: replace some stuff with memsets + add a little bounds safety in some places --- src/d_clisrv.c | 16 ++++++++++++++++ src/d_net.c | 6 +----- src/d_netfil.c | 32 ++++++++++++++++---------------- src/i_tcp.c | 16 +++++++++------- 4 files changed, 42 insertions(+), 28 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1117112cb..b380b2ed0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1939,8 +1939,11 @@ static boolean SV_ResendingSavegameToAnyone(void) INT32 i; for (i = 0; i < MAXNETNODES; i++) + { if (nodeingame[i] && resendingsavegame[i]) return true; + } + return false; } #endif @@ -2923,8 +2926,10 @@ static void CL_ConnectToServer(void) { pnumnodes = 0; for (i = 0; i < MAXNETNODES; i++) + { if (nodeingame[i]) pnumnodes++; + } } } while (!(cl_mode == CL_CONNECTED && (client || (server && nodewaited <= pnumnodes)))); @@ -4400,8 +4405,10 @@ void D_QuitNetGame(void) netbuffer->packettype = PT_SERVERSHUTDOWN; for (i = 0; i < MAXNETNODES; i++) + { if (nodeingame[i]) HSendPacket(i, true, 0, 0); + } #ifdef MASTERSERVER if (serverrunning && netgame && cv_advertise.value) // see mserv.c Online() UnregisterServer(); @@ -6851,8 +6858,10 @@ static inline void PingUpdate(void) //send out our ping packets for (i = 0; i < MAXNETNODES; i++) + { if (nodeingame[i]) HSendPacket(i, true, 0, sizeof(INT32) * (MAXPLAYERS+1)); + } pingmeasurecount = 0; //Reset count } @@ -6955,10 +6964,15 @@ static void RenewHolePunch(void) static void HandleNodeTimeouts(void) { INT32 i; + if (server) + { for (i = 1; i < MAXNETNODES; i++) + { if (nodeingame[i] && freezetimeout[i] < I_GetTime()) Net_ConnectionTimeout(i); + } + } } // Keep the network alive while not advancing tics! @@ -7168,11 +7182,13 @@ void NetUpdate(void) } for (i = 0; i < MAXNETNODES; ++i) + { if (resynch_inprogress[i]) { SV_SendResynch(i); counts = -666; } + } // Do not make tics while resynching if (counts != -666) diff --git a/src/d_net.c b/src/d_net.c index ba70cb7c1..33654ee67 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -611,12 +611,8 @@ void Net_WaitAllAckReceived(UINT32 timeout) static void InitNode(node_t *node) { - node->acktosend_head = node->acktosend_tail = 0; - memset(node->acktosend, 0, sizeof(node->acktosend)); - node->firstacktosend = 0; + memset(node, 0, sizeof(node_t)); node->nextacknum = 1; - node->remotefirstack = 0; - node->flags = 0; } static void InitAck(void) diff --git a/src/d_netfil.c b/src/d_netfil.c index d35bb09b3..ecbca1eed 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -958,7 +958,7 @@ void Got_Filetxpak(void) || fastcmp(filename, "music.kart") || fastcmp(filename, "patch.kart") )) - I_Error("Tried to download \"%s\"", filename); + I_Error("Tried to download base-game file: \"%s\"", filename); if (filenum >= fileneedednum) { @@ -1017,21 +1017,21 @@ void Got_Filetxpak(void) switch(file->status) { - case FS_NOTFOUND: - s = "FS_NOTFOUND"; - break; - case FS_FOUND: - s = "FS_FOUND"; - break; - case FS_OPEN: - s = "FS_OPEN"; - break; - case FS_MD5SUMBAD: - s = "FS_MD5SUMBAD"; - break; - default: - s = "unknown"; - break; + case FS_NOTFOUND: + s = "FS_NOTFOUND"; + break; + case FS_FOUND: + s = "FS_FOUND"; + break; + case FS_OPEN: + s = "FS_OPEN"; + break; + case FS_MD5SUMBAD: + s = "FS_MD5SUMBAD"; + break; + default: + s = "unknown"; + break; } I_Error("Received a file not requested (file id: %d, file status: %s)\n", filenum, s); diff --git a/src/i_tcp.c b/src/i_tcp.c index 98a03f841..e4d9e0a7a 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -496,8 +496,10 @@ static void cleanupnodes(void) // Why can't I start at zero? for (j = 1; j < MAXNETNODES; j++) + { if (!(nodeingame[j] || SV_SendingFile(j))) nodeconnected[j] = false; + } } static SINT8 getfreenode(void) @@ -507,11 +509,13 @@ static SINT8 getfreenode(void) cleanupnodes(); for (j = 0; j < MAXNETNODES; j++) + { if (!nodeconnected[j]) { nodeconnected[j] = true; return j; } + } /** \warning No free node? Just in case a node might not have been freed properly, * look if there are connected nodes that aren't in game, and forget them. @@ -810,7 +814,7 @@ static void SOCK_Send(void) static void SOCK_FreeNodenum(INT32 numnode) { // can't disconnect from self :) - if (!numnode || numnode > MAXNETNODES) + if (numnode <= 0 || numnode > MAXNETNODES) return; DEBFILE(va("Free node %d (%s)\n", numnode, SOCK_GetNodeAddress(numnode))); @@ -1431,14 +1435,12 @@ static void SOCK_RegisterHolePunch(void) static boolean SOCK_OpenSocket(void) { - size_t i; - - memset(clientaddress, 0, sizeof (clientaddress)); + memset(clientaddress, 0, sizeof(clientaddress)); + memset(nodeconnected, false, sizeof(nodeconnected)); nodeconnected[0] = true; // always connected to self - for (i = 1; i < MAXNETNODES; i++) - nodeconnected[i] = false; nodeconnected[BROADCASTADDR] = true; + I_NetSend = SOCK_Send; I_NetGet = SOCK_Get; I_NetCloseSocket = SOCK_CloseSocket; @@ -1478,7 +1480,7 @@ static boolean SOCK_Ban(INT32 node) { INT32 ban; - if (node > MAXNETNODES) + if (node < 0 || node > MAXNETNODES) return false; ban = numbans; From 821c061f82929b041c11bb3abd55067308c3b072 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Nov 2025 20:07:04 +0100 Subject: [PATCH 024/589] Optimize: Use doomednum lookup also when (re)spawning mapthings not just for loading savegame thinkers Actually even provides slight runtime performance improvement, but mostly makes levelload faster --- src/p_local.h | 3 +++ src/p_mobj.c | 71 ++++++++++++++++++++++++++++----------------------- src/p_saveg.c | 19 -------------- src/p_setup.c | 4 +++ 4 files changed, 46 insertions(+), 51 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 4d8e8032d..4b6530eb9 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -272,6 +272,9 @@ extern consvar_t cv_gravity; void P_RespawnSpecials(void); +extern mobjtype_t g_doomednum_to_mobjtype[UINT16_MAX]; +void CalculateDoomednumToMobjtype(void); + mobj_t *P_AllocateMobj(void); mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); diff --git a/src/p_mobj.c b/src/p_mobj.c index fcc70ec8b..e59d087d8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10448,6 +10448,21 @@ void P_PrecipitationEffects(void) } } +mobjtype_t g_doomednum_to_mobjtype[UINT16_MAX]; + +void CalculateDoomednumToMobjtype(void) +{ + memset(g_doomednum_to_mobjtype, MT_NULL, sizeof(g_doomednum_to_mobjtype)); + + for (size_t i = MT_NULL+1; i < NUMMOBJTYPES; i++) + { + if (mobjinfo[i].doomednum > 0 && mobjinfo[i].doomednum <= UINT16_MAX) + { + g_doomednum_to_mobjtype[ mobjinfo[i].doomednum ] = i; + } + } +} + // // P_RespawnSpecials // @@ -10527,11 +10542,9 @@ void P_RespawnSpecials(void) ss = R_PointInSubsector(x, y); // find which type to spawn - for (i = 0; i < NUMMOBJTYPES; i++) - if (mthing->type == mobjinfo[i].doomednum) - break; + i = g_doomednum_to_mobjtype[mthing->type]; - if (i == NUMMOBJTYPES) // prevent creation of objects with this type -- Monster Iestyn 17/12/17 + if (i <= MT_NULL || i >= NUMMOBJTYPES) // prevent creation of objects with this type -- Monster Iestyn 17/12/17 { // 3D Mode start Thing is unlikely to be added to the que, // so don't bother checking for that specific type @@ -10972,11 +10985,9 @@ void P_SpawnMapThing(mapthing_t *mthing) if (objectplacing) { // find which type to spawn - for (i = 0; i < NUMMOBJTYPES; i++) - if (mthing->type == mobjinfo[i].doomednum) - break; + i = g_doomednum_to_mobjtype[mthing->type]; - if (i == NUMMOBJTYPES) + if (i <= MT_NULL || i >= NUMMOBJTYPES) { if (mthing->type == 3328) // 3D Mode start Thing return; @@ -11044,13 +11055,9 @@ void P_SpawnMapThing(mapthing_t *mthing) } // find which type to spawn - for (i = 0; i < NUMMOBJTYPES; i++) - { - if (mthing->type == mobjinfo[i].doomednum) - break; - } + i = g_doomednum_to_mobjtype[mthing->type]; - if (i == NUMMOBJTYPES) + if (i <= MT_NULL || i >= NUMMOBJTYPES) { if (mthing->type == 3328) // 3D Mode start Thing return; @@ -11743,32 +11750,32 @@ ML_NOCLIMB : Direction not controllable if (mobj->flags & MF_MONITOR) { // flag for strong/weak random boxes - if (mthing->type == mobjinfo[MT_SUPERRINGBOX].doomednum || mthing->type == mobjinfo[MT_PRUP].doomednum || - mthing->type == mobjinfo[MT_SNEAKERTV].doomednum || mthing->type == mobjinfo[MT_INV].doomednum || - mthing->type == mobjinfo[MT_WHITETV].doomednum || mthing->type == mobjinfo[MT_GREENTV].doomednum || - mthing->type == mobjinfo[MT_YELLOWTV].doomednum || mthing->type == mobjinfo[MT_BLUETV].doomednum || - mthing->type == mobjinfo[MT_BLACKTV].doomednum || mthing->type == mobjinfo[MT_PITYTV].doomednum || - mthing->type == mobjinfo[MT_RECYCLETV].doomednum || mthing->type == mobjinfo[MT_MIXUPBOX].doomednum) + if (i == MT_SUPERRINGBOX || i == MT_PRUP || + i == MT_SNEAKERTV || i == MT_INV || + i == MT_WHITETV || i == MT_GREENTV || + i == MT_YELLOWTV || i == MT_BLUETV || + i == MT_BLACKTV || i == MT_PITYTV || + i == MT_RECYCLETV || i == MT_MIXUPBOX) mobj->flags2 |= MF2_AMBUSH; } - - else if (mthing->type != mobjinfo[MT_AXIS].doomednum && - mthing->type != mobjinfo[MT_AXISTRANSFER].doomednum && - mthing->type != mobjinfo[MT_AXISTRANSFERLINE].doomednum && - mthing->type != mobjinfo[MT_NIGHTSBUMPER].doomednum && - mthing->type != mobjinfo[MT_STARPOST].doomednum) + else if ( + i != MT_AXIS && + i != MT_AXISTRANSFER && + i != MT_AXISTRANSFERLINE && + i != MT_NIGHTSBUMPER && + i != MT_STARPOST) mobj->flags2 |= MF2_AMBUSH; } if (mthing->options & MTF_OBJECTSPECIAL) { // flag for strong/weak random boxes - if (mthing->type == mobjinfo[MT_SUPERRINGBOX].doomednum || mthing->type == mobjinfo[MT_PRUP].doomednum || - mthing->type == mobjinfo[MT_SNEAKERTV].doomednum || mthing->type == mobjinfo[MT_INV].doomednum || - mthing->type == mobjinfo[MT_WHITETV].doomednum || mthing->type == mobjinfo[MT_GREENTV].doomednum || - mthing->type == mobjinfo[MT_YELLOWTV].doomednum || mthing->type == mobjinfo[MT_BLUETV].doomednum || - mthing->type == mobjinfo[MT_BLACKTV].doomednum || mthing->type == mobjinfo[MT_PITYTV].doomednum || - mthing->type == mobjinfo[MT_RECYCLETV].doomednum || mthing->type == mobjinfo[MT_MIXUPBOX].doomednum) + if (i == MT_SUPERRINGBOX || i == MT_PRUP || + i == MT_SNEAKERTV || i == MT_INV || + i == MT_WHITETV || i == MT_GREENTV || + i == MT_YELLOWTV || i == MT_BLUETV || + i == MT_BLACKTV || i == MT_PITYTV || + i == MT_RECYCLETV || i == MT_MIXUPBOX) mobj->flags2 |= MF2_STRONGBOX; // Requires you to be in bonus time to activate diff --git a/src/p_saveg.c b/src/p_saveg.c index 0dcac2083..64686dfd4 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1965,21 +1965,6 @@ FUNCINLINE static ATTRINLINE player_t *LoadPlayer(UINT32 player) // Loads a mobj_t from a save game // -static mobjtype_t g_doomednum_to_mobjtype[UINT16_MAX]; - -static void CalculateDoomednumToMobjtype(void) -{ - memset(g_doomednum_to_mobjtype, MT_NULL, sizeof(g_doomednum_to_mobjtype)); - - for (size_t i = MT_NULL+1; i < NUMMOBJTYPES; i++) - { - if (mobjinfo[i].doomednum > 0 && mobjinfo[i].doomednum <= UINT16_MAX) - { - g_doomednum_to_mobjtype[ mobjinfo[i].doomednum ] = i; - } - } -} - static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) { mobj_t *mobj; @@ -2879,10 +2864,6 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) if (READUINT32(save->p) != ARCHIVEBLOCK_THINKERS) I_Error("Bad $$$.sav at archive block Thinkers"); - // Pre-calculate this lookup, because it was wasting - // a shit ton of time loading mobj thinkers. - CalculateDoomednumToMobjtype(); - // remove all the current thinkers for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = next) { diff --git a/src/p_setup.c b/src/p_setup.c index 2993bb5d2..5b4c2796b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2863,6 +2863,10 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) P_ResetDynamicSlopes(); + // Pre-calculate this lookup, because it was wasting + // a shit ton of time loading mobj thinkers. + CalculateDoomednumToMobjtype(); + P_SpawnMapThings(); P_SpawnEmblems(!fromnetsave); From 59ff5e61bf320b4dfd3e62c30853c085c5181613 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 10 Dec 2025 19:13:07 +0100 Subject: [PATCH 025/589] Revert "Fix use-after-free when mobj is removed while still playing sounds" This reverts commit 3bdc745bd15f5742c41f560c5f7c397bc5ca8a7a. --- src/p_setup.c | 2 -- src/s_sound.c | 7 +------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 5b4c2796b..bf40afe9d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -812,8 +812,6 @@ static void P_LoadSectors(UINT8 *data) ss->tag = SHORT(ms->tag); ss->flags |= SF_FLIPSPECIAL_FLOOR; - - ss->soundorg.thinker.function = (actionf_p1)P_MobjThinker; } // set the sky flat num diff --git a/src/s_sound.c b/src/s_sound.c index 651d579b8..5bc830252 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -772,14 +772,9 @@ void S_UpdateSounds(void) volume = c->volume; // 8 bits internal volume precision sep = NORM_SEP; - if (P_MobjWasRemoved(c->origin)) - { - // origin was removed, stop the music - S_StopChannel(cnum); - } // check non-local sounds for distance clipping // or modify their params - else + if (c->origin) { boolean itsUs = false; From 9a58eb3010a99370569240bcd519a94364b65b99 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 11 Dec 2025 14:10:28 +0100 Subject: [PATCH 026/589] G_BuildLocalTiccmd: remove "moveinput" variable checking both cmd->buttons aswell as cmd->driftturn already handles those cases --- src/g_game.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index b76c1290a..5d48a62b5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -800,6 +800,10 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn +// +// G_HandleLocalDriftturn +// Hack for Lua menus that check directional inputs with driftturn +// static void G_HandleLocalDriftturn(ticcmd_t *cmd, UINT8 ssplayer) { INT32 axis = 0; @@ -862,9 +866,8 @@ static void G_HandleLocalDriftturn(ticcmd_t *cmd, UINT8 ssplayer) // static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) { - boolean moveinput = false; INT32 axis = 0; - const boolean usejoystick = (cv_usejoystick[(ssplayer-1)].value); + const boolean usejoystick = cv_usejoystick[(ssplayer-1)].value; // check for inputs and return button commands // for stuff like joining with item button, saltyhop, honking, etc. @@ -899,15 +902,11 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) #undef CHECKINPUT - moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) - || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || - (usejoystick && JoyAxis(AXISAIM, ssplayer) != 0) || (usejoystick && JoyAxis(AXISTURN, ssplayer) != 0)); - axis = JoyAxis(AXISLOOKBACK, ssplayer); camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); // Reset to our spec player if we watch someone else. - if ((moveinput || cmd->buttons) + if ((cmd->driftturn || cmd->buttons) && displayplayers[0] != consoleplayer && ssplayer == 1) { if (cv_director.value) From 4ee468f5c6667c0a7d19b744bdf2bc4a46b7282a Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 11 Dec 2025 14:26:49 +0100 Subject: [PATCH 027/589] Accessability: Add "Auto Acceleration" feature ported from hostmod --- src/d_netcmd.c | 2 ++ src/g_game.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++- src/g_game.h | 2 ++ 3 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8fca12794..870ceba69 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -997,6 +997,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_litesteer[i]); + CV_RegisterVar(&cv_autoaccel[i]); + CV_RegisterVar(&cv_usejoystick[i]); CV_RegisterVar(&cv_joyscale[i]); CV_RegisterVar(&cv_rumble[i]); diff --git a/src/g_game.c b/src/g_game.c index 5d48a62b5..2d2a49461 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -454,6 +454,14 @@ consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS] = { {"litesteer4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} }; +//static CV_PossibleValue_t autoaccelcons_t[] = {{0, "Off"}, {1, "Manual"}, {2, "Automatic"}, {0, NULL}}; +consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS] = { + {"autoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"autoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"autoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"autoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}}; consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -918,6 +926,63 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) } } +// +// G_HandleAutoAcceleration +// +static void G_HandleAutoAcceleration(ticcmd_t *cmd, player_t *player, UINT8 forplayer) +{ + if (!cv_autoaccel[forplayer].value) + return; + + if (gamestate != GS_LEVEL) + return; + + // dont accel before and during countdown + if (leveltime <= starttime) + return; + + // dont do this in menus or when console is onscreen + if (menuactive || CON_Ready()) + return; + + // gotta have a player that aint respawning + if (!player->mo || player->kartstuff[k_respawn]) + return; + + // dont need for "finished" players + if (player->exiting || (player->pflags & PF_TIMEOVER)) + return; + + // dont do during spinout + if (player->kartstuff[k_spinouttimer]) + return; + + // spectators and freecam dont need special handling, see G_BuildTiccmd + + if (cmd->buttons & BT_BRAKE) + { + if (cmd->buttons & BT_DRIFT || + player->kartstuff[k_sneakertimer] || + player->kartstuff[k_squishedtimer]) + { + cmd->forwardmove = (SINT8)forwardmove[0]; + cmd->buttons |= BT_ACCELERATE; + } + else + { + // allows us to drive backwards if we need to + if (cmd->forwardmove > 0) + cmd->forwardmove = 0; + cmd->buttons &= ~BT_ACCELERATE; + } + } + else + { + cmd->forwardmove = (SINT8)forwardmove[1]; + cmd->buttons |= BT_ACCELERATE; + } +} + // // G_BuildTiccmd // Builds a ticcmd from all of the available inputs @@ -1065,7 +1130,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (InputDown(gc_accelerate, ssplayer) || (gamepadjoystickmove && axis > 0) || player->kartstuff[k_sneakertimer]) { cmd->buttons |= BT_ACCELERATE; - forward = forwardmove[1]; // 50 + forward = forwardmove[1]; // 50 } else if (analogjoystickmove && axis > 0) { @@ -1146,6 +1211,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->sidemove = (SINT8)(cmd->sidemove + side); } + G_HandleAutoAcceleration(cmd, player, forplayer); + //{ SRB2kart - Drift support // Not grouped with the rest of turn stuff because it needs to know what buttons you're pressing for rubber-burn turn // limit turning to angleturn[1] to stop mouselook letting you look too fast diff --git a/src/g_game.h b/src/g_game.h index c3b89435d..509749c5f 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -74,6 +74,8 @@ extern consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS]; + extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff; // Hud offsets From 4cea0c1414456af1383f861adbfc380683cb6097 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 11 Dec 2025 16:43:59 +0300 Subject: [PATCH 028/589] Add autoaccel into accessibility menu --- src/m_menudefs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 3d8d9549a..60af918dc 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1652,6 +1652,13 @@ static menuitem_t OP_AccessibilityMenu[] = {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 85}, {IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 90}, + + {IT_HEADER, NULL, "Controls", NULL, 100}, + + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 110}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 115}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 120}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 125}, }; static const char* OP_AccessibilityTooltips[] = @@ -1673,6 +1680,11 @@ static const char* OP_AccessibilityTooltips[] = NULL, "Reverse left and right channels of audio.", "Change how often the same Sound is allowed to play at once.", + NULL, + "Automatically hold acceleration button (Player 1).", + "Automatically hold acceleration button (Player 2).", + "Automatically hold acceleration button (Player 3).", + "Automatically hold acceleration button (Player 4).", }; static menuitem_t OP_SaturnMenu[] = From 44ba69cf539c3a3361e017d22fbf0d8686a218a4 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 11 Dec 2025 17:35:35 +0300 Subject: [PATCH 029/589] Move lite steer and turn smoothing cvars into individual player controls menu --- src/m_menu.c | 59 +++++++++++++++++++++++++++++++++++------------- src/m_menu.h | 4 ++-- src/m_menudefs.c | 40 ++++++++++++++++---------------- 3 files changed, 64 insertions(+), 39 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index bfe2372bf..deeb74e0c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9358,29 +9358,32 @@ static void M_SetupControlsMenu(UINT8 pnum) break; } + OP_AllControlsMenu[2].itemaction = &cv_litesteer[pnum]; + OP_AllControlsMenu[3].itemaction = &cv_turnsmooth[pnum]; + if (pnum > 0) { // Hide P1-only controls - OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat - OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Pause - OP_AllControlsMenu[18].status = IT_GRAYEDOUT2; // Screenshot - OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF - OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu - OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console - OP_AllControlsMenu[37].status = IT_GRAYEDOUT2; // Director + OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // Chat + OP_AllControlsMenu[10].status = IT_GRAYEDOUT2; // Rankings + OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Pause + OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // Screenshot + OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // GIF + OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // System Menu + OP_AllControlsMenu[25].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[41].status = IT_GRAYEDOUT2; // Director } else { // Unhide P1-only controls - OP_AllControlsMenu[15].status = IT_CONTROL; // Chat - OP_AllControlsMenu[16].status = IT_CONTROL; // Rankings - OP_AllControlsMenu[17].status = IT_CONTROL; // Pause - OP_AllControlsMenu[18].status = IT_CONTROL; // Screenshot - OP_AllControlsMenu[19].status = IT_CONTROL; // GIF - OP_AllControlsMenu[20].status = IT_CONTROL; // System Menu - OP_AllControlsMenu[21].status = IT_CONTROL; // Console - OP_AllControlsMenu[37].status = IT_CONTROL; // Director + OP_AllControlsMenu[19].status = IT_CONTROL; // Chat + OP_AllControlsMenu[10].status = IT_CONTROL; // Rankings + OP_AllControlsMenu[21].status = IT_CONTROL; // Pause + OP_AllControlsMenu[22].status = IT_CONTROL; // Screenshot + OP_AllControlsMenu[23].status = IT_CONTROL; // GIF + OP_AllControlsMenu[24].status = IT_CONTROL; // System Menu + OP_AllControlsMenu[25].status = IT_CONTROL; // Console + OP_AllControlsMenu[41].status = IT_CONTROL; // Director } M_SetupNextMenu(&OP_AllControlsDef); @@ -9494,12 +9497,36 @@ static void M_DrawControl(void) else if ((currentMenu->menuitems[i].status == IT_HEADER) && (i != max-1)) V_DrawString(19, y+6, highlightflags|V_ALLOWLOWERCASE, currentMenu->menuitems[i].text); else if (currentMenu->menuitems[i].status & IT_STRING) + { V_DrawString(x, y, ((i == itemOn) ? highlightflags|V_ALLOWLOWERCASE : V_ALLOWLOWERCASE), currentMenu->menuitems[i].text); + if (currentMenu->menuitems[i].status & IT_CVAR) + { + consvar_t *cv = (consvar_t *)currentMenu->menuitems[i].itemaction; + + // IT_HEADER matches IT_CVAR, for some reason... + if (cv) + { + INT32 w = V_StringWidth(cv->string, 0); + V_DrawString(BASEVIDWIDTH - x - w, y, + ((cv->flags & CV_CHEAT) && !CV_IsSetToDefault(cv) ? warningflags : highlightflags)|MENUCAPS, cv->string); + if (i == itemOn) + { + V_DrawCharacter(BASEVIDWIDTH - x - 10 - w - (skullAnimCounter/5), y, + '\x1C' | highlightflags, false); // left arrow + V_DrawCharacter(BASEVIDWIDTH - x + 2 + (skullAnimCounter/5), y, + '\x1D' | highlightflags, false); // right arrow + } + } + } + } + y += SMALLLINEHEIGHT; } V_DrawScaledPatch(currentMenu->x - 20, cursory, 0, (patch_t *)W_CachePatchName("M_CURSOR", PU_PATCH)); + + M_DoToolTips(currentMenu); } #undef controlheight diff --git a/src/m_menu.h b/src/m_menu.h index 62f66f177..2b048fe90 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -398,7 +398,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na NULL\ } -#define CONTROLMENUSTYLE(source, prev)\ +#define CONTROLMENUSTYLE(source, prev, tooltip)\ {\ "M_CONTRO",\ sizeof (source)/sizeof (menuitem_t),\ @@ -409,7 +409,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na 26, 40,\ 0,\ NULL,\ - NULL\ + tooltip\ } #define IMAGEDEF(source)\ diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 60af918dc..cbdaac587 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -648,17 +648,6 @@ static menuitem_t OP_ControlsMenu[] = {IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 55}, {IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 75}, - - {IT_STRING | IT_CVAR, NULL, "Digital turn easing (P1)", &cv_turnsmooth[0], 85}, - {IT_STRING | IT_CVAR, NULL, "Digital turn easing (P2)", &cv_turnsmooth[1], 95}, - {IT_STRING | IT_CVAR, NULL, "Digital turn easing (P3)", &cv_turnsmooth[2], 105}, - {IT_STRING | IT_CVAR, NULL, "Digital turn easing (P4)", &cv_turnsmooth[3], 115}, - - // i hate our menus sincerly - {IT_STRING | IT_CVAR, NULL, "Lite Steer (P1)", &cv_litesteer[0], 135}, - {IT_STRING | IT_CVAR, NULL, "Lite Steer (P2)", &cv_litesteer[1], 145}, - {IT_STRING | IT_CVAR, NULL, "Lite Steer (P3)", &cv_litesteer[2], 155}, - {IT_STRING | IT_CVAR, NULL, "Lite Steer (P4)", &cv_litesteer[3], 165}, }; static const char* OP_ControlsTooltips[] = @@ -669,15 +658,6 @@ static const char* OP_ControlsTooltips[] = "Setup player 4 controls.", "Options for mouse control.", "Allowed amount of controls per key.", - "Turn smoothing for non-analog turning (Player 1).", - "Turn smoothing for non-analog turning (Player 2).", - "Turn smoothing for non-analog turning (Player 3).", - "Turn smoothing for non-analog turning (Player 4).", - - "Hold DOWN on d-pad/keyboard for shallow turns (Player 1).", - "Hold DOWN on d-pad/keyboard for shallow turns (Player 2).", - "Hold DOWN on d-pad/keyboard for shallow turns (Player 3).", - "Hold DOWN on d-pad/keyboard for shallow turns (Player 4).", }; static menuitem_t OP_AllControlsMenu[] = @@ -685,6 +665,13 @@ static menuitem_t OP_AllControlsMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Gamepad Options...", &OP_Joystick1Def, 0}, {IT_CALL|IT_STRING, NULL, "Reset to defaults", M_ResetControls, 8}, + {IT_HEADER, NULL, "Control Options", NULL, 0}, + {IT_SPACE, NULL, NULL, NULL, 0}, + + // Cvars are set in M_SetupControlsMenu + {IT_STRING|IT_CVAR, NULL, "Lite Steer", &cv_litesteer[0], 18}, + {IT_STRING|IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth[0], 26}, + //{IT_SPACE, NULL, NULL, NULL, 0}, {IT_HEADER, NULL, "Gameplay Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, @@ -733,6 +720,17 @@ static menuitem_t OP_AllControlsMenu[] = {IT_CONTROL, NULL, "Custom Action 3", M_ChangeControl, gc_custom3 }, }; +// Has to be same length as OP_AllControlsMenu, but otherwise its mostly empty +static const char* OP_AllControlsTooltips[sizeof(OP_AllControlsMenu)/sizeof(OP_AllControlsMenu[0])] = { + NULL, + NULL, + NULL, + NULL, + "Hold DOWN on d-pad/keyboard for shallow turns.", + "Turn smoothing for non-analog turning.", + // The rest is null, for now +}; + #define OP_JOYMENU(pnum) \ {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, \ {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[pnum] , 15}, \ @@ -2492,7 +2490,7 @@ menu_t OP_MainDef = menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 40, 15, OP_ControlsTooltips); //WTF menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30, OP_MouseTooltips); -menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef); +menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef, OP_AllControlsTooltips); menu_t OP_Joystick1Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 30, 36, NULL); menu_t OP_Joystick2Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 30, 36, NULL); menu_t OP_Joystick3Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 30, 36, NULL); From 1c289d73cae3455782ee39a02b55b03461e521a0 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 11 Dec 2025 17:54:03 +0300 Subject: [PATCH 030/589] Oopsie --- src/m_menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index deeb74e0c..3650853bc 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9358,8 +9358,8 @@ static void M_SetupControlsMenu(UINT8 pnum) break; } - OP_AllControlsMenu[2].itemaction = &cv_litesteer[pnum]; - OP_AllControlsMenu[3].itemaction = &cv_turnsmooth[pnum]; + OP_AllControlsMenu[4].itemaction = &cv_litesteer[pnum]; + OP_AllControlsMenu[5].itemaction = &cv_turnsmooth[pnum]; if (pnum > 0) { From 6ad344f65d14eb32c4e52ee855faa03243e700ff Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 11 Dec 2025 18:19:00 +0100 Subject: [PATCH 031/589] findfile: let files added with "-file" look in addon/downloads folders first due to https://github.com/Indev450/SRB2Kart-Saturn/commit/956fc099adcd7f33993c43c8ee3aea64df3fe9b4 IWADS shouldnt use findfile anymore If there should be such case we can always expose the startupiwad count to check if were currently searching for iwads iirc --- src/d_netfil.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index d35bb09b3..57f0f0f6c 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -1162,8 +1162,12 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet filestatus_t homecheck; // store result of last file search boolean badmd5 = false; // store whether md5 was bad from either of the first two searches (if nothing was found in the third) - // skip for startup, our mainwads wont be in there - if (loaded_config) + // see IdentifyVersion + // Iwads skip findfile due to passing fullpath to W_OpenWadFile +#if 0 + // skip for Iwads, as they wont be in there + if (!startupiwadcount) +#endif { if (cv_addons_option.value == 3 && *cv_addons_folder.string != '\0') { From 1ccd3e37bcb50157359bbc8644cb4ed898c72636 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 11 Dec 2025 21:37:31 +0300 Subject: [PATCH 032/589] Init playerinfo[i].node to 255 so if playerinfo packet gets lost, server join screen doesn't display empty player names --- src/d_clisrv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8f2cc5afb..cd04fb3a2 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3475,6 +3475,9 @@ void CL_Reset(void) memset(player_muted, 0, sizeof(player_muted)); + for (INT32 i = 0; i < MAXPLAYERS; ++i) + playerinfo[i].node = 255; + // D_StartTitle should get done now, but the calling function will handle it } @@ -4263,6 +4266,9 @@ void D_ClientServerInit(void) #endif D_LoadBan(false); + for (INT32 i = 0; i < MAXPLAYERS; ++i) + playerinfo[i].node = 255; + gametic = 0; localgametic = 0; From 2c7c9ec32ab91a07a2a413ee69c6c6f24eedfc42 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 11 Dec 2025 20:10:01 +0100 Subject: [PATCH 033/589] fastcmp.h: mark fastcmp functions as pure this might let the compiler optimize aways subsequent calls in some cases strcmp etc from glibc also does it prayin nothin changes the locale at runtime lmao --- src/fastcmp.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fastcmp.h b/src/fastcmp.h index 0f7c24aaa..1b92e42e8 100644 --- a/src/fastcmp.h +++ b/src/fastcmp.h @@ -3,14 +3,14 @@ // returns false if s != c // returns true if s == c -FUNCINLINE static ATTRINLINE boolean fasticmp(const char *s, const char *c) +FUNCINLINE static ATTRINLINE PUREFUNC boolean fasticmp(const char *s, const char *c) { for (; *s && toupper(*s) == toupper(*c); s++, c++) ; return (*s == *c); // make sure both strings ended } // case-sensitive of the above -FUNCINLINE static ATTRINLINE boolean fastcmp(const char *s, const char *c) +FUNCINLINE static ATTRINLINE PUREFUNC boolean fastcmp(const char *s, const char *c) { for (; *s && *s == *c; s++, c++) ; return (*s == *c); // make sure both strings ended @@ -18,7 +18,7 @@ FUNCINLINE static ATTRINLINE boolean fastcmp(const char *s, const char *c) // length-limited of the above // only true if both strings are at least l characters long AND match, case-sensitively! -FUNCINLINE static ATTRINLINE boolean fastncmp(const char *s, const char *c, UINT16 l) +FUNCINLINE static ATTRINLINE PUREFUNC boolean fastncmp(const char *s, const char *c, UINT16 l) { for (; *s && *s == *c && --l; s++, c++) ; return !l; // make sure you reached the end From 3828a9f8e07e7cffaf9fbbe70a28a8f45382f1d3 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 11 Dec 2025 22:58:06 +0300 Subject: [PATCH 034/589] Add flipcammode toggle for using local flipcam settings instead of player flags --- src/m_menudefs.c | 11 +++++++---- src/p_mobj.c | 17 ++++++++++++++++- src/r_main.cpp | 5 +++++ src/r_main.h | 1 + 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index cbdaac587..e6129d2d8 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1339,16 +1339,19 @@ static menuitem_t OP_CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Field of View",&cv_fov, 30}, - {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 50}, - {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 60}, - {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 70}, - {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 80}, + {IT_STRING | IT_CVAR, NULL, "Flipcam Mode", &cv_flipcammode, 40}, + + {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 60}, + {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 70}, + {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 80}, + {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 90}, }; static const char* OP_CamOptionsTooltips[] = { NULL, "Player field of view.", + "Change flipcam mode.\nDisplayplayer - use currently viewed player option.\nLocal - use local flipcam toggle option.", NULL, NULL, NULL, diff --git a/src/p_mobj.c b/src/p_mobj.c index e59d087d8..cd7d44a62 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3237,7 +3237,22 @@ void P_DestroyRobots(void) // the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { - const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); + boolean player_flipcam = false; + + if (cv_flipcammode.value == 0) + player_flipcam = player->pflags & PF_FLIPCAM; + else + { + INT32 pnum = P_GetLocalPlayerNumForPlayer(player); + + // Shouldn't happen but just in case + if (pnum == -1) + pnum = 0; + + player_flipcam = cv_flipcam[pnum].value; + } + + const boolean flipcam = (player_flipcam && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); UINT8 postimgtype = 0; if (encoremode) diff --git a/src/r_main.cpp b/src/r_main.cpp index 1ad8e8be9..fecfba580 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -182,6 +182,9 @@ consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS] = { {"flipcam4", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam4_OnChange, 0, NULL, NULL, 0, 0, NULL} }; +static CV_PossibleValue_t flipcammode_cons_t[] = {{0, "Displayplayer"}, {1, "Local"}, {0, NULL}}; +consvar_t cv_flipcammode = {"flipcammode", "Displayplayer", CV_SAVE, flipcammode_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_shadow = {"shadow", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_shadowoffs = {"offsetshadows", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_skybox = {"skybox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1546,6 +1549,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_flipcam[i]); } + CV_RegisterVar(&cv_flipcammode); + // Enough for dedicated server if (dedicated) return; diff --git a/src/r_main.h b/src/r_main.h index 36c8756f8..d33d67606 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -205,6 +205,7 @@ extern consvar_t cv_showhud, cv_translucenthud, cv_uncappedhud; extern consvar_t cv_homremoval; extern consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_flipcammode; extern consvar_t cv_shadow, cv_shadowoffs; extern consvar_t cv_ffloorclip, cv_spriteclip; extern consvar_t cv_softcyancut; From 6c98440f27f14c26d70c468915feb1d5cbb461e9 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 16 Dec 2025 17:52:03 +0100 Subject: [PATCH 035/589] Remove pure attribute from fasticmp While i assume this to be fine currently, i quite frankly dont trust the srb2 codebase enough aswell as preventing any future issues if there should ever be need to switch locales, since toupper WILL change behaviour in such cases which does not qualify as pure --- src/fastcmp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fastcmp.h b/src/fastcmp.h index 1b92e42e8..ea87bee4d 100644 --- a/src/fastcmp.h +++ b/src/fastcmp.h @@ -3,7 +3,7 @@ // returns false if s != c // returns true if s == c -FUNCINLINE static ATTRINLINE PUREFUNC boolean fasticmp(const char *s, const char *c) +FUNCINLINE static ATTRINLINE boolean fasticmp(const char *s, const char *c) { for (; *s && toupper(*s) == toupper(*c); s++, c++) ; return (*s == *c); // make sure both strings ended From 0540b5656a2d95c21011d2617214de18c30b9e81 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 19 Nov 2025 19:10:23 +0100 Subject: [PATCH 036/589] OpenGL: keep around our drawnodes memory no need to constantly reallocate new memory we dont have renderer switch, and the next level will render drawnodes anyways those wont grow super big also, so theres no big worry about wasting tons of memory yes i like ceepeepee vectors, how can you tell --- src/hardware/hw_main.cpp | 51 ++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 9f1a90769..b363069b6 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -14,6 +14,7 @@ #ifdef HWRENDER #include +#include #include "../doomstat.h" #include "../doomdef.h" @@ -4174,6 +4175,7 @@ static int CompareVisSprites(const void *p1, const void *p2) static void HWR_SortVisSprites(void) { UINT32 i; + for (i = 0; i < gl_visspritecount; i++) { gl_vsprorder[i] = HWR_GetVisSprite(i); @@ -4242,38 +4244,29 @@ typedef struct // initial size of drawnode array #define DRAWNODES_INIT_SIZE 64 -gl_drawnode_t *drawnodes = NULL; -INT32 numdrawnodes = 0; -INT32 alloceddrawnodes = 0; +// no reason to waste all the allocations since every map will have atleast one translucent thing +static std::vector drawnodes; static void *HWR_CreateDrawNode(gl_drawnode_type_t type) { - gl_drawnode_t *drawnode; + // if we didnt alloc anything yet, reserve atleast 64 nodes + // dont declare with it as we want our size to be 0! + drawnodes.reserve(DRAWNODES_INIT_SIZE); - if (!drawnodes) - { - alloceddrawnodes = DRAWNODES_INIT_SIZE; - drawnodes = static_cast(Z_Malloc(alloceddrawnodes * sizeof(gl_drawnode_t), PU_LEVEL, &drawnodes)); - } - else if (numdrawnodes >= alloceddrawnodes) - { - alloceddrawnodes *= 2; - Z_Realloc(drawnodes, alloceddrawnodes * sizeof(gl_drawnode_t), PU_LEVEL, &drawnodes); - } - - drawnode = &drawnodes[numdrawnodes++]; - drawnode->type = type; + drawnodes.emplace_back(); + drawnodes.back().type = type; // not sure if returning different pointers to a union is necessary switch (type) { case DRAWNODE_PLANE: - return &drawnode->u.plane; + return &drawnodes.back().u.plane; case DRAWNODE_POLYOBJECT_PLANE: - return &drawnode->u.polyplane; + return &drawnodes.back().u.polyplane; case DRAWNODE_WALL: - return &drawnode->u.wall; + return &drawnodes.back().u.wall; } + return NULL; } @@ -4337,11 +4330,15 @@ static int CompareDrawNodePlanes(const void *p1, const void *p2) // Sorts and renders the list of drawnodes for the scene being rendered. static void HWR_RenderDrawNodes(void) { - INT32 i = 0, run_start = 0; + size_t i = 0, run_start = 0; + static std::vector sortindex; + + sortindex.reserve(DRAWNODES_INIT_SIZE); // Array for storing the rendering order. // A list of indices into the drawnodes array. - INT32 *sortindex; + + const size_t numdrawnodes = drawnodes.size(); if (!numdrawnodes) return; @@ -4350,7 +4347,7 @@ static void HWR_RenderDrawNodes(void) PS_START_TIMING(ps_hw_nodesorttime); - sortindex = static_cast(Z_Malloc(sizeof(INT32) * numdrawnodes, PU_STATIC, NULL)); + sortindex.resize(numdrawnodes); // Reversed order for (i = 0; i < numdrawnodes; i++) @@ -4366,7 +4363,7 @@ static void HWR_RenderDrawNodes(void) if (drawnodes[sortindex[run_start]].type == DRAWNODE_PLANE) { // found it, now look for run end - INT32 run_end; // (inclusive) + size_t run_end; // (inclusive) for (i = run_start+1; i < numdrawnodes; i++) { @@ -4379,7 +4376,7 @@ static void HWR_RenderDrawNodes(void) if (run_end > run_start) // if there are multiple consecutive planes, not just one { // consecutive run of planes found, now sort it - qs22j(sortindex + run_start, run_end - run_start + 1, sizeof(INT32), CompareDrawNodePlanes); + qs22j(sortindex.data() + run_start, run_end - run_start + 1, sizeof(INT32), CompareDrawNodePlanes); } run_start = run_end + 1; // continue looking for runs coming right after this one @@ -4451,9 +4448,7 @@ static void HWR_RenderDrawNodes(void) PS_STOP_TIMING(ps_hw_nodedrawtime); - numdrawnodes = 0; - - Z_Free(sortindex); + drawnodes.clear(); // clear so our size is 0 again! } From 8b3d55fbc89ab0d20ab1c741442b34c8b5189639 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 9 Dec 2025 18:14:44 +0100 Subject: [PATCH 037/589] HWR_ProcessSeg: port softwares code to skip rendering inner sides that are "joined" to other fofs This seems to improve performance on maps with moderate to lots of fofs quite a bit. On maps with only a few fofs, this makes no difference or has very very little regression Need to test and check if there are any visual errors, but so far everything seems good --- src/hardware/hw_main.cpp | 104 +++++++++++++++++++++++++++++---------- 1 file changed, 78 insertions(+), 26 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index b363069b6..afe899df2 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1881,6 +1881,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // Used for height comparisons and etc across FOFs and slopes fixed_t high1, highslope1, low1, lowslope1; + fixed_t high2, highslope2, low2, lowslope2; INT32 texnum; @@ -1893,19 +1894,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { for (rover = gl_backsector->ffloors; rover; rover = rover->next) { - boolean bothsides = false; - // Skip if it exists on both sectors. - ffloor_t * r2; - for (r2 = gl_frontsector->ffloors; r2; r2 = r2->next) - if (rover->master == r2->master) - { - bothsides = true; - break; - } - - if (bothsides) - continue; - const ffloortype_e roverflags = rover->flags; if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES) || (roverflags & FF_INVERTSIDES)) @@ -1917,6 +1905,45 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if ((high1 < lowcut || highslope1 < lowcutslope) || (low1 > highcut || lowslope1 > highcutslope)) continue; + ffloor_t * r2; + for (r2 = gl_frontsector->ffloors; r2; r2 = r2->next) + { + if (r2->master == rover->master) // Skip if same control line. + break; + + const ffloortype_e r2flags = r2->flags; + + if (!(r2flags & FF_EXISTS) || !(r2flags & FF_RENDERSIDES)) + continue; + + if (rover->flags & FF_EXTRA) + { + if (!(r2flags & FF_CUTEXTRA)) + continue; + + if (r2flags & FF_EXTRA && (r2flags & (FF_TRANSLUCENT|FF_FOG)) != (rover->flags & (FF_TRANSLUCENT|FF_FOG))) + continue; + } + else + { + if (!(r2flags & FF_CUTSOLIDS)) + continue; + } + + SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight) + SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight) + + if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) + continue; + if ((high1 > high2 || highslope1 > highslope2) || (low1 < low2 || lowslope1 < lowslope2)) + continue; + + break; + } + + if (r2) + continue; + side_t *side = R_GetFFloorSide(gl_curline->linedef, rover, gl_backsector); boolean do_texture_skew; @@ -2053,19 +2080,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { - boolean bothsides = false; - // Skip if it exists on both sectors. - ffloor_t * r2; - for (r2 = gl_backsector->ffloors; r2; r2 = r2->next) - if (rover->master == r2->master) - { - bothsides = true; - break; - } - - if (bothsides) - continue; - const ffloortype_e roverflags = rover->flags; if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES) || !(roverflags & FF_ALLSIDES)) @@ -2077,6 +2091,44 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if ((high1 < lowcut || highslope1 < lowcutslope) || (low1 > highcut || lowslope1 > highcutslope)) continue; + ffloor_t * r2; + for (r2 = gl_backsector->ffloors; r2; r2 = r2->next) + { + if (r2->master == rover->master) // Skip if same control line. + break; + + const ffloortype_e r2flags = r2->flags; + + if (!(r2flags & FF_EXISTS) || !(r2flags & FF_RENDERSIDES)) + continue; + + if (rover->flags & FF_EXTRA) + { + if (!(r2flags & FF_CUTEXTRA)) + continue; + + if (r2flags & FF_EXTRA && (r2flags & (FF_TRANSLUCENT|FF_FOG)) != (rover->flags & (FF_TRANSLUCENT|FF_FOG))) + continue; + } + else + { + if (!(r2flags & FF_CUTSOLIDS)) + continue; + } + + SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight) + SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight) + + if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) + continue; + if ((high1 > high2 || highslope1 > highslope2) || (low1 < low2 || lowslope1 < lowslope2)) + continue; + + break; + } + if (r2) + continue; + side_t *side = R_GetFFloorSide(gl_curline->linedef, rover, gl_backsector); boolean do_texture_skew; From 860dc37fe476b2b9cf489cf88c83c12268a31d04 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Nov 2025 20:51:53 +0100 Subject: [PATCH 038/589] Optimize: move a few strlen calls out of loops when applicable and the input does not get modified within the loop needs some testing incase i oversaw something --- src/command.c | 7 +++++-- src/d_clisrv.c | 6 ++++-- src/d_netfil.c | 11 ++++++----- src/hu_stuff.c | 41 ++++++++++++++++++++++++----------------- src/k_hud.c | 4 +++- src/m_menu.c | 3 ++- src/m_misc.c | 13 +++++++------ src/sdl/i_system.cpp | 9 +++++++-- src/v_video.c | 12 +++++++++--- 9 files changed, 67 insertions(+), 39 deletions(-) diff --git a/src/command.c b/src/command.c index 7e0c34d03..6b71dce73 100644 --- a/src/command.c +++ b/src/command.c @@ -237,10 +237,13 @@ void COM_ImmedExecute(const char *ptext) char line[1024] = ""; INT32 quotes; - while (i < strlen(ptext)) + const size_t txtlength = strlen(ptext); + + while (i < txtlength) { quotes = 0; - for (j = 0; i < strlen(ptext); i++,j++) + + for (j = 0; i < txtlength; i++,j++) { if (ptext[i] == '\"' && !quotes && i > 0 && ptext[i-1] != ' ') // Malformed command return; diff --git a/src/d_clisrv.c b/src/d_clisrv.c index cd04fb3a2..6cf50a4d3 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1457,12 +1457,14 @@ static inline void CL_DrawConnectionStatus(void) V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, dldlength, 8, 160); memset(tempname, 0, sizeof(tempname)); + // offset filename to just the name only part filename += strlen(filename) - nameonlylength(filename); + const size_t filenamelength = strlen(filename); - if (strlen(filename) > sizeof(tempname)-1) // too long to display fully + if (filenamelength > sizeof(tempname)-1) // too long to display fully { - size_t endhalfpos = strlen(filename)-10; + size_t endhalfpos = filenamelength-10; // display as first 14 chars + ... + last 10 chars // which should add up to 27 if our math(s) is correct snprintf(tempname, sizeof(tempname), "%.14s...%.10s", filename, filename+endhalfpos); diff --git a/src/d_netfil.c b/src/d_netfil.c index 57f0f0f6c..a4478fcc9 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -1079,12 +1079,14 @@ void CloseNetFile(void) // Receiving a file? for (i = 0; i < MAX_WADFILES; i++) + { if (fileneeded[i].status == FS_DOWNLOADING && fileneeded[i].file) { fclose(fileneeded[i].file); // File is not complete delete it remove(fileneeded[i].filename); } + } // Remove PT_FILEFRAGMENT from acknowledge list Net_AbortPacketType(PT_FILEFRAGMENT); @@ -1098,17 +1100,16 @@ void nameonly(char *s) void *ns; for (j = strlen(s); j != (size_t)-1; j--) + { if ((s[j] == '\\') || (s[j] == ':') || (s[j] == '/')) { ns = &(s[j+1]); len = strlen(ns); -#if 0 - memcpy(s, ns, len+1); -#else - memmove(s, ns, len+1); -#endif + memmove(s, ns, len+1); + return; } + } } // Returns the length in characters of the last element of a path. diff --git a/src/hu_stuff.c b/src/hu_stuff.c index a61199b39..6cca391e9 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -596,12 +596,12 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) } // Only servers/admins can CSAY. - if(!server && !(IsPlayerAdmin(consoleplayer))) + if (!server && !(IsPlayerAdmin(consoleplayer))) flags &= ~HU_CSAY; // We handle HU_SERVER_SAY, not the caller. flags &= ~HU_SERVER_SAY; - if(dedicated && !(flags & HU_CSAY)) + if (dedicated && !(flags & HU_CSAY)) flags |= HU_SERVER_SAY; buf[0] = target; @@ -615,17 +615,20 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) strlcat(msg, COM_Argv(ix + usedargs), msgspace); } - if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm + const size_t msglength = strlen(msg); + + if (msglength > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm { // what we're gonna do now is check if the node exists // with that logic, characters 4 and 5 are our numbers: const char *newmsg; INT32 spc = 1; // used if nodenum[1] is a space. - char *nodenum = (char*) malloc(3); + CLEANUP(pfree) char *nodenum = (char*) malloc(3); memcpy(nodenum, msg+3, 2); nodenum[2] = '\0'; + // check for undesirable characters in our "number" - if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9'))) + if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9'))) { // check if nodenum[1] is a space if (nodenum[1] == ' ') @@ -634,23 +637,21 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) else { HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); - free(nodenum); return; } } + // I'm very bad at C, I swear I am, additional checks eww! if (spc != 0) { if (msg[5] != ' ') { HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); - free(nodenum); return; } } target = atoi((const char*) nodenum); // turn that into a number - free(nodenum); //CONS_Printf("%d\n", target); // check for target player, if it doesn't exist then we can't send the message! @@ -661,12 +662,13 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) HU_AddChatText(va("\x82NOTICE: \x80Player %d does not exist.", target), false); // same return; } + buf[0] = target; newmsg = msg+5+spc; strlcpy(msg, newmsg, HU_MAXMSGLEN + 1); } - SendNetXCmd(XD_SAY, buf, strlen(msg) + 1 + msg-buf); + SendNetXCmd(XD_SAY, buf, msglength + 1 + msg-buf); } /** Send a message to everyone. @@ -917,10 +919,12 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum) return; } + const size_t msglength = strlen(msg); + //check for invalid characters (0x80 or above) { size_t i; - const size_t j = strlen(msg); + const size_t j = msglength; for (i = 0; i < j; i++) { if (msg[i] & 0x80) @@ -967,7 +971,7 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum) } // Handle "/me" actions, but only in messages to everyone. - if (target == 0 && strlen(msg) > 4 && strnicmp(msg, "/me ", 4) == 0) + if (target == 0 && msglength > 4 && strnicmp(msg, "/me ", 4) == 0) { msg += 4; action = true; @@ -1149,10 +1153,12 @@ static boolean HU_clearChatSpaces(void) size_t i = 0; // Used to just check our message char c; // current character we're iterating. boolean nothingbutspaces = true; + const size_t chatlength = strlen(w_chat_buf); - for (; i < strlen(w_chat_buf); i++) // iterate through message and eradicate all spaces that don't belong. + for (; i < chatlength; i++) // iterate through message and eradicate all spaces that don't belong. { c = w_chat_buf[i]; + if (!c) break; // if there's nothing, it's safe to assume our message has ended, so let's not waste any more time here. @@ -1161,6 +1167,7 @@ static boolean HU_clearChatSpaces(void) nothingbutspaces = false; } } + return nothingbutspaces; } @@ -1207,11 +1214,11 @@ static void HU_SendChatMessage(void) return; } - size_t len = strlen(msg); + const size_t msglength = strlen(msg); - if (len >= 5 && strnicmp(msg, "/mute", 5) == 0) // Used /mute + if (msglength >= 5 && strnicmp(msg, "/mute", 5) == 0) // Used /mute { - if (len > 6) + if (msglength > 6) DoMute(msg+6); else HU_AddChatText("\x82NOTICE: \x80Usage: /mute ", false); @@ -1219,7 +1226,7 @@ static void HU_SendChatMessage(void) return; } - if (len > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm + if (msglength > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm { INT32 spc = 1; // used if nodenum[1] is a space. const char *newmsg; @@ -1991,7 +1998,7 @@ static void HU_DrawChat(void) longest_name_length = max(longest_name_length, strlen(player_names[i])); } - for(i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) continue; diff --git a/src/k_hud.c b/src/k_hud.c index 59278a229..1d9b7fe5b 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4468,7 +4468,9 @@ static void K_drawLapStartAnim(void) V_DrawFixedPatch(leftx, y, FRACUNIT, vflags, kp_lapanim_lap[min(progress/2, 6)], NULL); char *lapnum = va("%02d", stplyr->laps + 1); - for (int i = 0; i < (int)strlen(lapnum); i++) + const size_t laplength = strlen(lapnum); + + for (int i = 0; i < (int)laplength; i++) { int digit = lapnum[i] - '0'; int frame = min(2, progress/2 - 8 - (i*2)); diff --git a/src/m_menu.c b/src/m_menu.c index 3650853bc..c2978fe82 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2868,8 +2868,9 @@ static void M_DrawCenteredMenu(void) static inline size_t M_StringHeight(const char *string) { size_t h = 8, i; + const size_t strlength = strlen(string); - for (i = 0; i < strlen(string); i++) + for (i = 0; i < strlength; i++) if (string[i] == '\n') h += 8; diff --git a/src/m_misc.c b/src/m_misc.c index 655a28a24..cbc40d4e2 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1693,22 +1693,23 @@ char *M_GetToken(const char *inputString) } -const char * M_Ftrim (double f) +const char * M_Ftrim(double f) { static char dig[9];/* "0." + 6 digits (6 is printf's default) */ int i; + /* I know I said it's the default, but just in case... */ sprintf(dig, "%.6f", fabs(modf(f, &f))); + /* trim trailing zeroes */ for (i = strlen(dig)-1; dig[i] == '0'; --i) ; + if (dig[i] == '.')/* :NOTHING: */ return ""; - else - { - dig[i + 1] = '\0'; - return &dig[1];/* skip the 0 */ - } + + dig[i + 1] = '\0'; + return &dig[1];/* skip the 0 */ } /** Count bits in a number. diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 60e5108ac..8a9b8bd69 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -2315,12 +2315,17 @@ static void pathonly(char *s) size_t j; for (j = strlen(s); j != (size_t)-1; j--) + { if ((s[j] == '\\') || (s[j] == ':') || (s[j] == '/')) { - if (s[j] == ':') s[j+1] = 0; - else s[j] = 0; + if (s[j] == ':') + s[j+1] = 0; + else + s[j] = 0; + return; } + } } /** \brief search for srb2.srb in the given path diff --git a/src/v_video.c b/src/v_video.c index 213db7bfc..ac85715ef 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2992,7 +2992,9 @@ INT32 V_CreditStringWidth(const char *string) if (!string) return 0; - for (i = 0; i < strlen(string); i++) + const size_t strlength = strlen(string); + + for (i = 0; i < strlength; i++) { c = toupper(string[i]) - CRED_FONTSTART; if (c < 0 || c >= CRED_FONTSIZE) @@ -3070,7 +3072,9 @@ INT32 V_LevelNameWidth(const char *string) INT32 c, w = 0; size_t i; - for (i = 0; i < strlen(string); i++) + const size_t strlength = strlen(string); + + for (i = 0; i < strlength; i++) { c = toupper(string[i]) - LT_FONTSTART; if (c < 0 || c >= LT_FONTSIZE || !lt_font[c]) @@ -3089,7 +3093,9 @@ INT32 V_LevelNameHeight(const char *string) INT32 c, w = 0; size_t i; - for (i = 0; i < strlen(string); i++) + const size_t strlength = strlen(string); + + for (i = 0; i < strlength; i++) { c = toupper(string[i]) - LT_FONTSTART; if (c < 0 || c >= LT_FONTSIZE || !lt_font[c]) From a4af2546437b033693dc5fec2ece1a6535b0e3c9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Dec 2025 20:16:04 +0100 Subject: [PATCH 039/589] Revert "dont call I_Quit from within "quit_handler", let it signal main loop to quit" This reverts commit a2feaa7fde4c2d3138cf21c40c2f8f671fac78ad. --- src/d_main.c | 3 --- src/dedicated/i_system.c | 12 ++---------- src/i_system.h | 3 +-- src/sdl/i_system.cpp | 20 +++++++++++--------- src/sdl/i_video.c | 3 +-- src/sdl/mixer_sound.c | 3 +-- 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ab10af215..c46ef0c44 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -679,9 +679,6 @@ void D_SRB2Loop(void) for (;;) { - if (I_Interrupted()) - I_Quit(); - // capbudget is the minimum precise_t duration of a single loop iteration precise_t capbudget; precise_t elapsed; diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 5edb71a99..31eaf0346 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1075,19 +1075,11 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -static volatile sig_atomic_t interrupted = 0; - -boolean I_Interrupted(void) -{ - return interrupted; -} - -static void quit_handler(int num) +FUNCNORETURN static ATTRNORETURN void quit_handler(int num) { signal(num, SIG_DFL); //default signal action raise(num); - //I_Quit(); - interrupted = true; + I_Quit(); } #ifdef HAVE_LIBBACKTRACE diff --git a/src/i_system.h b/src/i_system.h index 68d51f022..7084c655f 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -29,6 +29,7 @@ extern "C" { */ #define MAX_QUIT_FUNCS 16 + /** \brief Graphic system had started up */ extern UINT8 graphics_started; @@ -190,8 +191,6 @@ INT32 I_StartupSystem(void); */ void I_ShutdownSystem(void); -boolean I_Interrupted(void); - /** \brief The I_GetDiskFreeSpace function \param freespace a INT64 pointer to hold the free space amount diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 8a9b8bd69..0c024a5bd 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1670,19 +1670,21 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -static volatile sig_atomic_t interrupted = 0; - -boolean I_Interrupted(void) +FUNCNORETURN static ATTRNORETURN void quit_handler(int num) { - return interrupted; -} +#ifdef HAVE_THREADS + if (g_main_thread_id != std::this_thread::get_id()) + { + // Do not attempt any sort of recovery if this signal triggers off the main thread + signal(num, SIG_DFL); + raise(num); + exit(-2); + } +#endif -static void quit_handler(int num) -{ signal(num, SIG_DFL); //default signal action raise(num); - //I_Quit(); - interrupted = true; + I_Quit(); } static void I_RegisterSignals(void) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index ae2691359..c2d87e3f1 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -2012,8 +2012,7 @@ void I_ShutdownGraphics(void) SDL_DestroyWindow(window); window = NULL; - if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO) - SDL_QuitSubSystem(SDL_INIT_VIDEO); + SDL_QuitSubSystem(SDL_INIT_VIDEO); framebuffer = SDL_FALSE; } diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index c455aab01..529b47399 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -237,8 +237,7 @@ void I_ShutdownSound(void) Mix_Quit(); #endif - if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO) - SDL_QuitSubSystem(SDL_INIT_AUDIO); + SDL_QuitSubSystem(SDL_INIT_AUDIO); #ifdef HAVE_LIBGME if (gme) From 7c848f4be561876c4b833f711fe8458cbeb66580 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 24 Dec 2025 00:54:39 +0300 Subject: [PATCH 040/589] Sort directories too in replay list --- src/m_menu.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index c2978fe82..15309dd2d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4170,8 +4170,6 @@ static int ReplayListSortComparator(const void *entry1, const void *entry2) return -1; else if (demo2->type == MD_SUBDIR && demo1->type != MD_SUBDIR) return 1; - else if (demo1->type == MD_SUBDIR && demo2->type == MD_SUBDIR) - return 0; memcpy(filepath1, demo1->filepath, sizeof(filepath1)); memcpy(filepath2, demo2->filepath, sizeof(filepath2)); From 1c95e5f40e58dabf8b22d7221e863b789327583b Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 24 Dec 2025 01:23:20 +0300 Subject: [PATCH 041/589] Actually add filepath to directories to sort them --- src/m_menu.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 15309dd2d..9a8c8bfba 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4174,8 +4174,14 @@ static int ReplayListSortComparator(const void *entry1, const void *entry2) memcpy(filepath1, demo1->filepath, sizeof(filepath1)); memcpy(filepath2, demo2->filepath, sizeof(filepath2)); - nameonly(filepath1); - nameonly(filepath2); + // nameonly will make filepath's empty for directories since they may end with PATHSEP + // this is a lazy solution but if we don't do nameonly, dirs still will be sorted in correct only, + // just not very efficently + if (demo1->type != MD_SUBDIR) + { + nameonly(filepath1); + nameonly(filepath2); + } // Comparing in opposite order to move new replays to the top return strncmp(filepath2, filepath1, sizeof(filepath1)); @@ -4211,6 +4217,9 @@ static void PrepReplayList(boolean reset) { demolist_all[i].type = MD_SUBDIR; strncpy(demolist_all[i].title, dirmenu[i] + DIR_STRING, 64); + snprintf(demolist_all[i].filepath, sizeof(demolist_all[i].filepath), + // 255 = UINT8 limit. dirmenu entries are restricted to this length (see DIR_LEN). + "%s%.255s", menupath, dirmenu[i] + DIR_STRING); } else { From 2bf4c442597768e83790e0d6688393a3a746e1c4 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 24 Dec 2025 01:36:00 +0300 Subject: [PATCH 042/589] Revert "Actually add filepath to directories to sort them" This reverts commit 1c95e5f40e58dabf8b22d7221e863b789327583b. --- src/m_menu.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 9a8c8bfba..15309dd2d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4174,14 +4174,8 @@ static int ReplayListSortComparator(const void *entry1, const void *entry2) memcpy(filepath1, demo1->filepath, sizeof(filepath1)); memcpy(filepath2, demo2->filepath, sizeof(filepath2)); - // nameonly will make filepath's empty for directories since they may end with PATHSEP - // this is a lazy solution but if we don't do nameonly, dirs still will be sorted in correct only, - // just not very efficently - if (demo1->type != MD_SUBDIR) - { - nameonly(filepath1); - nameonly(filepath2); - } + nameonly(filepath1); + nameonly(filepath2); // Comparing in opposite order to move new replays to the top return strncmp(filepath2, filepath1, sizeof(filepath1)); @@ -4217,9 +4211,6 @@ static void PrepReplayList(boolean reset) { demolist_all[i].type = MD_SUBDIR; strncpy(demolist_all[i].title, dirmenu[i] + DIR_STRING, 64); - snprintf(demolist_all[i].filepath, sizeof(demolist_all[i].filepath), - // 255 = UINT8 limit. dirmenu entries are restricted to this length (see DIR_LEN). - "%s%.255s", menupath, dirmenu[i] + DIR_STRING); } else { From 7518a6f181e59de80e56e707c5972926447ee871 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 24 Dec 2025 01:36:02 +0300 Subject: [PATCH 043/589] Revert "Sort directories too in replay list" This reverts commit 7c848f4be561876c4b833f711fe8458cbeb66580. --- src/m_menu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index 15309dd2d..c2978fe82 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4170,6 +4170,8 @@ static int ReplayListSortComparator(const void *entry1, const void *entry2) return -1; else if (demo2->type == MD_SUBDIR && demo1->type != MD_SUBDIR) return 1; + else if (demo1->type == MD_SUBDIR && demo2->type == MD_SUBDIR) + return 0; memcpy(filepath1, demo1->filepath, sizeof(filepath1)); memcpy(filepath2, demo2->filepath, sizeof(filepath2)); From c9afd4a2cd6005b0ad5308f386da39003a414cbb Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 24 Dec 2025 00:06:05 +0100 Subject: [PATCH 044/589] G_GetDemoDate: make safer and use static memory bunch of smaller issues before, no real checks for strltol and potential free on a null pointer lul also skips replays with shorter than 10 char names and handles errors better --- src/g_demo.c | 93 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index a714f8e48..312e57530 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -55,6 +55,8 @@ #include "k_stats.h" // SRB2kart #include "r_fps.h" // frame interpolation/uncapped +#include + #ifdef HAVE_DISCORDRPC #include "discord.h" #endif @@ -2401,49 +2403,69 @@ static long G_GetCreationTime(char *filepath) static char *G_GetDemoDate(menudemo_t *pdemo) { - char *datetime; - datetime = malloc(sizeof(pdemo->date)); // mallocma balls - - // no mallocma balls... :c - if (!datetime) - { - return NULL; - } - + char *endPos = NULL; + static char datetime[11]; time_t file_time = 0; + const char *format = NULL; + struct tm *tm_buf = NULL; + CLEANUP(pfree) char *filename = NULL; // get le filepath - char *filename; filename = strdup(pdemo->filepath); -#if defined (_WIN32) if (!filename) { - // if we cant get a filename try just getting the file create time +#if defined (_WIN32) + // if we cant get a filename try just getting the file creation time file_time = G_GetCreationTime(pdemo->filepath); goto skipfilenametime; - } #else - if (!filename) - { - free(datetime); return NULL; - } #endif + } // get the actual filename Zzz... nameonly(filename); - // convert it to long Zzz.... - file_time = strtol(filename, NULL, 10); - free(filename); // dont need this anymore a + // the first 10 characters of a replay name usually is a unix timestamp + + // not long enough to contain a valid timestamp + if (strlen(filename) < 10) + { +#if defined (_WIN32) + // try to get file creation time + file_time = G_GetCreationTime(pdemo->filepath); + goto skipfilenametime; +#else + return NULL; +#endif + } + +#ifndef AVOID_ERRNO + errno = 0; +#endif + // get the timestamp as actual numbers lul + file_time = strtol(filename, &endPos, 10); + + if (endPos == filename // Empty string +#ifndef AVOID_ERRNO + || errno == ERANGE // Number out-of-range +#endif + || file_time < 0) // Number is not positive + { +#if defined (_WIN32) + // just try and get the creation time then + file_time = G_GetCreationTime(pdemo->filepath); +#else + return NULL; +#endif + } #if defined (_WIN32) skipfilenametime: #endif // then throw it into localtime to get an actual human readable format lmao - struct tm *tm_buf = NULL; tm_buf = localtime(&file_time); // cant believe we ended up in 1970 @@ -2456,14 +2478,10 @@ skipfilenametime: tm_buf = localtime(&file_time); if (tm_buf == NULL || tm_buf->tm_year <= 110) - { - free(datetime); return NULL; - } goto gotcreationtime; #else - free(datetime); return NULL; #endif } @@ -2472,17 +2490,27 @@ skipfilenametime: gotcreationtime: #endif - const char *format; - // US ppl are special (: if (cv_demodateformat.value == 2) format = "%m.%d.%Y"; else if (cv_demodateformat.value == 1) format = "%d.%m.%Y"; else - format = strstr(setlocale(LC_TIME, NULL), "en_US") ? "%m.%d.%Y" : "%d.%m.%Y"; + { + const char *locale = setlocale(LC_TIME, NULL); - strftime(datetime, sizeof(pdemo->date), format, tm_buf); + if (locale == NULL) + format = "%d.%m.%Y"; // fallback to non US format + else if (strstr(locale, "en_US")) + format = "%m.%d.%Y"; + else + format = "%d.%m.%Y"; + } + + if (strftime(datetime, sizeof(datetime), format, tm_buf) == 0) + { + return NULL; + } return datetime; } @@ -2491,6 +2519,7 @@ void G_LoadDemoTitle(menudemo_t *pdemo) { UINT8 infobuffer[96], *info_p; UINT16 pdemoversion; + char *demodate = NULL; size_t count; FILE *handle = fopen(pdemo->filepath, "rb"); @@ -2529,13 +2558,13 @@ void G_LoadDemoTitle(menudemo_t *pdemo) memcpy(pdemo->title, info_p, 64); // demo date - char *demodate; demodate = G_GetDemoDate(pdemo); if (demodate) - strncpy(pdemo->date, demodate, sizeof(pdemo->date)); + { + strlcpy(pdemo->date, demodate, sizeof(pdemo->date)); + } - free(demodate); break; #ifdef DEMO_COMPAT_100 case 0x0001: From 0fe3086a5ad41d9ec61609bebbe3c7ccdcfa0cf6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Dec 2025 18:58:41 +0100 Subject: [PATCH 045/589] Fixup the doomednum lookup properly match the old linear lookup by returning the FIRST match for doomednum also shrinks the array, doomednum max is 4095, no need for such massive array, also fixed a off by should fix some join desynchs and desynchs on certain maps --- src/d_netcmd.c | 2 -- src/info.h | 2 ++ src/p_local.h | 2 +- src/p_mobj.c | 15 +++++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 870ceba69..c669da59b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4751,8 +4751,6 @@ static void Command_LocateLump_f(void) } } -#define MAXDOOMEDNUM 4095 - static void Command_ListDoomednums_f(void) { INT16 i, j, k = 0, l = 0; diff --git a/src/info.h b/src/info.h index 4ee851cee..c84d63214 100644 --- a/src/info.h +++ b/src/info.h @@ -19,6 +19,8 @@ #include "sounds.h" #include "m_fixed.h" +#define MAXDOOMEDNUM 4095 + // dehacked.c now has lists for the more named enums! PLEASE keep them up to date! // For great modding!! diff --git a/src/p_local.h b/src/p_local.h index 4b6530eb9..3c16b5c62 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -272,7 +272,7 @@ extern consvar_t cv_gravity; void P_RespawnSpecials(void); -extern mobjtype_t g_doomednum_to_mobjtype[UINT16_MAX]; +extern mobjtype_t g_doomednum_to_mobjtype[MAXDOOMEDNUM+1]; void CalculateDoomednumToMobjtype(void); mobj_t *P_AllocateMobj(void); diff --git a/src/p_mobj.c b/src/p_mobj.c index cd7d44a62..ad7982d87 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10463,17 +10463,20 @@ void P_PrecipitationEffects(void) } } -mobjtype_t g_doomednum_to_mobjtype[UINT16_MAX]; +mobjtype_t g_doomednum_to_mobjtype[MAXDOOMEDNUM+1] = {}; void CalculateDoomednumToMobjtype(void) { memset(g_doomednum_to_mobjtype, MT_NULL, sizeof(g_doomednum_to_mobjtype)); - for (size_t i = MT_NULL+1; i < NUMMOBJTYPES; i++) + for (size_t i = 0; i < NUMMOBJTYPES; i++) { - if (mobjinfo[i].doomednum > 0 && mobjinfo[i].doomednum <= UINT16_MAX) + const INT32 doomednum = mobjinfo[i].doomednum; + + if (doomednum > 0 && doomednum <= MAXDOOMEDNUM) { - g_doomednum_to_mobjtype[ mobjinfo[i].doomednum ] = i; + if (g_doomednum_to_mobjtype[doomednum] == MT_NULL) + g_doomednum_to_mobjtype[doomednum] = (mobjtype_t)i; } } } @@ -10551,7 +10554,7 @@ void P_RespawnSpecials(void) if (mthing) { - mobjtype_t i; + mobjtype_t i = MT_NULL; x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; ss = R_PointInSubsector(x, y); @@ -10987,7 +10990,7 @@ INT32 numhuntemeralds = 0; // void P_SpawnMapThing(mapthing_t *mthing) { - mobjtype_t i; + mobjtype_t i = MT_NULL; mobj_t *mobj; fixed_t x, y, z; subsector_t *ss; From 4a3c9ccfbb81f8c11d92213be6c0ffdfd08abbdd Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Dec 2025 21:36:29 +0100 Subject: [PATCH 046/589] Remove tic provision (vanilla compat edition) based on https://codeberg.org/srb2classic/srb2classic/commit/7cf14fbe740998c3246dd190904f49a236b2ccec seems to get rid of some jitter in localhost --- src/d_clisrv.c | 54 +++++++++++++------------------------------------- src/d_net.c | 3 ++- 2 files changed, 16 insertions(+), 41 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1a2717a12..ef78fe91a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -159,7 +159,6 @@ boolean nodeingame[MAXNETNODES] = {}; // set false as nodes leave game tic_t servermaxping = 20; // server's max delay, in frames. Defaults to 20 static tic_t nettics[MAXNETNODES]; // what tic the client have received -static tic_t supposedtics[MAXNETNODES]; // nettics prevision for smaller packet static UINT8 nodewaiting[MAXNETNODES]; static tic_t firstticstosend; // min of the nettics static tic_t tictoclear = 0; // optimize d_clearticcmd @@ -186,7 +185,6 @@ boolean hu_stopped = false; // Client specific static ticcmd_t localcmds[MAXSPLITSCREENPLAYERS][MAXGENTLEMENDELAY]; -static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server @@ -4296,7 +4294,6 @@ static void ResetNode(INT32 node) playerpernode[node] = 0; nettics[node] = gametic; - supposedtics[node] = gametic; sendingsavegame[node] = false; @@ -4351,7 +4348,7 @@ void SV_ResetServer(void) ClearAdminPlayers(); mynode = 0; - cl_packetmissed = false; + #ifdef SATURNPAK cl_redownloadinggamestate = false; #endif @@ -4453,7 +4450,7 @@ void D_QuitNetGame(void) static inline void SV_AddNode(INT32 node) { nettics[node] = gametic; - supposedtics[node] = gametic; + // little hack because the server connects to itself and puts // nodeingame when connected not here if (node) @@ -5535,14 +5532,6 @@ static void PT_ClientCmd(INT32 netconsole, SINT8 node) realstart = ExpandTics(netbuffer->u.clientpak.client_tic, nettics[node]); realend = ExpandTics(netbuffer->u.clientpak.resendfrom, nettics[node]); - if (netbuffer->packettype == PT_CLIENTMIS || netbuffer->packettype == PT_CLIENT2MIS - || netbuffer->packettype == PT_CLIENT3MIS || netbuffer->packettype == PT_CLIENT4MIS - || netbuffer->packettype == PT_NODEKEEPALIVEMIS - || supposedtics[node] < realend) - { - supposedtics[node] = realend; - } - // Discard out of order packet if (nettics[node] > realend) { @@ -5894,7 +5883,6 @@ static void PT_ServerTics(SINT8 node) if (realend > gametic + CLIENTBACKUPTICS) realend = gametic + CLIENTBACKUPTICS; - cl_packetmissed = realstart > neededtic; UINT8 *pak = (UINT8 *)&packet->cmds; UINT8 *txtpak = (UINT8 *)&packet->cmds[packet->numslots * packet->numtics]; @@ -6027,11 +6015,12 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_CLIENT2CMD: case PT_CLIENT3CMD: case PT_CLIENT4CMD: + case PT_NODEKEEPALIVE: + // "mis" tics kept for vanilla compat case PT_CLIENTMIS: case PT_CLIENT2MIS: case PT_CLIENT3MIS: case PT_CLIENT4MIS: - case PT_NODEKEEPALIVE: case PT_NODEKEEPALIVEMIS: PT_ClientCmd(netconsole, node); break; @@ -6323,25 +6312,18 @@ static void SV_SendServerKeepAlive(void) static void CL_SendClientCmd(void) { size_t packetsize = 0; - boolean mis = false; doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); netbuffer->packettype = PT_CLIENTCMD; - if (cl_packetmissed) - { - netbuffer->packettype = PT_CLIENTMIS; - mis = true; - } - netbuffer->u.clientpak.resendfrom = (UINT8)(neededtic & UINT8_MAX); netbuffer->u.clientpak.client_tic = (UINT8)(gametic & UINT8_MAX); if (gamestate == GS_WAITINGPLAYERS) { // Send PT_NODEKEEPALIVE packet - netbuffer->packettype = (mis ? PT_NODEKEEPALIVEMIS : PT_NODEKEEPALIVE); + netbuffer->packettype = PT_NODEKEEPALIVE; packetsize = sizeof (clientcmd_pak) - sizeof (ticcmd_t) - sizeof (INT16); HSendPacket(servernode, false, 0, packetsize); } @@ -6404,19 +6386,19 @@ static void CL_SendClientCmd(void) if (splitscreen || botingame) // Send a special packet with 2 cmd for splitscreen { - netbuffer->packettype = (mis ? PT_CLIENT2MIS : PT_CLIENT2CMD); + netbuffer->packettype = PT_CLIENT2CMD; packetsize = sizeof (client2cmd_pak); G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds[1][lagDelay], 1); if (splitscreen > 1) { - netbuffer->packettype = (mis ? PT_CLIENT3MIS : PT_CLIENT3CMD); + netbuffer->packettype = PT_CLIENT3CMD; packetsize = sizeof (client3cmd_pak); G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds[2][lagDelay], 1); if (splitscreen > 2) { - netbuffer->packettype = (mis ? PT_CLIENT4MIS : PT_CLIENT4CMD); + netbuffer->packettype = PT_CLIENT4CMD; packetsize = sizeof (client4cmd_pak); G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds[3][lagDelay], 1); } @@ -6471,14 +6453,13 @@ static void SV_SendTics(void) // send to all client but not to me // for each node create a packet with x tics and send it - // x is computed using supposedtics[n], max packet size and maketic + // x is computed using nettics[n], max packet size and maketic for (n = 1; n < MAXNETNODES; n++) { if (!nodeingame[n]) continue; - // assert supposedtics[n]>=nettics[n] - realfirsttic = supposedtics[n]; + realfirsttic = nettics[n]; lasttictosend = min(maketic, nettics[n] + CLIENTBACKUPTICS); if (realfirsttic >= lasttictosend) @@ -6487,8 +6468,8 @@ static void SV_SendTics(void) // to resent packet that are supposed lost (this is necessary since lost // packet detection work when we have received packet with firsttic > neededtic // (getpacket servertics case) - DEBFILE(va("Nothing to send node %u mak=%u sup=%u net=%u \n", - n, lasttictosend, supposedtics[n], nettics[n])); + DEBFILE(va("Nothing to send node %u mak=%u net=%u \n", + n, lasttictosend, nettics[n])); realfirsttic = nettics[n]; if (realfirsttic >= lasttictosend || (I_GetTime() + n)&3) // all tic are ok @@ -6568,17 +6549,10 @@ static void SV_SendTics(void) packsize = bufpos - (UINT8 *)&(netbuffer->u); HSendPacket(n, false, 0, packsize); - - // when tic are too large, only one tic is sent so don't go backward! - if (lasttictosend-doomcom->extratics > realfirsttic) - supposedtics[n] = lasttictosend-doomcom->extratics; - else - supposedtics[n] = lasttictosend; - - supposedtics[n] = max(supposedtics[n], nettics[n]); } + // node 0 is me! - supposedtics[0] = maketic; + nettics[0] = maketic; } // diff --git a/src/d_net.c b/src/d_net.c index fd8fb0e31..3e0d4410c 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -863,11 +863,12 @@ static void DebugPrintpacket(const char *header) case PT_CLIENT2CMD: case PT_CLIENT3CMD: case PT_CLIENT4CMD: + case PT_NODEKEEPALIVE: + // "mis" tics kept for vanilla compat case PT_CLIENTMIS: case PT_CLIENT2MIS: case PT_CLIENT3MIS: case PT_CLIENT4MIS: - case PT_NODEKEEPALIVE: case PT_NODEKEEPALIVEMIS: fprintf(debugfile, " tic %4u resendfrom %u\n", (UINT32)netbuffer->u.clientpak.client_tic, From 08864e27b2de8382ca7530feedc37e7f5783d3e5 Mon Sep 17 00:00:00 2001 From: PAS Date: Tue, 23 Dec 2025 17:17:32 -0500 Subject: [PATCH 047/589] Fix double byte-swap in SV_MakeTic --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ef78fe91a..729a8f698 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6626,7 +6626,7 @@ void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle) // create missed tic static void SV_Maketic(void) { - G_MoveTiccmd(netcmds[maketic % BACKUPTICS], playercmds, MAXPLAYERS); + G_CopyTiccmd(netcmds[maketic % BACKUPTICS], playercmds, MAXPLAYERS); maketic++; } From 25dd3b49762cc979f3ffe52395ff43446d3f0b5a Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 1 Dec 2025 23:00:22 +0100 Subject: [PATCH 048/589] Revert "Fix static memory being re-tagged as purgable" This reverts commit c544cf9a7cc5b6c21d20e71672273be02035df92. --- src/z_zone.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/z_zone.cpp b/src/z_zone.cpp index 549696bd7..9e5b4f41e 100644 --- a/src/z_zone.cpp +++ b/src/z_zone.cpp @@ -651,9 +651,6 @@ void Z_ChangeTag(void *ptr, INT32 tag) I_Error("Internal memory management error: " "tried to make block purgable but it has no owner"); - // No, please, don't make my PU_STATIC patch NULL! It supposed to be always valid! - if (block->tag < 10) return; - block->tag = tag; } From 40bd3e5e19d7dd853d65b0661e0bebece028cd82 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Dec 2025 23:18:19 +0100 Subject: [PATCH 049/589] simplify opengl vsync set --- src/sdl/i_video.c | 14 +++++++------- src/sdl/ogl_sdl.c | 10 +--------- src/sdl/ogl_sdl.h | 2 +- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c2d87e3f1..6be6bf638 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1426,7 +1426,7 @@ void I_FinishUpdate(void) #ifdef HWRENDER if (rendermode == render_opengl) { - OglSdlFinishUpdate(cv_vidwait.value); + OglSdlFinishUpdate(); return; } #endif @@ -2028,17 +2028,17 @@ UINT32 I_GetRefreshRate(void) static void Impl_SetVsync(void) { -#if SDL_VERSION_ATLEAST(2,0,18) - if (renderer) - SDL_RenderSetVSync(renderer, cv_vidwait.value); -#endif #ifdef HWRENDER - if (!renderer && rendermode == render_opengl && - sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext) + if (rendermode == render_opengl && + sdlglcontext != NULL && SDL_GL_GetCurrentContext() == sdlglcontext) { SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); } #endif +#if SDL_VERSION_ATLEAST(2,0,18) + if (renderer) + SDL_RenderSetVSync(renderer, cv_vidwait.value); +#endif } void I_SetBorderlessWindow(void) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 319acab4b..4177c121a 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -241,22 +241,14 @@ boolean OglSdlSurface(INT32 w, INT32 h) \return void */ -void OglSdlFinishUpdate(boolean waitvbl) +void OglSdlFinishUpdate(void) { - static boolean oldwaitvbl = false; int sdlw, sdlh; #ifdef USE_FBO_OGL const boolean usefbo = UseScreenFBO(); #endif - if (oldwaitvbl != waitvbl) - { - SDL_GL_SetSwapInterval(waitvbl ? 1 : 0); - } - - oldwaitvbl = waitvbl; - SDL_GetWindowSize(window, &sdlw, &sdlh); HWR_MakeScreenFinalTexture(); diff --git a/src/sdl/ogl_sdl.h b/src/sdl/ogl_sdl.h index 6d614cd22..8dd2b9e0e 100644 --- a/src/sdl/ogl_sdl.h +++ b/src/sdl/ogl_sdl.h @@ -20,7 +20,7 @@ boolean OglSdlSurface(INT32 w, INT32 h); -void OglSdlFinishUpdate(boolean vidwait); +void OglSdlFinishUpdate(void); boolean VID_LoadOGLAPI(void); extern SDL_Renderer *renderer; From 1af1e42daba79f343dc0b42ba3b5788a1079b434 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Dec 2025 23:20:30 +0100 Subject: [PATCH 050/589] FBO: remove nvidia xwayland hack this has been a non issue since a while now, so can remove this (we shouldnt work around driver bugs anyways) --- src/sdl/ogl_sdl.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 4177c121a..9e51efdc4 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -63,18 +63,9 @@ PFNglGetString pglGetString; #endif #ifdef USE_FBO_OGL - -#if defined (__unix__) -static boolean xwaylandcrap = false; -#endif - boolean UseScreenFBO(void) { - return ((supportFBO && cv_glframebuffer.value && downsample) -#if defined (__unix__) - || (supportFBO && xwaylandcrap) -#endif - ); + return (supportFBO && cv_glframebuffer.value && downsample); } #endif @@ -201,17 +192,6 @@ boolean OglSdlSurface(INT32 w, INT32 h) supportNPO2tex = true; glanisotropicmode_cons_t[1].value = maximumAnisotropy; - -#if defined (__unix__) -#ifdef USE_FBO_OGL - // TODO: delet this since nvidia fixed their shit on 575 - char videodriver[4] = {'S','D','L',0}; - if (supportFBO && strstr((const char*)gl_renderer, "NVIDIA") - && (*strncpy(videodriver, SDL_GetCurrentVideoDriver(), sizeof(videodriver)-1) != '\0') - && (strncasecmp("x11", videodriver, 4) == 0)) - xwaylandcrap = true; -#endif -#endif } SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); @@ -281,13 +261,6 @@ void OglSdlFinishUpdate(void) if (!I_CheckNativeRes() || WipeInAction) #endif HWR_DrawScreenFinalTexture(realwidth, realheight, false); - -#if defined (__unix__) -#ifdef USE_FBO_OGL - if (loaded_config) - xwaylandcrap = false; -#endif -#endif } #endif //HWRENDER From 7866b769cc542c6d9062cc022f4bf2d3afaa31e8 Mon Sep 17 00:00:00 2001 From: LJ Sonic Date: Sun, 21 Dec 2025 21:37:57 +0100 Subject: [PATCH 051/589] Do not archive table values for nil keys --- src/lua_script.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index 96ce94a22..2aa88cd52 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1064,9 +1064,13 @@ static void ArchiveTables(UINT8 **p) { // Write key e = ArchiveValue(p, TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this. - if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise) + if (e == 1) + n++; // the table contained a new table we'll have to archive. :( + else if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise) { CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i); + lua_pop(gL, 1); + continue; } else if (e == 3) // nil key due to invalid userdata. NOT an error. { @@ -1077,15 +1081,12 @@ static void ArchiveTables(UINT8 **p) // Write value e = ArchiveValue(p, TABLESINDEX, -1); if (e == 1) - { n++; // the table contained a new table we'll have to archive. :( - } else if (e == 2) // invalid value type - { CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1)); - } lua_pop(gL, 1); + } lua_pop(gL, 1); WRITEUINT8(*p, ARCH_TEND); @@ -1276,13 +1277,21 @@ static void UnArchiveTables(UINT8 **p, boolean network) UINT8 ret; ret = UnArchiveValue(p, TABLESINDEX, network); - if (ret == 3) + if (ret == 1) // End of table + break; + else if (ret == 2) // Key contains a new table + n++; + else if (ret == 3) { //CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); lua_pushnil(gL); } - else if (ret == 1) // read key - break; + + if (lua_isnil(gL, -1)) // If key is nil, skip this entry + { + lua_pop(gL, 1); + continue; + } ret = UnArchiveValue(p, TABLESINDEX, network); if (ret == 1) @@ -1291,21 +1300,15 @@ static void UnArchiveTables(UINT8 **p, boolean network) lua_pop(gL, 1); // Pop key break; } + else if (ret == 2) // read value + n++; else if (ret == 3) { //CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); lua_pushnil(gL); } - else if (ret == 2) // read value - n++; - if (lua_isnil(gL, -2)) // if key is nil (if a function etc was accidentally saved) - { - CONS_Alert(CONS_ERROR, "A nil key in table %d was found! (Invalid key type or corrupted save?)\n", i); - lua_pop(gL, 2); // pop key and value instead of setting them in the table, to prevent Lua panic errors - } - else - lua_rawset(gL, -3); + lua_rawset(gL, -3); } lua_pop(gL, 1); From 35e4f35f6e9867b3b143755a6c276a5946dee617 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Dec 2025 10:31:45 +0100 Subject: [PATCH 052/589] fix some shadowed variables, enable -Wshadow by default --- src/Makefile.d/versions.mk | 5 +---- src/hardware/hw_cache.cpp | 7 ++----- src/hardware/hw_main.cpp | 6 +++--- src/p_polyobj.c | 3 +-- src/r_segs.cpp | 10 +++++----- src/r_things.cpp | 2 +- 6 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 451ff72e7..48964c39f 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs +WFLAGS:=-Wall -Wno-trigraphs -Wshadow ifndef GCC295 #WFLAGS+=-Wno-packed endif @@ -37,9 +37,6 @@ WFLAGS+=-Wfloat-equal ifndef GCC295 WFLAGS+=-Wendif-labels endif -ifdef GCC41 - WFLAGS+=-Wshadow -endif #WFLAGS+=-Wlarger-than-%len% WFLAGS+=-Wpointer-arith CWFLAGS+=-Wbad-function-cast diff --git a/src/hardware/hw_cache.cpp b/src/hardware/hw_cache.cpp index c20d7e9bb..09f4f1a7b 100644 --- a/src/hardware/hw_cache.cpp +++ b/src/hardware/hw_cache.cpp @@ -619,7 +619,6 @@ static void HWR_PrecacheLevelFlats(void) // lookup for flats that may´ve been already loaded // too lazy to make a hashtable or smth so unordered set will do :carbuncle: std::unordered_set flatpresent; - lumpnum_t lump; size_t i, j; INT32 k; @@ -649,9 +648,8 @@ static void HWR_PrecacheLevelFlats(void) const INT32 pic = ceiling ? sec->ceilingpic : sec->floorpic; const levelflat_t *levelflat = &levelflats[pic]; - lump = levelflat->lumpnum; - load_flat(lump, R_NoEncore(sec, ceiling)); + load_flat(levelflat->lumpnum, R_NoEncore(sec, ceiling)); if (levelflat->speed) // is it an animated flat ? { @@ -672,9 +670,8 @@ static void HWR_PrecacheLevelFlats(void) for (i = 0; i < numlevelflats; i++) { const levelflat_t *levelflat = &levelflats[i]; - lump = levelflat->lumpnum; - load_flat(lump, false); + load_flat(levelflat->lumpnum, false); if (levelflat->speed) // is it an animated flat ? { diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index afe899df2..70a5a3a8d 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5538,7 +5538,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool player_t *viewplayer = &players[displayplayers[viewssnum]]; const float fpov = FixedToFloat(R_GetPlayerFov(viewplayer)); - auto reset_viewstate = [&](const float fpov) + auto reset_viewstate = [&]() { HWR_SetTransform(fpov); HWR_ClearSprites(); @@ -5558,7 +5558,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool currentportallist = &portallist; HWR_SetPortalState(GLPORTAL_SEARCH); - reset_viewstate(fpov); + reset_viewstate(); if (rootportal) { @@ -5584,7 +5584,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool // draw normal things in current frame in current incremented stencil buffer area HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); - reset_viewstate(fpov); + reset_viewstate(); if constexpr (Type == RenderViewpointType::kPortal) { diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 7b5135c9e..94c808b22 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1385,8 +1385,7 @@ static void Polyobj_rotateThings(polyobj_t *po, vector2_t origin, angle_t delta, if (mo->player) { - angle_t localangle = P_GetLocalAngle(mo->player); - P_ForceLocalAngle(mo->player, localangle + delta); + P_ForceLocalAngle(mo->player, P_GetLocalAngle(mo->player) + delta); } } } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index c0aab2bfc..3fe8042ae 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -2229,12 +2229,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) lowcutslope = std::max(worldbottomslope, worldlowslope) + viewz; highcutslope = std::min(worldtopslope, worldhighslope) + viewz; - auto check_fof_offscreen = [&](ffloor_t* rover, INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope) + auto check_fof_offscreen = [&](ffloor_t* rrover, INT32 bottom, INT32 bottomslope, INT32 top, INT32 topslope) { - return ((P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= bottom + viewz - && P_GetFFloorTopZAt (rover, segright.x, segright.y) <= bottomslope + viewz) - || ( P_GetFFloorBottomZAt (rover, segleft .x, segleft .y) >= top + viewz - && P_GetFFloorBottomZAt (rover, segright.x, segright.y) >= topslope + viewz)); + return ((P_GetFFloorTopZAt (rrover, segleft .x, segleft .y) <= bottom + viewz + && P_GetFFloorTopZAt (rrover, segright.x, segright.y) <= bottomslope + viewz) + || ( P_GetFFloorBottomZAt (rrover, segleft .x, segleft .y) >= top + viewz + && P_GetFFloorBottomZAt (rrover, segright.x, segright.y) >= topslope + viewz)); }; if (frontsector->ffloors && backsector->ffloors) diff --git a/src/r_things.cpp b/src/r_things.cpp index 489ce8911..b62d9e5d7 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1577,7 +1577,7 @@ static void R_ProjectSprite(mobj_t *thing) else blendmode = thing->blendmode; - if (thing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility) + if (thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility) trans = tr_trans80; // because now the translucency is set through FF_TRANSMASK else if (thing->frame & FF_TRANSMASK) { From b0bf588c27363f192b14e2b795fa7f761fce297b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Dec 2025 10:52:21 +0100 Subject: [PATCH 053/589] fix some null pointer dereferences and enable -Wnull-dereference by default --- src/Makefile.d/versions.mk | 2 +- src/m_misc.c | 9 +++++---- src/s_sound.c | 3 +++ src/w_wad.c | 19 ++++++++++++++++++- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 48964c39f..149fb30fc 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs -Wshadow +WFLAGS:=-Wall -Wno-trigraphs -Wshadow -Wnull-dereference ifndef GCC295 #WFLAGS+=-Wno-packed endif diff --git a/src/m_misc.c b/src/m_misc.c index cbc40d4e2..8c7b34163 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1346,14 +1346,15 @@ void M_MinimapGenerate(void) minigen = AM_MinimapGenerate(mul); if (minigen == NULL || minigen->buf == NULL) - goto failure; + { + CONS_Alert(CONS_ERROR, M_GetText("Couldn't create %s\n"), filepath); + return; + } M_CreateScreenShotPalette(); ret = M_SavePNG(filepath, minigen->buf, minigen->w, minigen->h, screenshot_palette); -failure: - if (minigen->buf != NULL) - free(minigen->buf); + free(minigen->buf); if (ret) { diff --git a/src/s_sound.c b/src/s_sound.c index 5bc830252..e8075469c 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1491,6 +1491,9 @@ musicdef_t *S_FindMusicCredit(const char *musname) { def = S_GetMusicCredit(i); + if (!def) + continue; + if (hash != def->hash) continue; diff --git a/src/w_wad.c b/src/w_wad.c index 640ee0367..9be91c8ea 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1997,6 +1997,9 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag) rspr = (rotsprite_t *)W_GetCachedRotPatchPwad(WADFILENUM(num),LUMPNUM(num)); + if (rspr == NULL) + return W_CachePatchNum(W_GetNumForName("MISSING"), tag); + if (rspr->patches[idx] == NULL) { INT32 xpivot = 0, ypivot = 0; @@ -2612,6 +2615,9 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) // Remember that we're assuming that the WAD will have a specific set of lumps in a specific order. UINT8 *wadData = (UINT8*)(W_CacheLumpNum(lumpnum, PU_LEVEL)); + if (wadData == NULL) + I_Error("vres_GetMap: Invalid WadData!\n"); + filelump_t *fileinfo = (filelump_t *)(wadData + LONG(((wadinfo_t *)wadData)->infotableofs)); i = LONG(((wadinfo_t *)wadData)->numlumps); @@ -2628,6 +2634,8 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) } vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL)); + if (vlumps == NULL) + I_Error("vres_GetMap: Out of memory!\n"); // Build the lumps, skipping over empty entries. for (i = 0, realentry = 0; i < numlumps; realentry++) @@ -2663,7 +2671,11 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) lumpnum_t lumppos = lumpnum + 1; for (i = LUMPNUM(lumppos); i < wadfiles[WADFILENUM(lumpnum)]->numlumps; i++, lumppos++, numlumps++) { - if (memcmp(W_CheckNameForNum(lumppos), "MAP", 3) == 0 || W_LumpLength(lumppos) == 0) + const char *name = W_CheckNameForNum(lumppos); + if (name == NULL) + continue; + + if (memcmp(name, "MAP", 3) == 0 || W_LumpLength(lumppos) == 0) { break; } @@ -2671,10 +2683,15 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) numlumps++; vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL)); + if (vlumps == NULL) + I_Error("vres_GetMap: Out of memory!\n"); + for (i = 0; i < numlumps; i++, lumpnum++) { // Check if it is map marker. It is not always first lump sadly, so we need to expect it anywhere const char *name = W_CheckNameForNum(lumpnum); + if (name == NULL) + continue; if (strlen(name) == 5 && memcmp(name, "MAP", 3) == 0) { From f38ca9aa28bbb7e9c80f36d2afa3b6b197dfa26b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Dec 2025 12:40:50 +0100 Subject: [PATCH 054/589] Signal Handler: Add button to report issues to github mostly based on what srb2 does with some stuff from srb2-legacy the button will attempt to open the issue page on the saturn git when a crash occurs --- src/sdl/i_system.cpp | 80 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 0c024a5bd..354eb0427 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1388,7 +1388,7 @@ void I_SleepDuration(precise_t duration) #endif } -static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg); +static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg, char *signal_ttl); #ifdef HAVE_LIBBACKTRACE #include @@ -1484,6 +1484,7 @@ static void bt_error_cb(void *data, const char *msg, int errnum) static void write_backtrace(bt_crash_reason_t reason) { char sig_msg[512]; + char sig_name[128]; const char *filename = va("%s" PATHSEP CRASH_LOGFILE_NAME, srb2home); FILE *out = fopen(filename, "a+"); @@ -1540,8 +1541,8 @@ static void write_backtrace(bt_crash_reason_t reason) switch (reason.type) { case BTCRASH_SIGNAL: - I_PrintSignal(reason.value.signal, false, sig_msg); - fprintf(out, "%s", sig_msg); + I_PrintSignal(reason.value.signal, false, sig_msg, sig_name); + fprintf(out, "%s - %s", sig_name, sig_msg); break; case BTCRASH_ERRORMSG: @@ -1577,42 +1578,49 @@ static std::thread::id g_main_thread_id; boolean g_in_exiting_signal_handler = false; -static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg) +static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg, char *signal_name) { - const char *sigmsg; + const char *sigmsg, *signame; switch (signal_num) { #ifdef SIGINT case SIGINT: - sigmsg = ("SIGINT - SRB2Kart-Saturn was interrupted prematurely by the user."); + sigmsg = ("SRB2Kart-Saturn was interrupted prematurely by the user."); + signame = "SIGINT"; break; #endif case SIGILL: // illegal instruction - invalid function image - sigmsg = ("SIGILL - SRB2Kart-Saturn has attempted to execute an illegal instruction and needs to close."); + sigmsg = ("SRB2Kart-Saturn has attempted to execute an illegal instruction and needs to close."); + signame = "SIGILL"; break; case SIGFPE: // mathematical exception - sigmsg = ("SIGFPE - SRB2Kart-Saturn has encountered a mathematical exception and needs to close."); + sigmsg = ("SRB2Kart-Saturn has encountered a mathematical exception and needs to close."); + signame = "SIGFPE"; break; case SIGSEGV: // segment violation - sigmsg = ("SIGSEGV - SRB2Kart-Saturn has attempted to access a memory location that it shouldn't and needs to close."); + sigmsg = ("SRB2Kart-Saturn has attempted to access a memory location that it shouldn't and needs to close."); + signame = "SIGSEGV"; break; #ifdef SIGTERM case SIGTERM: // Software termination signal from kill - sigmsg = ("SIGTERM - SRB2Kart-Saturn was terminated by a kill signal."); + sigmsg = ("SRB2Kart-Saturn was terminated by a kill signal."); + signame = "SIGTERM"; break; #endif #ifdef SIGBREAK case SIGBREAK: // Ctrl-Break sequence sigmsg =("SIGBREAK - SRB2Kart-Saturn was terminated by a Ctrl-Break sequence."); + signame = "SIGBREAK"; break; #endif case SIGABRT: // abnormal termination triggered by abort call - sigmsg = ("SIGABRT - SRB2Kart-Saturn was terminated by an abort signal."); + sigmsg = ("SRB2Kart-Saturn was terminated by an abort signal."); + signame = "SIGABRT"; break; default: - sprintf(signal_msg, "Signal number %d", signal_num); - sigmsg = (core_dumped ? "Unknown signal" : signal_msg); + sigmsg = "SRB2Kart-Saturn was terminated by an unknown signal."; + signame = core_dumped ? "Unknown signal" : va("Signal number %d", signal_num); break; } @@ -1627,18 +1635,58 @@ static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_ms { sprintf(signal_msg, "%s", sigmsg); } + + sprintf(signal_name, "%s", signame); +} + +static int I_OpenURL(const char *url) +{ +#if SDL_VERSION_ATLEAST(2,0,14) + return SDL_OpenURL(va("%s", url)); +#else + return -1; +#endif } static void I_ReportSignal(int num, int coredumped) { char sigmsg[512]; + char signame[128]; + char sigttl[512] = "Process killed by signal: "; + const char *reportmsg = "\n\n\nTo help us figure out the cause, please report the issue to our github page with " CRASH_LOGFILE_NAME " attached.\n\nSorry for the inconvenience!"; - I_PrintSignal(num, coredumped, sigmsg); + I_PrintSignal(num, coredumped, sigmsg, signame); size_t len = strlen(sigmsg); snprintf(sigmsg + len, sizeof(sigmsg) - len, "\n\nCrash report has been saved into %s", CRASH_LOGFILE_NAME); - I_OutputMsg("\nProcess killed by signal: %s\n\n", sigmsg); - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Process killed by signal", sigmsg, NULL); + + strcat(sigttl, signame); + I_OutputMsg("\n%s\n\n", sigttl); + + if (M_CheckParm("-dedicated")) + return; + + const SDL_MessageBoxButtonData buttons[] = { + { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "OK" }, + { 0, 1, "Report Issue" }, + }; + + const SDL_MessageBoxData messageboxdata = { + SDL_MESSAGEBOX_ERROR, /* .flags */ + NULL, /* .window */ + sigttl, /* .title */ + va("%s %s", sigmsg, reportmsg), /* .message */ + SDL_arraysize(buttons), /* .numbuttons */ + buttons, /* .buttons */ + NULL /* .colorScheme */ + }; + + int buttonid; + + SDL_ShowMessageBox(&messageboxdata, &buttonid); + + if (buttonid == 1) + I_OpenURL("https://github.com/Indev450/SRB2Kart-Saturn/issues"); } #ifndef NEWSIGNALHANDLER From 495c34dd401b54cc2ee3aef2e55ec98802a1dccb Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Dec 2025 13:02:21 +0100 Subject: [PATCH 055/589] fix gcc version detection fallback stuff latest_gcc_version should always just be X.x not X.x.x this broke some warning flags for me --- src/Makefile.d/detect.mk | 4 ++-- src/Makefile.d/versions.mk | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk index dd31d2f3e..7ff978397 100644 --- a/src/Makefile.d/detect.mk +++ b/src/Makefile.d/detect.mk @@ -64,7 +64,7 @@ endif # This must have high to low order. gcc_versions:=\ - 151 150 15\ + 152 151 150 15\ 142 141 140 14\ 132 131 130 13\ 123 122 121 120 12\ @@ -77,7 +77,7 @@ gcc_versions:=\ 55 54 53 52 51 50\ 49 48 47 46 45 44 43 42 41 40 -latest_gcc_version:=15.1.1 +latest_gcc_version:=15.2 # Automatically set version flag, but not if one was # manually set. And don't bother if this is a clean only diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 149fb30fc..2a80cfa39 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs -Wshadow -Wnull-dereference +WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference ifndef GCC295 #WFLAGS+=-Wno-packed endif @@ -37,6 +37,9 @@ WFLAGS+=-Wfloat-equal ifndef GCC295 WFLAGS+=-Wendif-labels endif +ifdef GCC41 + WFLAGS+=-Wshadow +endif #WFLAGS+=-Wlarger-than-%len% WFLAGS+=-Wpointer-arith CWFLAGS+=-Wbad-function-cast From a2616778cc06a2f2c42a09da6b6eb4342a6f6d9d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Dec 2025 15:06:50 +0100 Subject: [PATCH 056/589] fix another -Wnull-dereference warning --- src/w_wad.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index 9be91c8ea..524bd97de 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1998,13 +1998,15 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag) rspr = (rotsprite_t *)W_GetCachedRotPatchPwad(WADFILENUM(num),LUMPNUM(num)); if (rspr == NULL) - return W_CachePatchNum(W_GetNumForName("MISSING"), tag); + return W_CachePatchNum(num, tag); if (rspr->patches[idx] == NULL) { INT32 xpivot = 0, ypivot = 0; ptr = (patch_t *)W_CachePatchNum(num, PU_PATCH); + if (ptr == NULL) + return W_CachePatchNum(num, tag); // >y pivot centered // >x pivot not centered From 9639ace28a4c2ad1e1587fda4928c2e9e3a791d6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Dec 2025 15:07:13 +0100 Subject: [PATCH 057/589] fix dedicated server build warnings --- src/android/i_system.c | 4 ---- src/dedicated/i_system.c | 10 +++------- src/i_system.h | 4 ++++ src/i_video.h | 11 +++++++++-- src/sdl/i_system.cpp | 18 ++++++++---------- src/sdl/i_video.c | 9 ++++++--- src/sdl/mixer_sound.c | 4 ++-- src/sdl/ogl_sdl.c | 3 +-- src/sdl/ogl_sdl.h | 4 +--- src/sdl/sdlmain.h | 18 ------------------ 10 files changed, 34 insertions(+), 51 deletions(-) diff --git a/src/android/i_system.c b/src/android/i_system.c index 102bff461..ef10df5b5 100644 --- a/src/android/i_system.c +++ b/src/android/i_system.c @@ -226,10 +226,6 @@ const char *I_LocateWad(void) return "/sdcard/srb2"; } -void I_GetJoystickEvents(void){} - -void I_GetJoystick2Events(void){} - char *I_GetEnv(const char *name) { LOGW("I_GetEnv() called?!"); diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 31eaf0346..4d52ffa70 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -167,6 +167,8 @@ static char returnWadPath[256]; #include "../i_video.h" #include "../i_sound.h" #include "../i_system.h" +#include "../i_time.h" +#include "../i_net.h" #include "../screen.h" //vid.WndParent #include "../d_net.h" #include "../g_game.h" @@ -196,8 +198,6 @@ UINT8 keyboard_started = false; #ifdef HAVE_TERMIOS // TERMIOS console code from Quake3: thank you! -boolean stdin_active = true; - typedef struct { size_t cursor; @@ -699,11 +699,7 @@ void I_JoyScale4(void) */ -void I_ShutdownJoystick(void) -{ -} - -void I_GetJoystickEvents(UINT8 index) +void I_ShutdownJoystick(UINT8 index) { (void)index; } diff --git a/src/i_system.h b/src/i_system.h index 7084c655f..97dfae9a1 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -29,6 +29,10 @@ extern "C" { */ #define MAX_QUIT_FUNCS 16 +void I_GetConsoleEvents(void); + +extern boolean consolevent; +extern boolean framebuffer; /** \brief Graphic system had started up */ diff --git a/src/i_video.h b/src/i_video.h index f28b5a601..9a43f82a7 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -125,8 +125,6 @@ boolean I_CheckNativeRes(void); void I_SetBorderlessWindow(void); -void I_HandleControllerHatRepeat(void); - #ifdef USE_FBO_OGL void RefreshOGLSDLSurface(void); @@ -135,6 +133,15 @@ boolean UseScreenFBO(void); extern boolean downsample; #endif +// So we can call this from i_video event loop +void I_ShutdownJoystick(UINT8 index); + +// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination +void I_UpdateJoystickDeviceIndex(UINT8 player); +void I_UpdateJoystickDeviceIndices(UINT8 excludePlayer); + +void I_HandleControllerHatRepeat(void); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 0c024a5bd..66d8e4bb4 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -213,14 +213,12 @@ static char returnWadPath[256]; #include "../byteptr.h" #endif -SDL_bool consolevent = SDL_FALSE; -SDL_bool framebuffer = SDL_FALSE; +boolean consolevent = false; +boolean framebuffer = false; UINT8 keyboard_started = false; #ifdef HAVE_TERMIOS // TERMIOS console code from Quake3: thank you! -SDL_bool stdin_active = SDL_TRUE; - typedef struct { size_t cursor; @@ -282,7 +280,7 @@ static void I_ShutdownConsole(void) if (consolevent) { I_OutputMsg("Shutdown tty console\n"); - consolevent = SDL_FALSE; + consolevent = false; tcsetattr(STDIN_FILENO, TCSADRAIN, &tty_tc); } } @@ -301,7 +299,7 @@ static void I_StartupConsole(void) framebuffer = static_cast( M_CheckParm("-framebuffer")); if (framebuffer) - consolevent = SDL_FALSE; + consolevent = false; if (!consolevent) return; @@ -309,7 +307,7 @@ static void I_StartupConsole(void) if (isatty(STDIN_FILENO)!=1) { I_OutputMsg("stdin is not a tty, tty console mode failed\n"); - consolevent = SDL_FALSE; + consolevent = false; return; } @@ -511,7 +509,7 @@ static void I_StartupConsole(void) if (gotConsole) { SetConsoleTitleA("SRB2Kart Console"); - consolevent = SDL_TRUE; + consolevent = true; } //Let get the real console HANDLE, because Mingw's Bash is bad! @@ -544,7 +542,7 @@ static inline void I_StartupConsole(void) framebuffer = M_CheckParm("-framebuffer"); if (framebuffer) - consolevent = SDL_FALSE; + consolevent = false; } static inline void I_ShutdownConsole(void){} #endif @@ -765,7 +763,7 @@ void I_JoyScale4(void) } // Cheat to get the device index for a joystick handle -INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev) +static INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev) { SDL_Joystick *joystick = NULL; diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 6be6bf638..72354ca1e 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -155,9 +155,12 @@ static SDL_bool usesdl2soft = SDL_FALSE; static SDL_bool borderlesswindow = SDL_FALSE; // SDL2 vars -SDL_Window *window = NULL; -SDL_Renderer *renderer = NULL; +static SDL_Window *window = NULL; +static SDL_Renderer *renderer = NULL; static SDL_Texture *texture = NULL; +#ifdef HWRENDER +static SDL_GLContext sdlglcontext = NULL; +#endif static SDL_bool havefocus = SDL_TRUE; static const char *fallback_resolution_name = "Fallback"; @@ -1426,7 +1429,7 @@ void I_FinishUpdate(void) #ifdef HWRENDER if (rendermode == render_opengl) { - OglSdlFinishUpdate(); + OglSdlFinishUpdate(window); return; } #endif diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 529b47399..272e48a1b 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -461,7 +461,7 @@ void *I_GetSfx(sfxinfo_t *sfx) gme_track_info(emu, &info, 0); len = (info->play_length * 441 / 10) << 2; - mem = Z_Malloc(len, PU_SOUND, 0); + mem = Z_Malloc(len, PU_SOUND, NULL); gme_play(emu, len >> 1, mem); gme_free_info(info); @@ -499,7 +499,7 @@ void *I_GetSfx(sfxinfo_t *sfx) gme_track_info(emu, &info, 0); len = (info->play_length * 441 / 10) << 2; - mem = Z_Malloc(len, PU_SOUND, 0); + mem = Z_Malloc(len, PU_SOUND, NULL); gme_play(emu, len >> 1, mem); gme_free_info(info); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 9e51efdc4..d50cdbe93 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -72,7 +72,6 @@ boolean UseScreenFBO(void) /** \brief SDL video display surface */ INT32 oglflags = 0; -SDL_GLContext sdlglcontext = NULL; void *GetGLFunc(const char *proc) { @@ -221,7 +220,7 @@ boolean OglSdlSurface(INT32 w, INT32 h) \return void */ -void OglSdlFinishUpdate(void) +void OglSdlFinishUpdate(SDL_Window *window) { int sdlw, sdlh; diff --git a/src/sdl/ogl_sdl.h b/src/sdl/ogl_sdl.h index 8dd2b9e0e..9bdebc715 100644 --- a/src/sdl/ogl_sdl.h +++ b/src/sdl/ogl_sdl.h @@ -20,11 +20,9 @@ boolean OglSdlSurface(INT32 w, INT32 h); -void OglSdlFinishUpdate(void); +void OglSdlFinishUpdate(SDL_Window *window); boolean VID_LoadOGLAPI(void); -extern SDL_Renderer *renderer; -extern SDL_GLContext sdlglcontext; extern Uint16 realwidth; extern Uint16 realheight; diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index c711d68d7..e5bdca395 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -23,9 +23,6 @@ extern "C" { #endif -extern SDL_bool consolevent; -extern SDL_bool framebuffer; - #include "../m_fixed.h" // SDL2 stub macro @@ -67,21 +64,6 @@ extern SDLJoyInfo_t JoyInfo[4]; //MAXSPLITSCREENPLAYERS #define SDL_JDEADZONE 153 #undef SDL_JDEADZONE -// So we can call this from i_video event loop -void I_ShutdownJoystick(UINT8 index); - -// Cheat to get the device index for a game controller handle -INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev); - -// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination -void I_UpdateJoystickDeviceIndex(UINT8 player); -void I_UpdateJoystickDeviceIndices(UINT8 excludePlayer); - -void I_GetConsoleEvents(void); - -// Needed for some WIN32 functions -extern SDL_Window *window; - #ifdef __cplusplus } // extern "C" #endif From 67e74b5874a4edc19c504947421151eab77f307c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Dec 2025 15:13:13 +0100 Subject: [PATCH 058/589] fix w_wad oopsie --- src/w_wad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 524bd97de..7e1ec30df 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1998,7 +1998,7 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag) rspr = (rotsprite_t *)W_GetCachedRotPatchPwad(WADFILENUM(num),LUMPNUM(num)); if (rspr == NULL) - return W_CachePatchNum(num, tag); + return W_CachePatchNum(W_GetNumForName("MISSING"), tag); if (rspr->patches[idx] == NULL) { @@ -2006,7 +2006,7 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag) ptr = (patch_t *)W_CachePatchNum(num, PU_PATCH); if (ptr == NULL) - return W_CachePatchNum(num, tag); + return W_CachePatchNum(W_GetNumForName("MISSING"), tag); // >y pivot centered // >x pivot not centered From c0cce90e601c1948ba82bcfeda35093801712b11 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Dec 2025 15:34:18 +0100 Subject: [PATCH 059/589] properly handle getcwd error in IdentifyVersion if getcwd fails, the buffer contents will be undefined so we shall just overwrite it again with "." --- src/d_main.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index c46ef0c44..f37d70a2c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1186,17 +1186,13 @@ static void IdentifyVersion(void) #endif char tempsrb2path[256] = "."; - getcwd(tempsrb2path, 256); + if (getcwd(tempsrb2path, 256) == NULL) + strcpy(tempsrb2path, "."); // get the current directory (possible problem on NT with "." as current dir) if (!srb2waddir) { - if (tempsrb2path[0]) - srb2waddir = tempsrb2path; - else - { - srb2waddir = "."; - } + srb2waddir = tempsrb2path; } #if (1) // reduce the amount of findfile by only using full cwd in this func From a2de1e24c5a835ab052238ad61ba7d0a7b47a53d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Dec 2025 17:46:37 +0100 Subject: [PATCH 060/589] d_cliserv: fix casts from nan to int type in few cases the files totalsize might be 0, which results in a nan, casting that to int type is undefined behavior --- src/d_clisrv.c | 68 ++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6cf50a4d3..d4983daa2 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -365,7 +365,7 @@ void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_ CONS_Alert(CONS_NOTICE, M_GetText("NetXCmd buffer full, delaying netcmd %d... (size: %d, needed: %s)\n"), id, localtextcmd[playerid][0], sizeu1(nparam)); if (buf == NULL) { - textcmdbuf[playerid] = Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL); + textcmdbuf[playerid] = (textcmdbuf_t*)Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL); textcmdbuf[playerid]->cmd[0] = 0; textcmdbuf[playerid]->next = NULL; WriteNetXCmd(textcmdbuf[playerid]->cmd, id, param, nparam); @@ -377,7 +377,7 @@ void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_ if (buf->cmd[0]+2+nparam > MAXTEXTCMD) { - buf->next = Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL); + buf->next = (textcmdbuf_t*)Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL); buf->next->cmd[0] = 0; buf->next->next = NULL; WriteNetXCmd(buf->next->cmd, id, param, nparam); @@ -454,13 +454,13 @@ static UINT8* D_GetTextcmd(tic_t tic, INT32 playernum) // If we don't have an entry for the tic, make it. if (!textcmdtic) { - textcmdtic = *tctprev = Z_Calloc(sizeof (textcmdtic_t), PU_STATIC, NULL); + textcmdtic = *tctprev = (textcmdtic_t*)Z_Calloc(sizeof (textcmdtic_t), PU_STATIC, NULL); textcmdtic->tic = tic; } // If we don't have an entry for the player, make it. if (!textcmdtic->playercmds[playernum]) - textcmdtic->playercmds[playernum] = Z_Calloc(MAXTEXTCMD, PU_STATIC, NULL); + textcmdtic->playercmds[playernum] = (UINT8*)Z_Calloc(MAXTEXTCMD, PU_STATIC, NULL); return textcmdtic->playercmds[playernum]; } @@ -1141,7 +1141,7 @@ typedef enum static void GetPackets(void); static cl_mode_t cl_mode = CL_SEARCHING; -static UINT16 cl_lastcheckedfilecount = 0; // used for full file list +static UINT16 cl_lastcheckedfilecount = 0; // used for full file list // Player name send/load @@ -1182,7 +1182,7 @@ static void CV_LoadPlayerNames(UINT8 **p) // // Keep the local client informed of our status. // -static inline void CL_DrawConnectionStatus(void) +static void CL_DrawConnectionStatus(void) { INT32 ccstime = I_GetTime(); @@ -1217,21 +1217,23 @@ static inline void CL_DrawConnectionStatus(void) case CL_DOWNLOADSAVEGAME: if (filedownload.current != -1) { - UINT32 currentsize = fileneeded[filedownload.current].currentsize; - UINT32 totalsize = fileneeded[filedownload.current].totalsize; - INT32 dldlength; + INT32 dldlength = 0; + fileneeded_t *file = &fileneeded[filedownload.current]; + UINT32 currentsize = file->currentsize; + UINT32 totalsize = file->totalsize; cltext = M_GetText("Downloading game state..."); Net_GetNetStat(); - dldlength = (INT32)((currentsize/(double)totalsize) * 256); + if (totalsize != 0) + dldlength = (INT32)((currentsize/(double)totalsize) * 256); if (dldlength > 256) dldlength = 256; V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 111); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, dldlength, 8, 96); V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, - va(" %4uK/%4uK",currentsize>>10,totalsize>>10)); + va(" %4uK/%4uK", currentsize>>10, totalsize>>10)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, va("%3.1fK/s ", ((double)getbps)/1024)); @@ -1270,29 +1272,30 @@ static inline void CL_DrawConnectionStatus(void) { if (cl_mode == CL_CHECKFILES) { - INT32 totalfileslength; + INT32 totalfileslength = 0; INT32 checkednum = 0; INT32 i; V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-24, V_YELLOWMAP|MENUCAPS, "Press ESC to abort"); - //ima just count files here + // ima just count files here for (i = 0; i < fileneedednum; i++) if (fileneeded[i].status != FS_NOTCHECKED) checkednum++; // Loading progress V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, "Checking server addons..."); - totalfileslength = (INT32)((checkednum/(double)(fileneedednum)) * 256); + if (fileneedednum != 0) + totalfileslength = (INT32)((checkednum/(double)fileneedednum) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %2u/%2u Files",checkednum,fileneedednum)); + va(" %2u/%2u Files", checkednum, fileneedednum)); } else if (cl_mode == CL_LOADFILES) { - INT32 totalfileslength; + INT32 totalfileslength = 0; INT32 loadcompletednum = 0; INT32 i; @@ -1305,12 +1308,13 @@ static inline void CL_DrawConnectionStatus(void) // Loading progress V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, "Loading server addons..."); - totalfileslength = (INT32)((loadcompletednum/(double)(fileneedednum)) * 256); + if (fileneedednum != 0) + totalfileslength = (INT32)((loadcompletednum/(double)fileneedednum) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %2u/%2u Files",loadcompletednum,fileneedednum)); + va(" %2u/%2u Files", loadcompletednum, fileneedednum)); } else if (cl_mode == CL_VIEWSERVER) { @@ -1438,19 +1442,22 @@ static inline void CL_DrawConnectionStatus(void) } else if (filedownload.current != -1) { - INT32 dldlength; - INT32 totalfileslength; - UINT32 totaldldsize; + INT32 dldlength = 0; + INT32 totalfileslength = 0; + UINT32 totaldldsize = 0; static char tempname[28]; fileneeded_t *file = &fileneeded[filedownload.current]; char *filename = file->filename; + UINT32 currentsize = file->currentsize; + UINT32 totalsize = file->totalsize; // Draw the bottom box. M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-14, V_YELLOWMAP|MENUCAPS, "Press ESC to abort"); Net_GetNetStat(); - dldlength = (INT32)((file->currentsize/(double)file->totalsize) * 256); + if (totalsize != 0) + dldlength = (INT32)((currentsize/(double)totalsize) * 256); if (dldlength > 256) dldlength = 256; V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, 256, 8, 175); @@ -1483,29 +1490,30 @@ static inline void CL_DrawConnectionStatus(void) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-22, V_YELLOWMAP|MENUCAPS, va(M_GetText("\"%s\""), tempname)); V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uK/%4uK",file->currentsize>>10,file->totalsize>>10)); + va(" %4uK/%4uK", currentsize>>10, totalsize>>10)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS, - va("%3.1fK/s ", ((double)getbps)/1024)); + va("%3.1fK/s ", ((double)getbps)/1024.0)); // Download progress - if (file->currentsize != file->totalsize) - totaldldsize = filedownload.completedsize+file->currentsize; //Add in single file progress download if applicable + if (currentsize != totalsize) + totaldldsize = filedownload.completedsize+currentsize; // Add in single file progress download if applicable else totaldldsize = filedownload.completedsize; V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP|MENUCAPS, "Overall Download Progress"); - totalfileslength = (INT32)((totaldldsize/(double)filedownload.totalsize) * 256); + if (filedownload.totalsize != 0) + totalfileslength = (INT32)((totaldldsize/(double)filedownload.totalsize) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); - if (filedownload.totalsize>>20 >= 10) //display in MB if over 10MB + if (filedownload.totalsize>>20 >= 10) // display in MB if over 10MB V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uM/%4uM",totaldldsize>>20,filedownload.totalsize>>20)); + va(" %4uM/%4uM", totaldldsize>>20, filedownload.totalsize>>20)); else V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uK/%4uK",totaldldsize>>10,filedownload.totalsize>>10)); + va(" %4uK/%4uK", totaldldsize>>10, filedownload.totalsize>>10)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va("%2u/%2u Files ", filedownload.completednum, filedownload.totalnum)); From 39a46e8f79ed4032b78b058817bf010e4923c6f3 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 30 Dec 2025 01:09:14 +0100 Subject: [PATCH 061/589] Revert "Remove tic provision (vanilla compat edition)" This reverts commit 4a3c9ccfbb81f8c11d92213be6c0ffdfd08abbdd. --- src/d_clisrv.c | 54 +++++++++++++++++++++++++++++++++++++------------- src/d_net.c | 3 +-- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 729a8f698..5125a6c7b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -159,6 +159,7 @@ boolean nodeingame[MAXNETNODES] = {}; // set false as nodes leave game tic_t servermaxping = 20; // server's max delay, in frames. Defaults to 20 static tic_t nettics[MAXNETNODES]; // what tic the client have received +static tic_t supposedtics[MAXNETNODES]; // nettics prevision for smaller packet static UINT8 nodewaiting[MAXNETNODES]; static tic_t firstticstosend; // min of the nettics static tic_t tictoclear = 0; // optimize d_clearticcmd @@ -185,6 +186,7 @@ boolean hu_stopped = false; // Client specific static ticcmd_t localcmds[MAXSPLITSCREENPLAYERS][MAXGENTLEMENDELAY]; +static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server @@ -4294,6 +4296,7 @@ static void ResetNode(INT32 node) playerpernode[node] = 0; nettics[node] = gametic; + supposedtics[node] = gametic; sendingsavegame[node] = false; @@ -4348,7 +4351,7 @@ void SV_ResetServer(void) ClearAdminPlayers(); mynode = 0; - + cl_packetmissed = false; #ifdef SATURNPAK cl_redownloadinggamestate = false; #endif @@ -4450,7 +4453,7 @@ void D_QuitNetGame(void) static inline void SV_AddNode(INT32 node) { nettics[node] = gametic; - + supposedtics[node] = gametic; // little hack because the server connects to itself and puts // nodeingame when connected not here if (node) @@ -5532,6 +5535,14 @@ static void PT_ClientCmd(INT32 netconsole, SINT8 node) realstart = ExpandTics(netbuffer->u.clientpak.client_tic, nettics[node]); realend = ExpandTics(netbuffer->u.clientpak.resendfrom, nettics[node]); + if (netbuffer->packettype == PT_CLIENTMIS || netbuffer->packettype == PT_CLIENT2MIS + || netbuffer->packettype == PT_CLIENT3MIS || netbuffer->packettype == PT_CLIENT4MIS + || netbuffer->packettype == PT_NODEKEEPALIVEMIS + || supposedtics[node] < realend) + { + supposedtics[node] = realend; + } + // Discard out of order packet if (nettics[node] > realend) { @@ -5883,6 +5894,7 @@ static void PT_ServerTics(SINT8 node) if (realend > gametic + CLIENTBACKUPTICS) realend = gametic + CLIENTBACKUPTICS; + cl_packetmissed = realstart > neededtic; UINT8 *pak = (UINT8 *)&packet->cmds; UINT8 *txtpak = (UINT8 *)&packet->cmds[packet->numslots * packet->numtics]; @@ -6015,12 +6027,11 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_CLIENT2CMD: case PT_CLIENT3CMD: case PT_CLIENT4CMD: - case PT_NODEKEEPALIVE: - // "mis" tics kept for vanilla compat case PT_CLIENTMIS: case PT_CLIENT2MIS: case PT_CLIENT3MIS: case PT_CLIENT4MIS: + case PT_NODEKEEPALIVE: case PT_NODEKEEPALIVEMIS: PT_ClientCmd(netconsole, node); break; @@ -6312,18 +6323,25 @@ static void SV_SendServerKeepAlive(void) static void CL_SendClientCmd(void) { size_t packetsize = 0; + boolean mis = false; doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); netbuffer->packettype = PT_CLIENTCMD; + if (cl_packetmissed) + { + netbuffer->packettype = PT_CLIENTMIS; + mis = true; + } + netbuffer->u.clientpak.resendfrom = (UINT8)(neededtic & UINT8_MAX); netbuffer->u.clientpak.client_tic = (UINT8)(gametic & UINT8_MAX); if (gamestate == GS_WAITINGPLAYERS) { // Send PT_NODEKEEPALIVE packet - netbuffer->packettype = PT_NODEKEEPALIVE; + netbuffer->packettype = (mis ? PT_NODEKEEPALIVEMIS : PT_NODEKEEPALIVE); packetsize = sizeof (clientcmd_pak) - sizeof (ticcmd_t) - sizeof (INT16); HSendPacket(servernode, false, 0, packetsize); } @@ -6386,19 +6404,19 @@ static void CL_SendClientCmd(void) if (splitscreen || botingame) // Send a special packet with 2 cmd for splitscreen { - netbuffer->packettype = PT_CLIENT2CMD; + netbuffer->packettype = (mis ? PT_CLIENT2MIS : PT_CLIENT2CMD); packetsize = sizeof (client2cmd_pak); G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds[1][lagDelay], 1); if (splitscreen > 1) { - netbuffer->packettype = PT_CLIENT3CMD; + netbuffer->packettype = (mis ? PT_CLIENT3MIS : PT_CLIENT3CMD); packetsize = sizeof (client3cmd_pak); G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds[2][lagDelay], 1); if (splitscreen > 2) { - netbuffer->packettype = PT_CLIENT4CMD; + netbuffer->packettype = (mis ? PT_CLIENT4MIS : PT_CLIENT4CMD); packetsize = sizeof (client4cmd_pak); G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds[3][lagDelay], 1); } @@ -6453,13 +6471,14 @@ static void SV_SendTics(void) // send to all client but not to me // for each node create a packet with x tics and send it - // x is computed using nettics[n], max packet size and maketic + // x is computed using supposedtics[n], max packet size and maketic for (n = 1; n < MAXNETNODES; n++) { if (!nodeingame[n]) continue; - realfirsttic = nettics[n]; + // assert supposedtics[n]>=nettics[n] + realfirsttic = supposedtics[n]; lasttictosend = min(maketic, nettics[n] + CLIENTBACKUPTICS); if (realfirsttic >= lasttictosend) @@ -6468,8 +6487,8 @@ static void SV_SendTics(void) // to resent packet that are supposed lost (this is necessary since lost // packet detection work when we have received packet with firsttic > neededtic // (getpacket servertics case) - DEBFILE(va("Nothing to send node %u mak=%u net=%u \n", - n, lasttictosend, nettics[n])); + DEBFILE(va("Nothing to send node %u mak=%u sup=%u net=%u \n", + n, lasttictosend, supposedtics[n], nettics[n])); realfirsttic = nettics[n]; if (realfirsttic >= lasttictosend || (I_GetTime() + n)&3) // all tic are ok @@ -6549,10 +6568,17 @@ static void SV_SendTics(void) packsize = bufpos - (UINT8 *)&(netbuffer->u); HSendPacket(n, false, 0, packsize); - } + // when tic are too large, only one tic is sent so don't go backward! + if (lasttictosend-doomcom->extratics > realfirsttic) + supposedtics[n] = lasttictosend-doomcom->extratics; + else + supposedtics[n] = lasttictosend; + + supposedtics[n] = max(supposedtics[n], nettics[n]); + } // node 0 is me! - nettics[0] = maketic; + supposedtics[0] = maketic; } // diff --git a/src/d_net.c b/src/d_net.c index 3e0d4410c..fd8fb0e31 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -863,12 +863,11 @@ static void DebugPrintpacket(const char *header) case PT_CLIENT2CMD: case PT_CLIENT3CMD: case PT_CLIENT4CMD: - case PT_NODEKEEPALIVE: - // "mis" tics kept for vanilla compat case PT_CLIENTMIS: case PT_CLIENT2MIS: case PT_CLIENT3MIS: case PT_CLIENT4MIS: + case PT_NODEKEEPALIVE: case PT_NODEKEEPALIVEMIS: fprintf(debugfile, " tic %4u resendfrom %u\n", (UINT32)netbuffer->u.clientpak.client_tic, From 242dee499d516daf80d0205c864a9eda7612a052 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 2 Jan 2026 18:34:00 +0100 Subject: [PATCH 062/589] initialize more globals that have been missed --- src/d_main.c | 2 +- src/d_net.c | 4 ++-- src/filesrch.c | 7 +++++-- src/g_game.c | 6 +++--- src/hardware/r_opengl/r_opengl.c | 2 +- src/i_time.c | 2 +- src/k_hud.c | 2 +- src/r_things.cpp | 4 ++-- 8 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index f37d70a2c..ab5fe7a10 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -639,7 +639,7 @@ void D_SRB2Loop(void) tic_t entertic = 0, oldentertics = 0, realtics = 0, rendertimeout = INFTICS; double deltatics = 0.0; double deltasecs = 0.0; - UINT64 precision; + UINT64 precision = 0; boolean interp = false; boolean doDisplay = false; diff --git a/src/d_net.c b/src/d_net.c index 59b31a1fb..c0d8c667b 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -59,7 +59,7 @@ static INT16 reboundsize[MAXREBOUND]; static INT32 rebound_head, rebound_tail; /// \brief max length per packet -INT16 hardware_MAXPACKETLENGTH; +INT16 hardware_MAXPACKETLENGTH = 0; boolean (*I_NetGet)(void) = NULL; void (*I_NetSend)(void) = NULL; @@ -96,7 +96,7 @@ INT32 ticruned = 0, ticmiss = 0; // globals INT32 getbps = 0, sendbps = 0; -float lostpercent = 0, duppercent = 0, gamelostpercent = 0; +float lostpercent = 0.0f, duppercent = 0.0f, gamelostpercent = 0.0f; INT32 packetheaderlength = 0; boolean Net_GetNetStat(void) diff --git a/src/filesrch.c b/src/filesrch.c index f7ff612bd..e34b51c47 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -49,7 +49,7 @@ size_t menupathindex[menudepth] = {}; size_t menudepthleft = menudepth; char menusearchbuf[MAXSTRINGLENGTH+1]; -textinput_t menusearch; +textinput_t menusearch = {}; char **dirmenu = NULL, **coredirmenu = NULL; // core only local for this file size_t sizedirmenu = 0, sizecoredirmenu = 0; // ditto @@ -271,10 +271,13 @@ static boolean filemenucmp(char *haystack, char *needle) { static char localhaystack[128]; strlcpy(localhaystack, haystack, 128); + if (!cv_addons_search_case.value) strupr(localhaystack); + if (cv_addons_search_type.value) - return (strstr(localhaystack, needle) != 0); + return (strstr(localhaystack, needle) != NULL); + return (!strncmp(localhaystack, needle, menusearch.length)); } diff --git a/src/g_game.c b/src/g_game.c index 2d2a49461..892579163 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -132,7 +132,7 @@ UINT8 skincolor_bluering = SKINCOLOR_STEEL; tic_t countdowntimer = 0; boolean countdowntimeup = false; -cutscene_t *cutscenes[128]; +cutscene_t *cutscenes[128] = {}; INT16 nextmapoverride = 0; boolean skipstats = false; @@ -144,7 +144,7 @@ mobj_t *blueflag = NULL; mapthing_t *rflagpoint = NULL; mapthing_t *bflagpoint = NULL; -struct quake quake; +struct quake quake = {}; // Map Header Information mapheader_t* mapheaderinfo[NUMMAPS] = {}; @@ -228,7 +228,7 @@ tic_t racecountdown = 0, exitcountdown = 0; // for racing fixed_t gravity = 0; fixed_t mapobjectscale = FRACUNIT; -struct maplighting maplighting; +struct maplighting maplighting = {}; INT16 autobalance = 0; //for CTF team balance INT16 teamscramble = 0; //for CTF team scramble diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 94656e843..edd2f51a7 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -745,7 +745,7 @@ typedef struct gl_shaderstate_s static gl_shaderstate_t gl_shaderstate; // Shader info -static float shader_leveltime = 0; +static float shader_leveltime = 0.0f; static float shader_light_x = 0.0f; static float shader_light_y = 0.0f; static float shader_light_z = 0.0f; diff --git a/src/i_time.c b/src/i_time.c index 09d5fb3fa..6e5cc3a4d 100644 --- a/src/i_time.c +++ b/src/i_time.c @@ -21,7 +21,7 @@ #include "m_fixed.h" #include "i_system.h" -timestate_t g_time; +timestate_t g_time = {}; static CV_PossibleValue_t timescale_cons_t[] = {{FRACUNIT/20, "MIN"}, {20*FRACUNIT, "MAX"}, {0, NULL}}; consvar_t cv_timescale = {"timescale", "1.0", CV_NETVAR|CV_CHEAT|CV_FLOAT, timescale_cons_t, NULL, FRACUNIT, NULL, NULL, 0, 0, NULL}; diff --git a/src/k_hud.c b/src/k_hud.c index 1d9b7fe5b..f4f7f1c1a 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -568,7 +568,7 @@ static patch_t *kp_racefinish[6]; static patch_t *kp_positionnum[NUMPOSNUMS][NUMPOSFRAMES]; static patch_t *kp_winnernum[NUMPOSFRAMES]; -patch_t *kp_facenum[MAXPLAYERS+1]; +patch_t *kp_facenum[MAXPLAYERS+1] = {}; static patch_t *kp_facehighlight[8]; static patch_t *kp_rankbumper; diff --git a/src/r_things.cpp b/src/r_things.cpp index b62d9e5d7..cab9512e3 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -658,7 +658,7 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column) dc->texturemid = basetexturemid; } -INT32 lengthcol; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height +INT32 lengthcol = 0; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height static void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column) { @@ -3086,7 +3086,7 @@ static void R_DrawMaskedList(drawnode_t* head) void R_DrawMasked(maskcount_t* masks, INT32 nummasks) { INT32 i; - drawnode_t *heads; /**< Drawnode lists; as many as number of views/portals. */ + drawnode_t *heads = NULL; /**< Drawnode lists; as many as number of views/portals. */ heads = static_cast(calloc(nummasks, sizeof(drawnode_t))); From edbebbf082ba1b078e9f5c22fa8d60bd00fcb609 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 2 Jan 2026 18:31:02 +0100 Subject: [PATCH 063/589] fix wrong type for K_DriftSparkColor all the colour stuff is still a bit of a mess, but generally its handled as an uint8 --- src/k_hud.c | 10 +++++----- src/k_kart.c | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index f4f7f1c1a..d0146a38e 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1065,7 +1065,7 @@ static void K_initKartHUD(void) } if (timeinmap > 113 || forceshowhud) - hudtrans = cv_translucenthud.value; + hudtrans = (UINT8)cv_translucenthud.value; else if (timeinmap > 105) hudtrans = ((((INT32)timeinmap) - 105)*cv_translucenthud.value)/(113-105); else @@ -1122,9 +1122,9 @@ void K_KartPlayerHUDUpdate(player_t *player) UINT8 K_GetHudColor(void) { if (cv_colorizedhud.value && cv_colorizedhudcolor.value) - return cv_colorizedhudcolor.value; + return (UINT8)cv_colorizedhudcolor.value; - return ((stplyr && gamestate == GS_LEVEL) ? stplyr->skincolor : cv_playercolor.value); + return ((stplyr && gamestate == GS_LEVEL) ? stplyr->skincolor : (UINT8)cv_playercolor.value); } boolean K_UseColorHud(void) @@ -1526,7 +1526,7 @@ static void K_drawKartItem(void) { localcolor = K_GetHudColor(); - switch((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3) + switch ((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3) { // Each case is handled in threes, to give three frames of in-game time to see the item on the roulette case 0: // Sneaker @@ -2195,7 +2195,7 @@ static boolean K_drawKartPositionFaces(void) return true; if (!LUA_HudEnabled(hud_minirankings)) - return false; // Don't proceed but still return true for free play above if HUD is disabled. + return false; // Don't proceed but still return true for free play above if HUD is disabled. for (j = 0; j < numplayersingame; j++) { diff --git a/src/k_kart.c b/src/k_kart.c index 767e041a1..bb4da62a5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3103,17 +3103,18 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I return NULL; } -static UINT16 K_DriftSparkColor(player_t *player, INT32 charge) +static UINT8 K_DriftSparkColor(player_t *player, INT32 charge) { - UINT16 color = SKINCOLOR_NONE; + UINT8 color = SKINCOLOR_NONE; + const INT32 sparkval = K_GetKartDriftSparkValue(player); - if (charge >= K_GetKartDriftSparkValue(player)*4) + if (charge >= sparkval*4) { color = K_RainbowColor(); } - else if (charge >= K_GetKartDriftSparkValue(player)*2) + else if (charge >= sparkval*2) { - if (charge <= (K_GetKartDriftSparkValue(player)*2)+(24*3)) + if (charge <= (sparkval*2)+(24*3)) color = SKINCOLOR_RASPBERRY; // transition else color = SKINCOLOR_KETCHUP; From 5184115216790614e9953e0268a5563034051446 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 8 Jan 2026 00:33:43 +0100 Subject: [PATCH 064/589] enable "Wzero-as-null-pointer-constant", fix cases of it prevent ambiguity and bad practices, i like expressive and "correct" code shoutout blankart for making me aware this exists --- src/Makefile.d/versions.mk | 2 +- src/blua/lstrlib.c | 2 +- src/blua/luaconf.h | 6 +++--- src/d_clisrv.c | 14 +++++++------- src/d_main.c | 3 ++- src/d_netcmd.c | 14 +++++++------- src/f_finale.c | 2 +- src/g_demo.c | 2 +- src/g_game.c | 14 +++++++------- src/hardware/hw_batching.c | 2 +- src/hardware/hw_md2load.c | 28 ++++++++++++++-------------- src/hardware/hw_md3load.c | 24 ++++++++++++------------ src/hardware/hw_model.c | 18 +++++++++--------- src/hardware/r_opengl/r_opengl.c | 12 ++++++------ src/http-mserv.c | 8 ++++---- src/lua_mobjlib.c | 2 +- src/m_cheat.c | 8 ++++---- src/m_cond.c | 2 +- src/m_menu.c | 8 ++++---- src/m_perfstats.c | 18 +++++++++--------- src/p_enemy.c | 8 ++++---- src/p_mobj.c | 24 ++++++++++++------------ src/p_setup.c | 4 ++-- src/p_spec.c | 6 +++--- src/r_main.cpp | 2 +- src/r_skins.c | 2 +- src/r_things.cpp | 4 ++-- src/s_sound.c | 6 +++--- src/s_sound.h | 4 ++-- src/strcasestr.c | 8 ++++---- src/w_wad.c | 18 +++++++++--------- src/y_inter.c | 8 ++++---- 32 files changed, 142 insertions(+), 141 deletions(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 2a80cfa39..e57119fb9 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference +WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference -Wzero-as-null-pointer-constant ifndef GCC295 #WFLAGS+=-Wno-packed endif diff --git a/src/blua/lstrlib.c b/src/blua/lstrlib.c index e2fd23604..6fe279bcb 100644 --- a/src/blua/lstrlib.c +++ b/src/blua/lstrlib.c @@ -527,7 +527,7 @@ static int str_find_aux (lua_State *L, int find) { if (find) { lua_pushinteger(L, s1-s+1); /* start */ lua_pushinteger(L, res-s); /* end */ - return push_captures(&ms, NULL, 0) + 2; + return push_captures(&ms, NULL, NULL) + 2; } else return push_captures(&ms, s1, res); diff --git a/src/blua/luaconf.h b/src/blua/luaconf.h index 76a798751..22fa8bf53 100644 --- a/src/blua/luaconf.h +++ b/src/blua/luaconf.h @@ -772,10 +772,10 @@ union luai_Cast { double l_d; long l_l; }; #include #if defined(__GNUC__) -#define l_likely(x) (__builtin_expect(((x) != 0), 1)) -#define l_unlikely(x) (__builtin_expect(((x) != 0), 0)) +#define l_likely(x) (__builtin_expect(!!(x), 1)) +#define l_unlikely(x) (__builtin_expect(!!(x), 0)) #else -#define l_likely(x) (x) +#define l_likely(x) (x) #define l_unlikely(x) (x) #endif diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d4983daa2..68ab08c5a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -332,7 +332,7 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(const UINT8 **p, INT32 playernu #ifdef PARANOIA if (id >= MAXNETXCMD) I_Error("Command id %d too big", id); - if (listnetxcmd[id] != 0) + if (listnetxcmd[id] != NULL) I_Error("Command id %d already used", id); #endif listnetxcmd[id] = cmd_f; @@ -1236,7 +1236,7 @@ static void CL_DrawConnectionStatus(void) va(" %4uK/%4uK", currentsize>>10, totalsize>>10)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, - va("%3.1fK/s ", ((double)getbps)/1024)); + va("%3.1fK/s ", ((double)getbps)/1024.0)); } else cltext = M_GetText("Waiting to download game state..."); @@ -1963,7 +1963,7 @@ static boolean SV_ResendingSavegameToAnyone(void) static void SV_SendSaveGame(INT32 node, boolean resending) { size_t length, compressedlen; - savebuffer_t save = {0}; + savebuffer_t save = {}; UINT8 *compressedsave; UINT8 *buffertosend; @@ -2033,7 +2033,7 @@ static consvar_t cv_dumpconsistency = {"dumpconsistency", "Off", CV_NETVAR, CV_O static void SV_SavedGame(void) { size_t length; - savebuffer_t save = {0}; + savebuffer_t save = {}; char tmpsave[264]; if (!cv_dumpconsistency.value) @@ -2073,7 +2073,7 @@ static void SV_SavedGame(void) static void CL_LoadReceivedSavegame(boolean reloading) { - savebuffer_t save = {0}; + savebuffer_t save = {}; size_t length, decompressedlen; char tmpsave[264]; @@ -7237,7 +7237,7 @@ void CL_ClearRewinds(void) rewind_t *CL_SaveRewindPoint(size_t demopos) { - savebuffer_t save = {0}; + savebuffer_t save = {}; rewind_t *rewind; if (rewindhead && rewindhead->leveltime + REWIND_POINT_INTERVAL > leveltime) @@ -7260,7 +7260,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos) rewind_t *CL_RewindToTime(tic_t time) { - savebuffer_t save = {0}; + savebuffer_t save = {}; rewind_t *rewind; while (rewindhead && rewindhead->leveltime > time) diff --git a/src/d_main.c b/src/d_main.c index ab5fe7a10..3e474cec3 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1865,7 +1865,8 @@ void D_SRB2Main(void) if (M_CheckParm("-warp") && M_IsNextParm()) { const char *word = M_GetNextParm(); - pstartmap = G_FindMapByNameOrCode(word, 0); + pstartmap = G_FindMapByNameOrCode(word, NULL); + if (! pstartmap) I_Error("Cannot find a map remotely named '%s'\n", word); else diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c669da59b..781120be2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -249,7 +249,7 @@ consvar_t cv_competitionboxes = {"competitionboxes", "Random", CV_NETVAR|CV_CHEA #ifdef SEENAMES static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}}; -consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif @@ -458,16 +458,16 @@ consvar_t cv_showping = {"showping", "Always", CV_SAVE, showping_cons_t, NULL, 0 static CV_PossibleValue_t pingmeasurement_cons_t[] = {{0, "Frames"}, {1, "Milliseconds"}, {0, NULL}}; consvar_t cv_pingmeasurement = {"pingmeasurement", "Frames", CV_SAVE, pingmeasurement_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t cv_pingstyle_cons_t[] = {{0, "New"}, {1, "Old"}, {0, NULL}}; -consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // Intermission time Tails 04-19-2002 static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}}; @@ -2789,7 +2789,7 @@ static void Command_Map_f(void) // G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer else { - if (!mapheaderinfo[newmapnum-1]) + if (mapheaderinfo[newmapnum-1] == NULL) { CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum)); return; diff --git a/src/f_finale.c b/src/f_finale.c index 801af8ab5..32ed8c3ec 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1318,7 +1318,7 @@ boolean F_ContinueResponder(event_t *event) keypressed = true; imcontinuing = true; continuetime = TICRATE; - S_StartSound(0, sfx_itemup); + S_StartSound(NULL, sfx_itemup); return true; } diff --git a/src/g_demo.c b/src/g_demo.c index 312e57530..ede5adf18 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -76,7 +76,7 @@ static tic_t demostarttime; // for comparative timing purposes //@TODO put these all in a struct for namespacing purposes? static char demoname[128]; -savebuffer_t demobuf = {0}; +savebuffer_t demobuf = {}; static UINT8 *demotime_p, *demoinfo_p; static UINT8 *demoend; static UINT8 demoflags; diff --git a/src/g_game.c b/src/g_game.c index 892579163..27a2922a8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3501,7 +3501,7 @@ void G_LoadGameData(void) INT32 i, j; UINT8 modded = false; UINT8 rtemp; - savebuffer_t save = {0}; + savebuffer_t save = {}; //For records tic_t rectime; @@ -3634,7 +3634,7 @@ void G_SaveGameData(boolean force) size_t length; INT32 i, j; UINT8 btemp; - savebuffer_t save = {0}; + savebuffer_t save = {}; (void)force; char backupfile[MAX_WADPATH+4]; @@ -3805,7 +3805,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride) size_t length; char vcheck[VERSIONSIZE]; char savename[255]; - savebuffer_t save = {0}; + savebuffer_t save = {}; // memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots memset(&savedata, 0, sizeof(savedata)); @@ -3891,7 +3891,7 @@ void G_SaveGame(UINT32 savegameslot) boolean saved; char savename[256] = ""; const char *backup; - savebuffer_t save = {0}; + savebuffer_t save = {}; sprintf(savename, savegamename, savegameslot); backup = va("%s",savename); @@ -4161,7 +4161,7 @@ static void measurekeywords(mapsearchfreq_t *fr, PU_STATIC, NULL); for (qp = strtok(va("%s", q), " "); qp && fr->total < 255; - qp = strtok(0, " ")) + qp = strtok(NULL, " ")) { if (( sp = strcasestr(s, qp) )) { @@ -4242,7 +4242,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, { newmapnum = mapnum; newmapname = realmapname; - realmapname = 0; + realmapname = NULL; Z_Free(apromapname); if (!wanttable) break; @@ -4263,7 +4263,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, { apromapnum = mapnum; apromapname = realmapname; - realmapname = 0; + realmapname = NULL; } } else/* ...match individual keywords */ diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 4d6b1ea6e..8bf7f7375 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -391,7 +391,7 @@ void HWR_RenderBatches(void) nextSurfaceInfo = nextEntry->surf; if (nextPolyFlags & PF_NoTexture) - nextTexture = 0; + nextTexture = NULL; if (useshader && currentShader != nextShader) { diff --git a/src/hardware/hw_md2load.c b/src/hardware/hw_md2load.c index 3805deffb..d28ebf058 100644 --- a/src/hardware/hw_md2load.c +++ b/src/hardware/hw_md2load.c @@ -274,7 +274,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) if (!f) return NULL; - retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); + retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); //size_t fileLen; @@ -288,13 +288,13 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) { texPos++; namelen = strlen(texPos) + 1; - texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0); + texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); strcpy(texturefilename, texPos); } else { namelen = strlen(fileName) + 1; - texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0); + texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); strcpy(texturefilename, fileName); } @@ -316,7 +316,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) header = (md2header_t*)buffer; retModel->numMeshes = 1; // MD2 only has one mesh - retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, 0); + retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, NULL); retModel->meshes[0].numFrames = header->numFrames; // const float WUNITS = 1.0f; // float dataScale = WUNITS; @@ -332,7 +332,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) if (retModel->numMaterials <= 0) // Always at least one skin, duh retModel->numMaterials = 1; - retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); + retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); // int t; for (t = 0; t < retModel->numMaterials; t++) @@ -409,9 +409,9 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) float *uvptr; dataScale = 0.015624f; // 1 / 64.0f - retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, 0); + retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, NULL); retModel->meshes[0].numVertices = header->numXYZ; - retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); + retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); ptr = (char*)frames; for (i = 0; i < header->numFrames; i++, ptr += header->framesize) @@ -423,12 +423,12 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) md2vertex_t *vertex; md2frame_t *framePtr = (md2frame_t*)ptr; - retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, 0); - retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, 0); + retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, NULL); + retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag); - retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, 0); + retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, NULL); vertptr = retModel->meshes[0].tinyframes[i].vertices; normptr = retModel->meshes[0].tinyframes[i].normals; @@ -484,8 +484,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) char *ptr; retModel->meshes[0].numVertices = header->numTris * 3; - retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, 0); - retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); + retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, NULL); + retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); trisPtr = tris; uvptr = retModel->meshes[0].uvs; @@ -507,8 +507,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) md2vertex_t *vertex; md2frame_t *framePtr = (md2frame_t*)ptr; - retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); - retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); + retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); + retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag); //float *vertptr, *normptr; diff --git a/src/hardware/hw_md3load.c b/src/hardware/hw_md3load.c index 53f6034c0..b536c7e73 100644 --- a/src/hardware/hw_md3load.c +++ b/src/hardware/hw_md3load.c @@ -168,7 +168,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) if (!f) return NULL; - retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); + retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); // find length of file fseek(f, 0, SEEK_END); @@ -201,7 +201,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) if (retModel->numMaterials <= 0) // Always at least one skin, duh retModel->numMaterials = 1; - retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); + retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); for (t = 0; t < retModel->numMaterials; t++) { @@ -225,7 +225,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) retModel->materials[t].spheremap = false; } - retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, 0); + retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, NULL); matCount = 0; for (i = 0, surfEnd = 0; i < mdh->numSurfaces; i++) @@ -298,9 +298,9 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) unsigned short *indexptr; md3Triangle *mdT; - retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, 0); + retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, NULL); retModel->meshes[i].numVertices = mdS->numVerts; - retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, 0); + retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, NULL); for (j = 0; j < mdS->numFrames; j++) { short *vertptr; @@ -308,12 +308,12 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) // char *tanptr; int k; md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); - retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, 0); - retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, 0); + retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, NULL); + retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[i].tinyframes[j].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag); - retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, 0); + retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, NULL); vertptr = retModel->meshes[i].tinyframes[j].vertices; normptr = retModel->meshes[i].tinyframes[j].normals; @@ -374,16 +374,16 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) int k; retModel->meshes[i].numVertices = mdS->numTriangles * 3;//mdS->numVerts; - retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, 0); - retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, 0); + retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, NULL); + retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, NULL); for (j = 0; j < mdS->numFrames; j++) { float *vertptr; float *normptr; md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); - retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0); - retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0); + retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); + retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); // if (retModel->materials[i].lightmap) // retModel->meshes[i].frames[j].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag); vertptr = retModel->meshes[i].frames[j].vertices; diff --git a/src/hardware/hw_model.c b/src/hardware/hw_model.c index 8698365e4..274c23394 100644 --- a/src/hardware/hw_model.c +++ b/src/hardware/hw_model.c @@ -189,7 +189,7 @@ model_t *LoadModel(const char *filename, int ztag) return NULL; } - model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, 0); + model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, NULL); strcpy(model->mdlFilename, filename); Optimize(model); @@ -237,7 +237,7 @@ void GenerateVertexNormals(model_t *model) { mdlframe_t *frame = &mesh->frames[j]; int memTag = PU_STATIC; - float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, 0); + float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, NULL); int k; float *vertPtr = frame->vertices; float *oldNormals; @@ -309,7 +309,7 @@ static boolean AddMaterialToList(materiallist_t **head, material_t *material) } // Didn't find it, so add to the list - newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, 0); + newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, NULL); newMatNode->material = material; ListAdd(newMatNode, (listitem_t**)head); return true; @@ -351,7 +351,7 @@ void Optimize(model_t *model) } memTag = PU_STATIC; - newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, 0); + newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, NULL); i = 0; for (node = matListHead; node; node = node->next) @@ -377,14 +377,14 @@ void Optimize(model_t *model) newMesh->numFrames = 1; newMesh->numTriangles = numTriangles; newMesh->numVertices = numTriangles * 3; - newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0); - newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0); + newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, NULL); + newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, NULL); curFrame = &newMesh->frames[0]; curFrame->material = curMat; - curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); - curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); - curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0); + curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); + curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); + curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, NULL); // Now traverse the meshes of the model, adding in // vertices/normals/uvs that match the current material diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index edd2f51a7..fab0a8a6d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -98,10 +98,10 @@ static size_t textureBufferSize = 0; static LTListItem *LightTablesTail = NULL; static LTListItem *LightTablesHead = NULL; -static RGBA_t screenPalette[256] = {0}; // the palette for the postprocessing step in palette rendering +static RGBA_t screenPalette[256] = {}; // the palette for the postprocessing step in palette rendering static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table -RGBA_t myPaletteData[256] = {0}; // the palette for converting textures to RGBA +RGBA_t myPaletteData[256] = {}; // the palette for converting textures to RGBA static GLint gltexformat = GL_RGB5_A1; GLint screen_width = 0; // used by Draw2DLine() @@ -127,9 +127,9 @@ GLuint gl_num_extensions; int majorGL = 0, minorGL = 0; //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) -GLfloat modelMatrix[16] = {0}; -GLfloat projMatrix[16] = {0}; -static GLint viewport[4]; +GLfloat modelMatrix[16] = {}; +GLfloat projMatrix[16] = {}; +static GLint viewport[4]; #ifdef USE_FBO_OGL enum @@ -171,7 +171,7 @@ boolean supportstencil = false; // flush all of the stored textures, leaving them unavailable at times such as between levels // These need to start at 0 and be set to their number, and be reset to 0 when deleted so that Intel GPUs // can know when the textures aren't there, as textures are always considered resident in their virtual memory -static GLuint screenTextures[NUMSCREENTEXTURES] = {0}; +static GLuint screenTextures[NUMSCREENTEXTURES] = {}; #define byte2float(byte) (GLfloat)(byte / 255.0f) diff --git a/src/http-mserv.c b/src/http-mserv.c index 8e35f905d..fd63c5f69 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -189,7 +189,7 @@ HMS_connect (const char *format, ...) seek = strlen(hms_api) + 1;/* + '/' */ va_start (ap, format); - url = malloc(seek + vsnprintf(0, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); + url = malloc(seek + vsnprintf(NULL, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); va_end (ap); sprintf(url, "%s/", hms_api); @@ -471,8 +471,8 @@ HMS_fetch_servers (msg_server_t *list, int query_id) *end = '\0'; address = strtok(p, " "); - port = strtok(0, " "); - contact = strtok(0, ""); + port = strtok(NULL, " "); + contact = strtok(NULL, ""); if (address && port) { @@ -539,7 +539,7 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size) if (HMS_do(hms)) { version = strtok(hms->buffer, " "); - version_name = strtok(0, "\n"); + version_name = strtok(NULL, "\n"); if (version && version_name) { diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 45c3a9f19..9bd5f5203 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -475,7 +475,7 @@ int mobj_localskin_setter(lua_State *L) } else { - mo->localskin = 0; + mo->localskin = NULL; mo->skinlocal = false; } } diff --git a/src/m_cheat.c b/src/m_cheat.c index 2890c7196..58bc1401d 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -80,7 +80,7 @@ static UINT8 cheatf_warp(void) if (success) { G_SaveGameData(true); //G_SetGameModified(false); - S_StartSound(0, sfx_kc42); + S_StartSound(NULL, sfx_kc42); } // Refresh secrets menu existing. @@ -117,13 +117,13 @@ static UINT8 cheatf_devmode(void) #endif static cheatseq_t cheat_warp = { - 0, cheatf_warp, + NULL, cheatf_warp, //{ SCRAMBLE('r'), SCRAMBLE('e'), SCRAMBLE('d'), SCRAMBLE('x'), SCRAMBLE('v'), SCRAMBLE('i'), 0xff } { SCRAMBLE('b'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), 0xff } }; static cheatseq_t cheat_warp_joy = { - 0, cheatf_warp, + NULL, cheatf_warp, /*{ SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_UPARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), @@ -136,7 +136,7 @@ static cheatseq_t cheat_warp_joy = { #ifdef DEVELOP static cheatseq_t cheat_devmode = { - 0, cheatf_devmode, + NULL, cheatf_devmode, { SCRAMBLE('d'), SCRAMBLE('e'), SCRAMBLE('v'), SCRAMBLE('m'), SCRAMBLE('o'), SCRAMBLE('d'), SCRAMBLE('e'), 0xff } }; #endif diff --git a/src/m_cond.c b/src/m_cond.c index acf78e6ef..126d5a49a 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -235,7 +235,7 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1 wnum = conditionSets[set - 1].numconditions; num = ++conditionSets[set - 1].numconditions; - conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, 0); + conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, NULL); cond = conditionSets[set - 1].condition; diff --git a/src/m_menu.c b/src/m_menu.c index c2978fe82..55112356b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5385,7 +5385,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na { CONS_Printf("custom settings menu initiation\n"); for (CVARSETUP = 0; CVARSETUP < MAXMENUCCVARS; ++CVARSETUP) - OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", 0, INT16_MAX}; + OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", NULL, INT16_MAX}; } if (category && ((ccvarposition == 0 && category[0] != '\0') || !fasticmp(category, OP_CustomCvarMenu[ccvarlaststheader].text))) @@ -7494,7 +7494,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) if ((lumpnum = W_CheckNumForName(va("%sE", mapname))) != LUMPERROR) mappingforencore = (patch_t *)W_CachePatchNum(lumpnum, PU_PATCH);*/ - V_DrawFixedPatch((x+w)<>1), (staty+67)<>1, 0, statlr, flashcol); V_DrawFixedPatch((statx+40+GRIDSTATOFFSET)<>1, 0, statud, flashcol); // bg - V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<>1), (staty+73)<>1, 0, statbg, 0); + V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<>1), (staty+73)<>1, 0, statbg, NULL); for (i = 0; i < numskins; i++) // draw the stat dots { @@ -8218,7 +8218,7 @@ static void M_DrawSetupMultiPlayerMenu(void) V_DrawFixedPatch((statx+64)<flags2 & MF2_FRET) { P_SetMobjState(actor, S_BLACKEGG_DESTROYPLAT1); - S_StartSound(0, sfx_s3k53); + S_StartSound(NULL, sfx_s3k53); actor->flags2 &= ~MF2_FRET; return; } @@ -6011,7 +6011,7 @@ void A_Boss7Chase(void *thing) { // Punch him! P_SetMobjState(actor, actor->info->meleestate); - S_StartSound(0, sfx_begrnd); // warning sound + S_StartSound(NULL, sfx_begrnd); // warning sound return; } } @@ -6057,7 +6057,7 @@ void A_Boss7Chase(void *thing) case 2: // Homing Missile A_FaceTarget(actor); P_SetMobjState(actor, actor->info->missilestate); - S_StartSound(0, sfx_beflap); + S_StartSound(NULL, sfx_beflap); break; } @@ -10739,7 +10739,7 @@ void A_BrakChase(void *thing) { actor->reactiontime--; if (actor->reactiontime == 0 && actor->type == MT_CYBRAKDEMON) - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } // modify target threshold diff --git a/src/p_mobj.c b/src/p_mobj.c index ad7982d87..581edf2f0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3606,10 +3606,10 @@ static void P_CalculatePrecipFloor(precipmobj_t *mobj) // Just the identification of a precip thinker. The thinker // should never actually be called! // -void P_NullPrecipThinker(precipmobj_t *mobj) +FUNCNORETURN void P_NullPrecipThinker(precipmobj_t *mobj) { (void)mobj; - I_Assert("P_NullPrecipThinker should not be called" == 0); + I_Error("P_NullPrecipThinker should not be called"); } boolean P_PrecipThinker(precipmobj_t *mobj) @@ -4012,7 +4012,7 @@ static void P_Boss3Thinker(mobj_t *mobj) if ((UINT32)mobj->extravalue1 + TICRATE*2 < leveltime) { mobj->extravalue1 = (INT32)leveltime; - S_StartSound(0, sfx_buzz1); + S_StartSound(NULL, sfx_buzz1); } // If in the center, check to make sure @@ -4631,7 +4631,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (mobj->health > 0) mobj->health--; - S_StartSound(0, (mobj->health) ? sfx_behurt : sfx_bedie2); + S_StartSound(NULL, (mobj->health) ? sfx_behurt : sfx_bedie2); mobj->reactiontime /= 3; @@ -4670,7 +4670,7 @@ static void P_Boss7Thinker(mobj_t *mobj) INT32 i; mobj->state->nextstate = mobj->info->painstate; // Reset - S_StartSound(0, sfx_bedeen); + S_StartSound(NULL, sfx_bedeen); for (i = 0; i < MAXPLAYERS; i++) { @@ -4694,7 +4694,7 @@ static void P_Boss7Thinker(mobj_t *mobj) mobj->state->nextstate = mobj->info->spawnstate; // Laugh - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } } } @@ -4714,7 +4714,7 @@ static void P_Boss7Thinker(mobj_t *mobj) var2 = 2*TICRATE + (80<<16); A_LobShot(mobj); - S_StartSound(0, sfx_begoop); + S_StartSound(NULL, sfx_begoop); } } else if (mobj->state == &states[S_BLACKEGG_SHOOT2]) @@ -4738,7 +4738,7 @@ static void P_Boss7Thinker(mobj_t *mobj) S_StopSound(missile); if (leveltime & 1) - S_StartSound(0, sfx_beshot); + S_StartSound(NULL, sfx_beshot); } else if (mobj->state == &states[S_BLACKEGG_JUMP1] && mobj->tics == 1) { @@ -4871,7 +4871,7 @@ static void P_Boss7Thinker(mobj_t *mobj) fixed_t x,y,z; mobj_t *mo2; - S_StartSound(0, sfx_befall); + S_StartSound(NULL, sfx_befall); z = mobj->floorz; for (j = 0; j < 2; j++) @@ -4910,13 +4910,13 @@ static void P_Boss7Thinker(mobj_t *mobj) P_DamageMobj(players[i].mo, mobj, mobj, 1); // Laugh - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } P_SetMobjState(mobj, mobj->info->spawnstate); } else if (mobj->state == &states[mobj->info->deathstate] && mobj->tics == mobj->state->tics) - S_StartSound(0, sfx_bedie1 + (P_RandomFixed() & 1)); + S_StartSound(NULL, sfx_bedie1 + (P_RandomFixed() & 1)); } // Metal Sonic battle boss @@ -10711,7 +10711,7 @@ void P_SpawnPlayer(INT32 playernum) // the dead body mobj retains the skin through the 'spritedef' override). mobj->skin = &skins[p->skin]; - mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : 0); + mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : NULL); mobj->skinlocal = p->skinlocal; mobj->health = p->health; diff --git a/src/p_setup.c b/src/p_setup.c index bf40afe9d..612530882 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1022,7 +1022,7 @@ void P_WriteThings(lumpnum_t lumpnum) size_t i, length; mapthing_t *mt; UINT8 *data; - savebuffer_t save = {0}; + savebuffer_t save = {}; INT16 temp; data = W_CacheLumpNum(lumpnum, PU_LEVEL); @@ -1166,7 +1166,7 @@ static void P_LoadLineDefs2(void) for (; i--; ld++) { ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here - ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; + ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : NULL; // Repeat count for midtexture if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff)) diff --git a/src/p_spec.c b/src/p_spec.c index 66901d234..5045a8287 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4579,8 +4579,8 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor) if (!sec->ffloors) { sec->ffloors = ffloor; - ffloor->next = 0; - ffloor->prev = 0; + ffloor->next = NULL; + ffloor->prev = NULL; return; } @@ -4588,7 +4588,7 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor) rover->next = ffloor; ffloor->prev = rover; - ffloor->next = 0; + ffloor->next = NULL; } /** Adds a 3Dfloor. diff --git a/src/r_main.cpp b/src/r_main.cpp index fecfba580..e3bfb83fa 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1087,7 +1087,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) ret = &subsectors[nodenum & ~NF_SUBSECTOR]; for (i = 0; i < ret->numlines; i++) if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side) - return 0; + return NULL; return ret; } diff --git a/src/r_skins.c b/src/r_skins.c index 538b8c38a..41971788c 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -302,7 +302,7 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) if (player->mo) { - player->mo->localskin = 0; + player->mo->localskin = NULL; player->mo->skinlocal = false; } } diff --git a/src/r_things.cpp b/src/r_things.cpp index cab9512e3..77b02b78c 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -532,8 +532,8 @@ void R_ClearSprites(void) visspritecount = numvisiblesprites = clippedvissprites = 0; } -static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0}; -static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0}; +static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {}; +static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {}; static void R_AllocVisSpriteChunkMemory(UINT32 chunk) { diff --git a/src/s_sound.c b/src/s_sound.c index e8075469c..7f931671d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -884,7 +884,7 @@ static void S_StopChannel(INT32 cnum) if (cnum != i && c->sfxinfo == channels[i].sfxinfo) break; - c->sfxinfo = 0; + c->sfxinfo = NULL; } c->origin = NULL; @@ -1271,7 +1271,7 @@ static musicdef_t *S_AddMusicCredit(void) return &musicdefs[chunk][i]; } -struct cursongcredit cursongcredit = {0}; // Currently displayed song credit info +struct cursongcredit cursongcredit = {}; // Currently displayed song credit info static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicdef_t **defp) { @@ -1704,7 +1704,7 @@ static void S_UnloadMusic(void) music.flags = 0; music.looping = false; - music_refade_cv = 0; + music_refade_cv = NULL; } static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) diff --git a/src/s_sound.h b/src/s_sound.h index 9e0296d2b..c7f487e92 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -253,9 +253,9 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 void S_ChangeMusicSpecial (const char *mmusic); -void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); +void S_SetRestoreMusicFadeInCvar(consvar_t *cvar); #define S_ClearRestoreMusicFadeInCvar() \ - S_SetRestoreMusicFadeInCvar(0) + S_SetRestoreMusicFadeInCvar(NULL) int S_GetRestoreMusicFadeIn (void); // Stops the music. diff --git a/src/strcasestr.c b/src/strcasestr.c index d24a36e54..f50141dcf 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -73,8 +73,8 @@ nongnu_strcasestr (const char *s, const char *q) up = strchr(s, uc); lp = strchr(s, lc); - if (!( (intptr_t)up|(intptr_t)lp )) - return 0; + if (up == NULL || lp == NULL) + return NULL; if (!lp || ( up && up < lp )) { @@ -100,12 +100,12 @@ nongnu_strcasestr (const char *s, const char *q) if (trycmp(ppa, cpa, q, qn) == 0) return (*ppa); - if (!( (intptr_t)up|(intptr_t)lp )) + if (up == NULL || lp == NULL) break; if (!(*ppa) || ( (*ppb) && (*ppb) < (*ppa) )) swapp(&ppa, &ppb, &cpa, &cpb); } - return 0; + return NULL; } diff --git a/src/w_wad.c b/src/w_wad.c index 7e1ec30df..432f1421f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -697,12 +697,12 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lump_p->name, '\0', 9); // Making sure they're initialized to 0. Is it necessary? @@ -1667,9 +1667,9 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si if (fread(rawData, 1, rawSize, handle) < rawSize) I_Error("wad %d, lump %d: cannot read compressed data", wad, lump); - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; + strm.zalloc = NULL; + strm.zfree = NULL; + strm.opaque = NULL; strm.total_in = strm.avail_in = rawSize; strm.total_out = strm.avail_out = decSize; @@ -2238,14 +2238,14 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. if (*trimname) // Ignore directories, well kinda { - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? @@ -2483,14 +2483,14 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. if (*trimname) // Ignore directories, well kinda { - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? diff --git a/src/y_inter.c b/src/y_inter.c index d35fa7825..27e794ffc 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -104,7 +104,7 @@ typedef struct } y_voteclient; // votescreen stuff -votescreen_t VoteScreen = {0}; +votescreen_t VoteScreen = {}; static y_votelvlinfo levelinfo[5]; static y_voteclient voteclient; @@ -1093,7 +1093,7 @@ void Y_VoteDrawer(void) V_DrawSmallScaledPatch(BASEVIDWIDTH-100, y, V_SNAPTORIGHT, pic); else { - V_DrawFixedPatch((BASEVIDWIDTH-20)< Date: Thu, 8 Jan 2026 00:27:06 +0100 Subject: [PATCH 065/589] K_SpawnSparkleTrail: check for blend effect apply outside the loop tiny optimization --- src/k_kart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index bb4da62a5..342414738 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3595,6 +3595,8 @@ void K_SpawnSparkleTrail(mobj_t *mo) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); + const boolean shouldblend = (mo->player && K_PlayerEffectsShouldBlend(mo->player)); + for (i = 0; i < 3; i++) { fixed_t newx = mo->x + mo->momx + (P_RandomRange(-rad, rad)<color = mo->color; - if (mo->player && K_PlayerEffectsShouldBlend(mo->player)) + if (shouldblend) sparkle->blendmode = AST_ADD; } From e923777eb67df6d889c8196e496f722b7c44ed20 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 8 Jan 2026 00:26:02 +0100 Subject: [PATCH 066/589] Acessability: add basic "reducevfx" toggle to disable/reduce certain effects toggles certain effects, which may be troublesome to some players -disabled hyudoro flashing, instead makes player translucent - Makes rainbow colour effects, such as invul, change colours very slowly - Disables underwater and heatwave screen effects - Disables palette flashing - Disables vhs effect not the most pretty implementation, but im lazy and this works feel free to suggest more things --- src/g_game.h | 1 + src/hardware/hw_main.cpp | 24 ++++- src/hardware/hw_md2.c | 11 ++- src/k_kart.c | 11 ++- src/p_mobj.c | 3 +- src/r_things.cpp | 11 ++- src/v_video.c | 197 ++++++++++++++++++++------------------- 7 files changed, 150 insertions(+), 108 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index 509749c5f..6ecc69dfa 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -130,6 +130,7 @@ extern consvar_t cv_spinoutroll; extern consvar_t cv_squishdance, cv_squishdancespeed; extern consvar_t cv_playerblendeffects; +extern consvar_t cv_reducevfx; extern consvar_t cv_cechotoggle; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 70a5a3a8d..1622a4528 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3786,8 +3786,15 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } - if (cv_playerfade.value && sprmo->player) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + if (sprmo->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0) + Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + + if (cv_playerfade.value) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + } if (HWR_UseShader()) { @@ -4076,8 +4083,15 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } - if (cv_playerfade.value && sprmo->player) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + if (sprmo->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0) + Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + + if (cv_playerfade.value) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + } if (HWR_UseShader()) { @@ -6100,7 +6114,7 @@ static void HWR_DoPostProcessor(void) const camera_t *thiscam = &camera[0]; // Not supported in splitscreen - someone want to add support? - const boolean screenwave = (!splitscreen && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); + const boolean screenwave = (!splitscreen && !cv_reducevfx.value && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); // Capture the screen for intermission and screen waving if ((lastdraw || screenwave) && gamestate != GS_INTERMISSION) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 763fb873c..e45a56cda 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1198,8 +1198,15 @@ void HWR_DrawMD2(gl_vissprite_t *spr) Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); } - if (cv_playerfade.value && spr->mobj->player) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); + if (spr->mobj->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && spr->mobj->player->kartstuff[k_hyudorotimer] > 0) + Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + + if (cv_playerfade.value) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); + } // dont forget to enabled the depth test because we can't do this like // before: polygons models are not sorted diff --git a/src/k_kart.c b/src/k_kart.c index 342414738..59271a1e4 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -47,6 +47,8 @@ consvar_t cv_airsparks = {"airdriftsparks", "Off", CV_SAVE, CV_OnOff, NULL, 0, N consvar_t cv_playerblendeffects = {"playerblendeffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_reducevfx = {"reducevfx", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + // funn-E streeetch static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; consvar_t cv_gravstretch = {"gravstretch", "MIN", CV_SAVE|CV_FLOAT, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -482,7 +484,8 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = { // UINT8 K_RainbowColor(void) { - return (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); + const INT32 time = cv_reducevfx.value ? (leveltime >> 3) : leveltime; + return (UINT8)(1 + (time % (MAXSKINCOLORS-1))); } // Define for getting accurate color brightness readings according to how the human eye sees them. @@ -764,6 +767,8 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_playerblendeffects); + CV_RegisterVar(&cv_reducevfx); + CV_RegisterVar(&cv_saltyhop); CV_RegisterVar(&cv_saltyhopsfx); CV_RegisterVar(&cv_saltysquish); @@ -6768,7 +6773,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) { if (splitscreen) { - if (leveltime & 1) + if (!cv_reducevfx.value && leveltime & 1) player->mo->flags2 |= MF2_DONTDRAW; else player->mo->flags2 &= ~MF2_DONTDRAW; @@ -6794,7 +6799,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (P_IsDisplayPlayer(player) || (!P_IsDisplayPlayer(player) && (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)))) { - if (leveltime & 1) + if (!cv_reducevfx.value && leveltime & 1) player->mo->flags2 |= MF2_DONTDRAW; else player->mo->flags2 &= ~MF2_DONTDRAW; diff --git a/src/p_mobj.c b/src/p_mobj.c index 581edf2f0..d1b8b850a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12354,8 +12354,9 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 allowai // void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration) { - if (!pl) + if (!pl || cv_reducevfx.value) // no palette flashing with reducevfx return; + pl->flashcount = duration; pl->flashpal = type; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 77b02b78c..d1c856238 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1588,8 +1588,15 @@ static void R_ProjectSprite(mobj_t *thing) else trans = 0; - if (cv_playerfade.value && thing->player) - trans = static_cast(R_GetThingTransTable(R_DoPlayerFade(thing), static_cast(trans))); + if (thing->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && thing->player->kartstuff[k_hyudorotimer] > 0) + trans = static_cast(R_GetThingTransTable(FRACUNIT/2, static_cast(trans))); + + if (cv_playerfade.value) + trans = static_cast(R_GetThingTransTable(R_DoPlayerFade(thing), static_cast(trans))); + } //SoM: 3/17/2000: Disregard sprites that are out of view.. if (vflip) diff --git a/src/v_video.c b/src/v_video.c index ac85715ef..bb118d269 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -15,6 +15,7 @@ #include "doomdef.h" #include "d_main.h" +#include "g_game.h" #include "r_local.h" #include "p_local.h" #include "v_video.h" @@ -1755,6 +1756,9 @@ void V_DrawVhsEffect(boolean rewind) #endif SINT8 offs; + if (cv_reducevfx.value) + return; + barsize = vid.dup << 5; updistort = vid.dup << (rewind ? 5 : 3); downdistort = updistort >> 1; @@ -3639,127 +3643,130 @@ void V_DoPostProcessor(INT32 view, INT32 param) UINT8 *tmpscr = vid.screens[4]; UINT8 *srcscr = vid.screens[0]; - if (thiscam->postimg & POSTIMG_WATER) + if (!cv_reducevfx.value) { - INT32 y; - // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic - angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK; - INT32 newpix; - INT32 sine; - //UINT8 *transme = transtables + ((tr_trans50-1)<postimg & POSTIMG_WATER) { - sine = (FINESINE(disStart)*5)>>FRACBITS; - newpix = abs(sine); + INT32 y; + // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic + angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK; + INT32 newpix; + INT32 sine; + //UINT8 *transme = transtables + ((tr_trans50-1)<>FRACBITS; + newpix = abs(sine); - // Cleanup edge - while (newpix) + if (sine < 0) { - tmpscr[(y*vid.width)+xoffset+newpix] = srcscr[(y*vid.width)+xoffset]; - newpix--; - } - } - else - { - memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix); + memcpy(&tmpscr[(y*vid.width)+xoffset+newpix], &srcscr[(y*vid.width)+xoffset], viewwidth-newpix); - // Cleanup edge - while (newpix) + // Cleanup edge + while (newpix) + { + tmpscr[(y*vid.width)+xoffset+newpix] = srcscr[(y*vid.width)+xoffset]; + newpix--; + } + } + else { - tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)]; - newpix--; + memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix); + + // Cleanup edge + while (newpix) + { + tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)]; + newpix--; + } } + + /* + Unoptimized version + for (x = 0; x < vid.width; x++) + { + newpix = (x + sine); + + if (newpix < 0) + newpix = 0; + else if (newpix >= vid.width) + newpix = vid.width-1; + + tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); + }*/ + + disStart += 22;//the offset into the displacement map, increment each game loop + disStart &= FINEMASK; //clip it to FINEMASK } - /* - Unoptimized version - for (x = 0; x < vid.width; x++) - { - newpix = (x + sine); - - if (newpix < 0) - newpix = 0; - else if (newpix >= vid.width) - newpix = vid.width-1; - - tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); - }*/ - - disStart += 22;//the offset into the displacement map, increment each game loop - disStart &= FINEMASK; //clip it to FINEMASK + UINT8 *tmp = tmpscr; + tmpscr = srcscr; + srcscr = tmp; } - - UINT8 *tmp = tmpscr; - tmpscr = srcscr; - srcscr = tmp; - } - else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave - { - INT32 y; - - // Make sure table is built - if (heatshifter == NULL || lastheight != viewheight) + else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave { - if (heatshifter) - Z_Free(heatshifter); + INT32 y; - heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL); - - for (y = 0; y < viewheight; y++) + // Make sure table is built + if (heatshifter == NULL || lastheight != viewheight) { - if (M_RandomChance(FRACUNIT/8)) // 12.5% - heatshifter[y] = true; + if (heatshifter) + Z_Free(heatshifter); + + heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL); + + for (y = 0; y < viewheight; y++) + { + if (M_RandomChance(FRACUNIT/8)) // 12.5% + heatshifter[y] = true; + } + + heatindex[0] = heatindex[1] = heatindex[2] = heatindex[3] = 0; + lastheight = viewheight; } - heatindex[0] = heatindex[1] = heatindex[2] = heatindex[3] = 0; - lastheight = viewheight; - } - - for (y = yoffset; y < yoffset+viewheight; y++) - { - if (heatshifter[heatindex[view]++]) + for (y = yoffset; y < yoffset+viewheight; y++) { - // Shift this row of pixels to the right by 2 - tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset]; - memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup); + if (heatshifter[heatindex[view]++]) + { + // Shift this row of pixels to the right by 2 + tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset]; + memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup); + } + else + memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); + + heatindex[view] %= viewheight; } - else - memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); - heatindex[view] %= viewheight; + if (renderisnewtic) // This isn't interpolated... but how do you interpolate a one-pixel shift? + { + heatindex[view]++; + heatindex[view] %= vid.height; + } + + UINT8 *tmp = tmpscr; + tmpscr = srcscr; + srcscr = tmp; } - if (renderisnewtic) // This isn't interpolated... but how do you interpolate a one-pixel shift? - { - heatindex[view]++; - heatindex[view] %= vid.height; - } - - UINT8 *tmp = tmpscr; - tmpscr = srcscr; - srcscr = tmp; - } - #ifdef MOTIONBLUR - if (thiscam->postimg & POSTIMG_MOTION) // Motion Blur! - { - INT32 x, y; - - // TODO: Add a postimg_param so that we can pick the translucency level... - UINT8 *transme = transtables + ((param-1)<postimg & POSTIMG_MOTION) // Motion Blur! { - for (x = xoffset; x < xoffset+viewwidth; x++) - tmpscr[y*vid.width + x] = colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))]; + INT32 x, y; + + // TODO: Add a postimg_param so that we can pick the translucency level... + UINT8 *transme = transtables + ((param-1)<postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down { From 3bf3bdf641add15d06adc37eeae47fca47c1e29b Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 8 Jan 2026 00:33:06 +0100 Subject: [PATCH 067/589] enable "Wzero-as-null-pointer-constant", fix cases of it prevent ambiguity and bad practices, i like expressive and "correct" code shoutout blankart for making me aware this exists --- src/Makefile.d/versions.mk | 2 +- src/blua/lstrlib.c | 2 +- src/blua/luaconf.h | 6 +++--- src/d_clisrv.c | 18 +++++++++--------- src/d_main.c | 3 ++- src/d_netcmd.c | 14 +++++++------- src/f_finale.c | 2 +- src/g_demo.c | 2 +- src/g_game.c | 14 +++++++------- src/hardware/hw_batching.c | 2 +- src/hardware/hw_md2load.c | 28 ++++++++++++++-------------- src/hardware/hw_md3load.c | 24 ++++++++++++------------ src/hardware/hw_model.c | 18 +++++++++--------- src/hardware/r_opengl/r_opengl.c | 12 ++++++------ src/http-mserv.c | 8 ++++---- src/lua_mobjlib.c | 2 +- src/m_cheat.c | 8 ++++---- src/m_cond.c | 2 +- src/m_menu.c | 8 ++++---- src/m_perfstats.c | 18 +++++++++--------- src/p_enemy.c | 8 ++++---- src/p_mobj.c | 24 ++++++++++++------------ src/p_setup.c | 4 ++-- src/p_spec.c | 6 +++--- src/r_main.cpp | 2 +- src/r_skins.c | 2 +- src/r_things.cpp | 4 ++-- src/s_sound.c | 6 +++--- src/s_sound.h | 4 ++-- src/strcasestr.c | 8 ++++---- src/w_wad.c | 18 +++++++++--------- src/y_inter.c | 8 ++++---- 32 files changed, 144 insertions(+), 143 deletions(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 2a80cfa39..e57119fb9 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference +WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference -Wzero-as-null-pointer-constant ifndef GCC295 #WFLAGS+=-Wno-packed endif diff --git a/src/blua/lstrlib.c b/src/blua/lstrlib.c index e2fd23604..6fe279bcb 100644 --- a/src/blua/lstrlib.c +++ b/src/blua/lstrlib.c @@ -527,7 +527,7 @@ static int str_find_aux (lua_State *L, int find) { if (find) { lua_pushinteger(L, s1-s+1); /* start */ lua_pushinteger(L, res-s); /* end */ - return push_captures(&ms, NULL, 0) + 2; + return push_captures(&ms, NULL, NULL) + 2; } else return push_captures(&ms, s1, res); diff --git a/src/blua/luaconf.h b/src/blua/luaconf.h index 76a798751..22fa8bf53 100644 --- a/src/blua/luaconf.h +++ b/src/blua/luaconf.h @@ -772,10 +772,10 @@ union luai_Cast { double l_d; long l_l; }; #include #if defined(__GNUC__) -#define l_likely(x) (__builtin_expect(((x) != 0), 1)) -#define l_unlikely(x) (__builtin_expect(((x) != 0), 0)) +#define l_likely(x) (__builtin_expect(!!(x), 1)) +#define l_unlikely(x) (__builtin_expect(!!(x), 0)) #else -#define l_likely(x) (x) +#define l_likely(x) (x) #define l_unlikely(x) (x) #endif diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5125a6c7b..50d9a322f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -332,7 +332,7 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(const UINT8 **p, INT32 playernu #ifdef PARANOIA if (id >= MAXNETXCMD) I_Error("Command id %d too big", id); - if (listnetxcmd[id] != 0) + if (listnetxcmd[id] != NULL) I_Error("Command id %d already used", id); #endif listnetxcmd[id] = cmd_f; @@ -1234,7 +1234,7 @@ static inline void CL_DrawConnectionStatus(void) va(" %4uK/%4uK",currentsize>>10,totalsize>>10)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, - va("%3.1fK/s ", ((double)getbps)/1024)); + va("%3.1fK/s ", ((double)getbps)/1024.0)); } else cltext = M_GetText("Waiting to download game state..."); @@ -1956,7 +1956,7 @@ static boolean SV_ResendingSavegameToAnyone(void) static void SV_SendSaveGame(INT32 node, boolean resending) { size_t length, compressedlen; - savebuffer_t save = {0}; + savebuffer_t save = {}; UINT8 *compressedsave; UINT8 *buffertosend; @@ -2026,7 +2026,7 @@ static consvar_t cv_dumpconsistency = {"dumpconsistency", "Off", CV_NETVAR, CV_O static void SV_SavedGame(void) { size_t length; - savebuffer_t save = {0}; + savebuffer_t save = {}; char tmpsave[264]; if (!cv_dumpconsistency.value) @@ -2066,7 +2066,7 @@ static void SV_SavedGame(void) static void CL_LoadReceivedSavegame(boolean reloading) { - savebuffer_t save = {0}; + savebuffer_t save = {}; size_t length, decompressedlen; char tmpsave[264]; @@ -4933,8 +4933,6 @@ static void PT_ClientJoin(SINT8 node) if (client || nodeingame[node] || levelloading) return; - doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); - const char *refuse = GetRefuseMessage(node); if (refuse) @@ -4943,6 +4941,8 @@ static void PT_ClientJoin(SINT8 node) return; } + doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); + // client authorised to join nodewaiting[node] = (UINT8)(netbuffer->u.clientcfg.localplayers - playerpernode[node]); @@ -7288,7 +7288,7 @@ void CL_ClearRewinds(void) rewind_t *CL_SaveRewindPoint(size_t demopos) { - savebuffer_t save = {0}; + savebuffer_t save = {}; rewind_t *rewind; if (rewindhead && rewindhead->leveltime + REWIND_POINT_INTERVAL > leveltime) @@ -7311,7 +7311,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos) rewind_t *CL_RewindToTime(tic_t time) { - savebuffer_t save = {0}; + savebuffer_t save = {}; rewind_t *rewind; while (rewindhead && rewindhead->leveltime > time) diff --git a/src/d_main.c b/src/d_main.c index c46ef0c44..486ca5b07 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1869,7 +1869,8 @@ void D_SRB2Main(void) if (M_CheckParm("-warp") && M_IsNextParm()) { const char *word = M_GetNextParm(); - pstartmap = G_FindMapByNameOrCode(word, 0); + pstartmap = G_FindMapByNameOrCode(word, NULL); + if (! pstartmap) I_Error("Cannot find a map remotely named '%s'\n", word); else diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b579e6848..e9f814857 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -249,7 +249,7 @@ consvar_t cv_competitionboxes = {"competitionboxes", "Random", CV_NETVAR|CV_CHEA #ifdef SEENAMES static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}}; -consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif @@ -458,16 +458,16 @@ consvar_t cv_showping = {"showping", "Always", CV_SAVE, showping_cons_t, NULL, 0 static CV_PossibleValue_t pingmeasurement_cons_t[] = {{0, "Frames"}, {1, "Milliseconds"}, {0, NULL}}; consvar_t cv_pingmeasurement = {"pingmeasurement", "Frames", CV_SAVE, pingmeasurement_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t cv_pingstyle_cons_t[] = {{0, "New"}, {1, "Old"}, {0, NULL}}; -consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // Intermission time Tails 04-19-2002 static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}}; @@ -2447,7 +2447,7 @@ static void Command_Map_f(void) // G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer else { - if (!mapheaderinfo[newmapnum-1]) + if (mapheaderinfo[newmapnum-1] == NULL) { CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum)); return; diff --git a/src/f_finale.c b/src/f_finale.c index 801af8ab5..32ed8c3ec 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1318,7 +1318,7 @@ boolean F_ContinueResponder(event_t *event) keypressed = true; imcontinuing = true; continuetime = TICRATE; - S_StartSound(0, sfx_itemup); + S_StartSound(NULL, sfx_itemup); return true; } diff --git a/src/g_demo.c b/src/g_demo.c index 312e57530..ede5adf18 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -76,7 +76,7 @@ static tic_t demostarttime; // for comparative timing purposes //@TODO put these all in a struct for namespacing purposes? static char demoname[128]; -savebuffer_t demobuf = {0}; +savebuffer_t demobuf = {}; static UINT8 *demotime_p, *demoinfo_p; static UINT8 *demoend; static UINT8 demoflags; diff --git a/src/g_game.c b/src/g_game.c index c304c2e6f..64328da06 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3498,7 +3498,7 @@ void G_LoadGameData(void) INT32 i, j; UINT8 modded = false; UINT8 rtemp; - savebuffer_t save = {0}; + savebuffer_t save = {}; //For records tic_t rectime; @@ -3631,7 +3631,7 @@ void G_SaveGameData(boolean force) size_t length; INT32 i, j; UINT8 btemp; - savebuffer_t save = {0}; + savebuffer_t save = {}; (void)force; char backupfile[MAX_WADPATH+4]; @@ -3802,7 +3802,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride) size_t length; char vcheck[VERSIONSIZE]; char savename[255]; - savebuffer_t save = {0}; + savebuffer_t save = {}; // memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots memset(&savedata, 0, sizeof(savedata)); @@ -3888,7 +3888,7 @@ void G_SaveGame(UINT32 savegameslot) boolean saved; char savename[256] = ""; const char *backup; - savebuffer_t save = {0}; + savebuffer_t save = {}; sprintf(savename, savegamename, savegameslot); backup = va("%s",savename); @@ -4158,7 +4158,7 @@ static void measurekeywords(mapsearchfreq_t *fr, PU_STATIC, NULL); for (qp = strtok(va("%s", q), " "); qp && fr->total < 255; - qp = strtok(0, " ")) + qp = strtok(NULL, " ")) { if (( sp = strcasestr(s, qp) )) { @@ -4239,7 +4239,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, { newmapnum = mapnum; newmapname = realmapname; - realmapname = 0; + realmapname = NULL; Z_Free(apromapname); if (!wanttable) break; @@ -4260,7 +4260,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, { apromapnum = mapnum; apromapname = realmapname; - realmapname = 0; + realmapname = NULL; } } else/* ...match individual keywords */ diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 4d6b1ea6e..8bf7f7375 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -391,7 +391,7 @@ void HWR_RenderBatches(void) nextSurfaceInfo = nextEntry->surf; if (nextPolyFlags & PF_NoTexture) - nextTexture = 0; + nextTexture = NULL; if (useshader && currentShader != nextShader) { diff --git a/src/hardware/hw_md2load.c b/src/hardware/hw_md2load.c index 3805deffb..d28ebf058 100644 --- a/src/hardware/hw_md2load.c +++ b/src/hardware/hw_md2load.c @@ -274,7 +274,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) if (!f) return NULL; - retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); + retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); //size_t fileLen; @@ -288,13 +288,13 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) { texPos++; namelen = strlen(texPos) + 1; - texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0); + texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); strcpy(texturefilename, texPos); } else { namelen = strlen(fileName) + 1; - texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0); + texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); strcpy(texturefilename, fileName); } @@ -316,7 +316,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) header = (md2header_t*)buffer; retModel->numMeshes = 1; // MD2 only has one mesh - retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, 0); + retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, NULL); retModel->meshes[0].numFrames = header->numFrames; // const float WUNITS = 1.0f; // float dataScale = WUNITS; @@ -332,7 +332,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) if (retModel->numMaterials <= 0) // Always at least one skin, duh retModel->numMaterials = 1; - retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); + retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); // int t; for (t = 0; t < retModel->numMaterials; t++) @@ -409,9 +409,9 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) float *uvptr; dataScale = 0.015624f; // 1 / 64.0f - retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, 0); + retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, NULL); retModel->meshes[0].numVertices = header->numXYZ; - retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); + retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); ptr = (char*)frames; for (i = 0; i < header->numFrames; i++, ptr += header->framesize) @@ -423,12 +423,12 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) md2vertex_t *vertex; md2frame_t *framePtr = (md2frame_t*)ptr; - retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, 0); - retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, 0); + retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, NULL); + retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag); - retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, 0); + retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, NULL); vertptr = retModel->meshes[0].tinyframes[i].vertices; normptr = retModel->meshes[0].tinyframes[i].normals; @@ -484,8 +484,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) char *ptr; retModel->meshes[0].numVertices = header->numTris * 3; - retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, 0); - retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); + retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, NULL); + retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); trisPtr = tris; uvptr = retModel->meshes[0].uvs; @@ -507,8 +507,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) md2vertex_t *vertex; md2frame_t *framePtr = (md2frame_t*)ptr; - retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); - retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); + retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); + retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag); //float *vertptr, *normptr; diff --git a/src/hardware/hw_md3load.c b/src/hardware/hw_md3load.c index 53f6034c0..b536c7e73 100644 --- a/src/hardware/hw_md3load.c +++ b/src/hardware/hw_md3load.c @@ -168,7 +168,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) if (!f) return NULL; - retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); + retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); // find length of file fseek(f, 0, SEEK_END); @@ -201,7 +201,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) if (retModel->numMaterials <= 0) // Always at least one skin, duh retModel->numMaterials = 1; - retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); + retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); for (t = 0; t < retModel->numMaterials; t++) { @@ -225,7 +225,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) retModel->materials[t].spheremap = false; } - retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, 0); + retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, NULL); matCount = 0; for (i = 0, surfEnd = 0; i < mdh->numSurfaces; i++) @@ -298,9 +298,9 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) unsigned short *indexptr; md3Triangle *mdT; - retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, 0); + retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, NULL); retModel->meshes[i].numVertices = mdS->numVerts; - retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, 0); + retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, NULL); for (j = 0; j < mdS->numFrames; j++) { short *vertptr; @@ -308,12 +308,12 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) // char *tanptr; int k; md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); - retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, 0); - retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, 0); + retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, NULL); + retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[i].tinyframes[j].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag); - retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, 0); + retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, NULL); vertptr = retModel->meshes[i].tinyframes[j].vertices; normptr = retModel->meshes[i].tinyframes[j].normals; @@ -374,16 +374,16 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) int k; retModel->meshes[i].numVertices = mdS->numTriangles * 3;//mdS->numVerts; - retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, 0); - retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, 0); + retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, NULL); + retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, NULL); for (j = 0; j < mdS->numFrames; j++) { float *vertptr; float *normptr; md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); - retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0); - retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0); + retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); + retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); // if (retModel->materials[i].lightmap) // retModel->meshes[i].frames[j].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag); vertptr = retModel->meshes[i].frames[j].vertices; diff --git a/src/hardware/hw_model.c b/src/hardware/hw_model.c index 8698365e4..274c23394 100644 --- a/src/hardware/hw_model.c +++ b/src/hardware/hw_model.c @@ -189,7 +189,7 @@ model_t *LoadModel(const char *filename, int ztag) return NULL; } - model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, 0); + model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, NULL); strcpy(model->mdlFilename, filename); Optimize(model); @@ -237,7 +237,7 @@ void GenerateVertexNormals(model_t *model) { mdlframe_t *frame = &mesh->frames[j]; int memTag = PU_STATIC; - float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, 0); + float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, NULL); int k; float *vertPtr = frame->vertices; float *oldNormals; @@ -309,7 +309,7 @@ static boolean AddMaterialToList(materiallist_t **head, material_t *material) } // Didn't find it, so add to the list - newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, 0); + newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, NULL); newMatNode->material = material; ListAdd(newMatNode, (listitem_t**)head); return true; @@ -351,7 +351,7 @@ void Optimize(model_t *model) } memTag = PU_STATIC; - newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, 0); + newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, NULL); i = 0; for (node = matListHead; node; node = node->next) @@ -377,14 +377,14 @@ void Optimize(model_t *model) newMesh->numFrames = 1; newMesh->numTriangles = numTriangles; newMesh->numVertices = numTriangles * 3; - newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0); - newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0); + newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, NULL); + newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, NULL); curFrame = &newMesh->frames[0]; curFrame->material = curMat; - curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); - curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); - curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0); + curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); + curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); + curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, NULL); // Now traverse the meshes of the model, adding in // vertices/normals/uvs that match the current material diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 94656e843..86d1f5faa 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -98,10 +98,10 @@ static size_t textureBufferSize = 0; static LTListItem *LightTablesTail = NULL; static LTListItem *LightTablesHead = NULL; -static RGBA_t screenPalette[256] = {0}; // the palette for the postprocessing step in palette rendering +static RGBA_t screenPalette[256] = {}; // the palette for the postprocessing step in palette rendering static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table -RGBA_t myPaletteData[256] = {0}; // the palette for converting textures to RGBA +RGBA_t myPaletteData[256] = {}; // the palette for converting textures to RGBA static GLint gltexformat = GL_RGB5_A1; GLint screen_width = 0; // used by Draw2DLine() @@ -127,9 +127,9 @@ GLuint gl_num_extensions; int majorGL = 0, minorGL = 0; //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) -GLfloat modelMatrix[16] = {0}; -GLfloat projMatrix[16] = {0}; -static GLint viewport[4]; +GLfloat modelMatrix[16] = {}; +GLfloat projMatrix[16] = {}; +static GLint viewport[4]; #ifdef USE_FBO_OGL enum @@ -171,7 +171,7 @@ boolean supportstencil = false; // flush all of the stored textures, leaving them unavailable at times such as between levels // These need to start at 0 and be set to their number, and be reset to 0 when deleted so that Intel GPUs // can know when the textures aren't there, as textures are always considered resident in their virtual memory -static GLuint screenTextures[NUMSCREENTEXTURES] = {0}; +static GLuint screenTextures[NUMSCREENTEXTURES] = {}; #define byte2float(byte) (GLfloat)(byte / 255.0f) diff --git a/src/http-mserv.c b/src/http-mserv.c index 8e35f905d..fd63c5f69 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -189,7 +189,7 @@ HMS_connect (const char *format, ...) seek = strlen(hms_api) + 1;/* + '/' */ va_start (ap, format); - url = malloc(seek + vsnprintf(0, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); + url = malloc(seek + vsnprintf(NULL, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); va_end (ap); sprintf(url, "%s/", hms_api); @@ -471,8 +471,8 @@ HMS_fetch_servers (msg_server_t *list, int query_id) *end = '\0'; address = strtok(p, " "); - port = strtok(0, " "); - contact = strtok(0, ""); + port = strtok(NULL, " "); + contact = strtok(NULL, ""); if (address && port) { @@ -539,7 +539,7 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size) if (HMS_do(hms)) { version = strtok(hms->buffer, " "); - version_name = strtok(0, "\n"); + version_name = strtok(NULL, "\n"); if (version && version_name) { diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 45c3a9f19..9bd5f5203 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -475,7 +475,7 @@ int mobj_localskin_setter(lua_State *L) } else { - mo->localskin = 0; + mo->localskin = NULL; mo->skinlocal = false; } } diff --git a/src/m_cheat.c b/src/m_cheat.c index 2890c7196..58bc1401d 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -80,7 +80,7 @@ static UINT8 cheatf_warp(void) if (success) { G_SaveGameData(true); //G_SetGameModified(false); - S_StartSound(0, sfx_kc42); + S_StartSound(NULL, sfx_kc42); } // Refresh secrets menu existing. @@ -117,13 +117,13 @@ static UINT8 cheatf_devmode(void) #endif static cheatseq_t cheat_warp = { - 0, cheatf_warp, + NULL, cheatf_warp, //{ SCRAMBLE('r'), SCRAMBLE('e'), SCRAMBLE('d'), SCRAMBLE('x'), SCRAMBLE('v'), SCRAMBLE('i'), 0xff } { SCRAMBLE('b'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), 0xff } }; static cheatseq_t cheat_warp_joy = { - 0, cheatf_warp, + NULL, cheatf_warp, /*{ SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_UPARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), @@ -136,7 +136,7 @@ static cheatseq_t cheat_warp_joy = { #ifdef DEVELOP static cheatseq_t cheat_devmode = { - 0, cheatf_devmode, + NULL, cheatf_devmode, { SCRAMBLE('d'), SCRAMBLE('e'), SCRAMBLE('v'), SCRAMBLE('m'), SCRAMBLE('o'), SCRAMBLE('d'), SCRAMBLE('e'), 0xff } }; #endif diff --git a/src/m_cond.c b/src/m_cond.c index acf78e6ef..126d5a49a 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -235,7 +235,7 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1 wnum = conditionSets[set - 1].numconditions; num = ++conditionSets[set - 1].numconditions; - conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, 0); + conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, NULL); cond = conditionSets[set - 1].condition; diff --git a/src/m_menu.c b/src/m_menu.c index c2978fe82..55112356b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5385,7 +5385,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na { CONS_Printf("custom settings menu initiation\n"); for (CVARSETUP = 0; CVARSETUP < MAXMENUCCVARS; ++CVARSETUP) - OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", 0, INT16_MAX}; + OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", NULL, INT16_MAX}; } if (category && ((ccvarposition == 0 && category[0] != '\0') || !fasticmp(category, OP_CustomCvarMenu[ccvarlaststheader].text))) @@ -7494,7 +7494,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) if ((lumpnum = W_CheckNumForName(va("%sE", mapname))) != LUMPERROR) mappingforencore = (patch_t *)W_CachePatchNum(lumpnum, PU_PATCH);*/ - V_DrawFixedPatch((x+w)<>1), (staty+67)<>1, 0, statlr, flashcol); V_DrawFixedPatch((statx+40+GRIDSTATOFFSET)<>1, 0, statud, flashcol); // bg - V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<>1), (staty+73)<>1, 0, statbg, 0); + V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<>1), (staty+73)<>1, 0, statbg, NULL); for (i = 0; i < numskins; i++) // draw the stat dots { @@ -8218,7 +8218,7 @@ static void M_DrawSetupMultiPlayerMenu(void) V_DrawFixedPatch((statx+64)<flags2 & MF2_FRET) { P_SetMobjState(actor, S_BLACKEGG_DESTROYPLAT1); - S_StartSound(0, sfx_s3k53); + S_StartSound(NULL, sfx_s3k53); actor->flags2 &= ~MF2_FRET; return; } @@ -6011,7 +6011,7 @@ void A_Boss7Chase(void *thing) { // Punch him! P_SetMobjState(actor, actor->info->meleestate); - S_StartSound(0, sfx_begrnd); // warning sound + S_StartSound(NULL, sfx_begrnd); // warning sound return; } } @@ -6057,7 +6057,7 @@ void A_Boss7Chase(void *thing) case 2: // Homing Missile A_FaceTarget(actor); P_SetMobjState(actor, actor->info->missilestate); - S_StartSound(0, sfx_beflap); + S_StartSound(NULL, sfx_beflap); break; } @@ -10739,7 +10739,7 @@ void A_BrakChase(void *thing) { actor->reactiontime--; if (actor->reactiontime == 0 && actor->type == MT_CYBRAKDEMON) - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } // modify target threshold diff --git a/src/p_mobj.c b/src/p_mobj.c index ad7982d87..581edf2f0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3606,10 +3606,10 @@ static void P_CalculatePrecipFloor(precipmobj_t *mobj) // Just the identification of a precip thinker. The thinker // should never actually be called! // -void P_NullPrecipThinker(precipmobj_t *mobj) +FUNCNORETURN void P_NullPrecipThinker(precipmobj_t *mobj) { (void)mobj; - I_Assert("P_NullPrecipThinker should not be called" == 0); + I_Error("P_NullPrecipThinker should not be called"); } boolean P_PrecipThinker(precipmobj_t *mobj) @@ -4012,7 +4012,7 @@ static void P_Boss3Thinker(mobj_t *mobj) if ((UINT32)mobj->extravalue1 + TICRATE*2 < leveltime) { mobj->extravalue1 = (INT32)leveltime; - S_StartSound(0, sfx_buzz1); + S_StartSound(NULL, sfx_buzz1); } // If in the center, check to make sure @@ -4631,7 +4631,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (mobj->health > 0) mobj->health--; - S_StartSound(0, (mobj->health) ? sfx_behurt : sfx_bedie2); + S_StartSound(NULL, (mobj->health) ? sfx_behurt : sfx_bedie2); mobj->reactiontime /= 3; @@ -4670,7 +4670,7 @@ static void P_Boss7Thinker(mobj_t *mobj) INT32 i; mobj->state->nextstate = mobj->info->painstate; // Reset - S_StartSound(0, sfx_bedeen); + S_StartSound(NULL, sfx_bedeen); for (i = 0; i < MAXPLAYERS; i++) { @@ -4694,7 +4694,7 @@ static void P_Boss7Thinker(mobj_t *mobj) mobj->state->nextstate = mobj->info->spawnstate; // Laugh - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } } } @@ -4714,7 +4714,7 @@ static void P_Boss7Thinker(mobj_t *mobj) var2 = 2*TICRATE + (80<<16); A_LobShot(mobj); - S_StartSound(0, sfx_begoop); + S_StartSound(NULL, sfx_begoop); } } else if (mobj->state == &states[S_BLACKEGG_SHOOT2]) @@ -4738,7 +4738,7 @@ static void P_Boss7Thinker(mobj_t *mobj) S_StopSound(missile); if (leveltime & 1) - S_StartSound(0, sfx_beshot); + S_StartSound(NULL, sfx_beshot); } else if (mobj->state == &states[S_BLACKEGG_JUMP1] && mobj->tics == 1) { @@ -4871,7 +4871,7 @@ static void P_Boss7Thinker(mobj_t *mobj) fixed_t x,y,z; mobj_t *mo2; - S_StartSound(0, sfx_befall); + S_StartSound(NULL, sfx_befall); z = mobj->floorz; for (j = 0; j < 2; j++) @@ -4910,13 +4910,13 @@ static void P_Boss7Thinker(mobj_t *mobj) P_DamageMobj(players[i].mo, mobj, mobj, 1); // Laugh - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } P_SetMobjState(mobj, mobj->info->spawnstate); } else if (mobj->state == &states[mobj->info->deathstate] && mobj->tics == mobj->state->tics) - S_StartSound(0, sfx_bedie1 + (P_RandomFixed() & 1)); + S_StartSound(NULL, sfx_bedie1 + (P_RandomFixed() & 1)); } // Metal Sonic battle boss @@ -10711,7 +10711,7 @@ void P_SpawnPlayer(INT32 playernum) // the dead body mobj retains the skin through the 'spritedef' override). mobj->skin = &skins[p->skin]; - mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : 0); + mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : NULL); mobj->skinlocal = p->skinlocal; mobj->health = p->health; diff --git a/src/p_setup.c b/src/p_setup.c index bf40afe9d..612530882 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1022,7 +1022,7 @@ void P_WriteThings(lumpnum_t lumpnum) size_t i, length; mapthing_t *mt; UINT8 *data; - savebuffer_t save = {0}; + savebuffer_t save = {}; INT16 temp; data = W_CacheLumpNum(lumpnum, PU_LEVEL); @@ -1166,7 +1166,7 @@ static void P_LoadLineDefs2(void) for (; i--; ld++) { ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here - ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; + ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : NULL; // Repeat count for midtexture if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff)) diff --git a/src/p_spec.c b/src/p_spec.c index 66901d234..5045a8287 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4579,8 +4579,8 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor) if (!sec->ffloors) { sec->ffloors = ffloor; - ffloor->next = 0; - ffloor->prev = 0; + ffloor->next = NULL; + ffloor->prev = NULL; return; } @@ -4588,7 +4588,7 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor) rover->next = ffloor; ffloor->prev = rover; - ffloor->next = 0; + ffloor->next = NULL; } /** Adds a 3Dfloor. diff --git a/src/r_main.cpp b/src/r_main.cpp index 493105929..e470e5b5d 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1087,7 +1087,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) ret = &subsectors[nodenum & ~NF_SUBSECTOR]; for (i = 0; i < ret->numlines; i++) if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side) - return 0; + return NULL; return ret; } diff --git a/src/r_skins.c b/src/r_skins.c index 538b8c38a..41971788c 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -302,7 +302,7 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) if (player->mo) { - player->mo->localskin = 0; + player->mo->localskin = NULL; player->mo->skinlocal = false; } } diff --git a/src/r_things.cpp b/src/r_things.cpp index b62d9e5d7..f9e159843 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -532,8 +532,8 @@ void R_ClearSprites(void) visspritecount = numvisiblesprites = clippedvissprites = 0; } -static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0}; -static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0}; +static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {}; +static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {}; static void R_AllocVisSpriteChunkMemory(UINT32 chunk) { diff --git a/src/s_sound.c b/src/s_sound.c index e8075469c..7f931671d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -884,7 +884,7 @@ static void S_StopChannel(INT32 cnum) if (cnum != i && c->sfxinfo == channels[i].sfxinfo) break; - c->sfxinfo = 0; + c->sfxinfo = NULL; } c->origin = NULL; @@ -1271,7 +1271,7 @@ static musicdef_t *S_AddMusicCredit(void) return &musicdefs[chunk][i]; } -struct cursongcredit cursongcredit = {0}; // Currently displayed song credit info +struct cursongcredit cursongcredit = {}; // Currently displayed song credit info static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicdef_t **defp) { @@ -1704,7 +1704,7 @@ static void S_UnloadMusic(void) music.flags = 0; music.looping = false; - music_refade_cv = 0; + music_refade_cv = NULL; } static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) diff --git a/src/s_sound.h b/src/s_sound.h index 9e0296d2b..c7f487e92 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -253,9 +253,9 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 void S_ChangeMusicSpecial (const char *mmusic); -void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); +void S_SetRestoreMusicFadeInCvar(consvar_t *cvar); #define S_ClearRestoreMusicFadeInCvar() \ - S_SetRestoreMusicFadeInCvar(0) + S_SetRestoreMusicFadeInCvar(NULL) int S_GetRestoreMusicFadeIn (void); // Stops the music. diff --git a/src/strcasestr.c b/src/strcasestr.c index d24a36e54..f50141dcf 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -73,8 +73,8 @@ nongnu_strcasestr (const char *s, const char *q) up = strchr(s, uc); lp = strchr(s, lc); - if (!( (intptr_t)up|(intptr_t)lp )) - return 0; + if (up == NULL || lp == NULL) + return NULL; if (!lp || ( up && up < lp )) { @@ -100,12 +100,12 @@ nongnu_strcasestr (const char *s, const char *q) if (trycmp(ppa, cpa, q, qn) == 0) return (*ppa); - if (!( (intptr_t)up|(intptr_t)lp )) + if (up == NULL || lp == NULL) break; if (!(*ppa) || ( (*ppb) && (*ppb) < (*ppa) )) swapp(&ppa, &ppb, &cpa, &cpb); } - return 0; + return NULL; } diff --git a/src/w_wad.c b/src/w_wad.c index 7e1ec30df..432f1421f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -697,12 +697,12 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lump_p->name, '\0', 9); // Making sure they're initialized to 0. Is it necessary? @@ -1667,9 +1667,9 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si if (fread(rawData, 1, rawSize, handle) < rawSize) I_Error("wad %d, lump %d: cannot read compressed data", wad, lump); - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; + strm.zalloc = NULL; + strm.zfree = NULL; + strm.opaque = NULL; strm.total_in = strm.avail_in = rawSize; strm.total_out = strm.avail_out = decSize; @@ -2238,14 +2238,14 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. if (*trimname) // Ignore directories, well kinda { - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? @@ -2483,14 +2483,14 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. if (*trimname) // Ignore directories, well kinda { - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? diff --git a/src/y_inter.c b/src/y_inter.c index d35fa7825..27e794ffc 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -104,7 +104,7 @@ typedef struct } y_voteclient; // votescreen stuff -votescreen_t VoteScreen = {0}; +votescreen_t VoteScreen = {}; static y_votelvlinfo levelinfo[5]; static y_voteclient voteclient; @@ -1093,7 +1093,7 @@ void Y_VoteDrawer(void) V_DrawSmallScaledPatch(BASEVIDWIDTH-100, y, V_SNAPTORIGHT, pic); else { - V_DrawFixedPatch((BASEVIDWIDTH-20)< Date: Thu, 8 Jan 2026 00:33:43 +0100 Subject: [PATCH 068/589] enable "Wzero-as-null-pointer-constant", fix cases of it prevent ambiguity shoutout blankart for making me aware this exists --- src/Makefile.d/versions.mk | 2 +- src/blua/lstrlib.c | 2 +- src/blua/luaconf.h | 6 +++--- src/d_clisrv.c | 14 +++++++------- src/d_main.c | 3 ++- src/d_netcmd.c | 14 +++++++------- src/f_finale.c | 2 +- src/g_demo.c | 2 +- src/g_game.c | 14 +++++++------- src/hardware/hw_batching.c | 2 +- src/hardware/hw_md2load.c | 28 ++++++++++++++-------------- src/hardware/hw_md3load.c | 24 ++++++++++++------------ src/hardware/hw_model.c | 18 +++++++++--------- src/hardware/r_opengl/r_opengl.c | 12 ++++++------ src/http-mserv.c | 8 ++++---- src/lua_mobjlib.c | 2 +- src/m_cheat.c | 8 ++++---- src/m_cond.c | 2 +- src/m_menu.c | 8 ++++---- src/m_perfstats.c | 18 +++++++++--------- src/p_enemy.c | 8 ++++---- src/p_mobj.c | 24 ++++++++++++------------ src/p_setup.c | 4 ++-- src/p_spec.c | 6 +++--- src/r_main.cpp | 2 +- src/r_skins.c | 2 +- src/r_things.cpp | 4 ++-- src/s_sound.c | 6 +++--- src/s_sound.h | 4 ++-- src/strcasestr.c | 8 ++++---- src/w_wad.c | 18 +++++++++--------- src/y_inter.c | 8 ++++---- 32 files changed, 142 insertions(+), 141 deletions(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 2a80cfa39..e57119fb9 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference +WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference -Wzero-as-null-pointer-constant ifndef GCC295 #WFLAGS+=-Wno-packed endif diff --git a/src/blua/lstrlib.c b/src/blua/lstrlib.c index e2fd23604..6fe279bcb 100644 --- a/src/blua/lstrlib.c +++ b/src/blua/lstrlib.c @@ -527,7 +527,7 @@ static int str_find_aux (lua_State *L, int find) { if (find) { lua_pushinteger(L, s1-s+1); /* start */ lua_pushinteger(L, res-s); /* end */ - return push_captures(&ms, NULL, 0) + 2; + return push_captures(&ms, NULL, NULL) + 2; } else return push_captures(&ms, s1, res); diff --git a/src/blua/luaconf.h b/src/blua/luaconf.h index 76a798751..22fa8bf53 100644 --- a/src/blua/luaconf.h +++ b/src/blua/luaconf.h @@ -772,10 +772,10 @@ union luai_Cast { double l_d; long l_l; }; #include #if defined(__GNUC__) -#define l_likely(x) (__builtin_expect(((x) != 0), 1)) -#define l_unlikely(x) (__builtin_expect(((x) != 0), 0)) +#define l_likely(x) (__builtin_expect(!!(x), 1)) +#define l_unlikely(x) (__builtin_expect(!!(x), 0)) #else -#define l_likely(x) (x) +#define l_likely(x) (x) #define l_unlikely(x) (x) #endif diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d4983daa2..68ab08c5a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -332,7 +332,7 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(const UINT8 **p, INT32 playernu #ifdef PARANOIA if (id >= MAXNETXCMD) I_Error("Command id %d too big", id); - if (listnetxcmd[id] != 0) + if (listnetxcmd[id] != NULL) I_Error("Command id %d already used", id); #endif listnetxcmd[id] = cmd_f; @@ -1236,7 +1236,7 @@ static void CL_DrawConnectionStatus(void) va(" %4uK/%4uK", currentsize>>10, totalsize>>10)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, - va("%3.1fK/s ", ((double)getbps)/1024)); + va("%3.1fK/s ", ((double)getbps)/1024.0)); } else cltext = M_GetText("Waiting to download game state..."); @@ -1963,7 +1963,7 @@ static boolean SV_ResendingSavegameToAnyone(void) static void SV_SendSaveGame(INT32 node, boolean resending) { size_t length, compressedlen; - savebuffer_t save = {0}; + savebuffer_t save = {}; UINT8 *compressedsave; UINT8 *buffertosend; @@ -2033,7 +2033,7 @@ static consvar_t cv_dumpconsistency = {"dumpconsistency", "Off", CV_NETVAR, CV_O static void SV_SavedGame(void) { size_t length; - savebuffer_t save = {0}; + savebuffer_t save = {}; char tmpsave[264]; if (!cv_dumpconsistency.value) @@ -2073,7 +2073,7 @@ static void SV_SavedGame(void) static void CL_LoadReceivedSavegame(boolean reloading) { - savebuffer_t save = {0}; + savebuffer_t save = {}; size_t length, decompressedlen; char tmpsave[264]; @@ -7237,7 +7237,7 @@ void CL_ClearRewinds(void) rewind_t *CL_SaveRewindPoint(size_t demopos) { - savebuffer_t save = {0}; + savebuffer_t save = {}; rewind_t *rewind; if (rewindhead && rewindhead->leveltime + REWIND_POINT_INTERVAL > leveltime) @@ -7260,7 +7260,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos) rewind_t *CL_RewindToTime(tic_t time) { - savebuffer_t save = {0}; + savebuffer_t save = {}; rewind_t *rewind; while (rewindhead && rewindhead->leveltime > time) diff --git a/src/d_main.c b/src/d_main.c index ab5fe7a10..3e474cec3 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1865,7 +1865,8 @@ void D_SRB2Main(void) if (M_CheckParm("-warp") && M_IsNextParm()) { const char *word = M_GetNextParm(); - pstartmap = G_FindMapByNameOrCode(word, 0); + pstartmap = G_FindMapByNameOrCode(word, NULL); + if (! pstartmap) I_Error("Cannot find a map remotely named '%s'\n", word); else diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c669da59b..781120be2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -249,7 +249,7 @@ consvar_t cv_competitionboxes = {"competitionboxes", "Random", CV_NETVAR|CV_CHEA #ifdef SEENAMES static CV_PossibleValue_t seenames_cons_t[] = {{0, "Off"}, {1, "Colorless"}, {2, "Team"}, {3, "Ally/Foe"}, {0, NULL}}; -consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_seenames = {"seenames", "Off", CV_SAVE, seenames_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowseenames = {"allowseenames", "No", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif @@ -458,16 +458,16 @@ consvar_t cv_showping = {"showping", "Always", CV_SAVE, showping_cons_t, NULL, 0 static CV_PossibleValue_t pingmeasurement_cons_t[] = {{0, "Frames"}, {1, "Milliseconds"}, {0, NULL}}; consvar_t cv_pingmeasurement = {"pingmeasurement", "Frames", CV_SAVE, pingmeasurement_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pingicon = {"pingicon", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t cv_pingstyle_cons_t[] = {{0, "New"}, {1, "Old"}, {0, NULL}}; -consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pingstyle = {"pingstyle", "New", CV_SAVE, cv_pingstyle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_luaimmersion = {"luaimmersion", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showviewpointtext = {"showviewpointtext", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, 0, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showdownloadprompt = {"showdownloadprompt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // Intermission time Tails 04-19-2002 static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NULL}}; @@ -2789,7 +2789,7 @@ static void Command_Map_f(void) // G_TOLFlag handles both multiplayer gametype and ignores it for !multiplayer else { - if (!mapheaderinfo[newmapnum-1]) + if (mapheaderinfo[newmapnum-1] == NULL) { CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum)); return; diff --git a/src/f_finale.c b/src/f_finale.c index 801af8ab5..32ed8c3ec 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1318,7 +1318,7 @@ boolean F_ContinueResponder(event_t *event) keypressed = true; imcontinuing = true; continuetime = TICRATE; - S_StartSound(0, sfx_itemup); + S_StartSound(NULL, sfx_itemup); return true; } diff --git a/src/g_demo.c b/src/g_demo.c index 312e57530..ede5adf18 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -76,7 +76,7 @@ static tic_t demostarttime; // for comparative timing purposes //@TODO put these all in a struct for namespacing purposes? static char demoname[128]; -savebuffer_t demobuf = {0}; +savebuffer_t demobuf = {}; static UINT8 *demotime_p, *demoinfo_p; static UINT8 *demoend; static UINT8 demoflags; diff --git a/src/g_game.c b/src/g_game.c index 892579163..27a2922a8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3501,7 +3501,7 @@ void G_LoadGameData(void) INT32 i, j; UINT8 modded = false; UINT8 rtemp; - savebuffer_t save = {0}; + savebuffer_t save = {}; //For records tic_t rectime; @@ -3634,7 +3634,7 @@ void G_SaveGameData(boolean force) size_t length; INT32 i, j; UINT8 btemp; - savebuffer_t save = {0}; + savebuffer_t save = {}; (void)force; char backupfile[MAX_WADPATH+4]; @@ -3805,7 +3805,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride) size_t length; char vcheck[VERSIONSIZE]; char savename[255]; - savebuffer_t save = {0}; + savebuffer_t save = {}; // memset savedata to all 0, fixes calling perfectly valid saves corrupt because of bots memset(&savedata, 0, sizeof(savedata)); @@ -3891,7 +3891,7 @@ void G_SaveGame(UINT32 savegameslot) boolean saved; char savename[256] = ""; const char *backup; - savebuffer_t save = {0}; + savebuffer_t save = {}; sprintf(savename, savegamename, savegameslot); backup = va("%s",savename); @@ -4161,7 +4161,7 @@ static void measurekeywords(mapsearchfreq_t *fr, PU_STATIC, NULL); for (qp = strtok(va("%s", q), " "); qp && fr->total < 255; - qp = strtok(0, " ")) + qp = strtok(NULL, " ")) { if (( sp = strcasestr(s, qp) )) { @@ -4242,7 +4242,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, { newmapnum = mapnum; newmapname = realmapname; - realmapname = 0; + realmapname = NULL; Z_Free(apromapname); if (!wanttable) break; @@ -4263,7 +4263,7 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, { apromapnum = mapnum; apromapname = realmapname; - realmapname = 0; + realmapname = NULL; } } else/* ...match individual keywords */ diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 4d6b1ea6e..8bf7f7375 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -391,7 +391,7 @@ void HWR_RenderBatches(void) nextSurfaceInfo = nextEntry->surf; if (nextPolyFlags & PF_NoTexture) - nextTexture = 0; + nextTexture = NULL; if (useshader && currentShader != nextShader) { diff --git a/src/hardware/hw_md2load.c b/src/hardware/hw_md2load.c index 3805deffb..d28ebf058 100644 --- a/src/hardware/hw_md2load.c +++ b/src/hardware/hw_md2load.c @@ -274,7 +274,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) if (!f) return NULL; - retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); + retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); //size_t fileLen; @@ -288,13 +288,13 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) { texPos++; namelen = strlen(texPos) + 1; - texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0); + texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); strcpy(texturefilename, texPos); } else { namelen = strlen(fileName) + 1; - texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0); + texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, NULL); strcpy(texturefilename, fileName); } @@ -316,7 +316,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) header = (md2header_t*)buffer; retModel->numMeshes = 1; // MD2 only has one mesh - retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, 0); + retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, NULL); retModel->meshes[0].numFrames = header->numFrames; // const float WUNITS = 1.0f; // float dataScale = WUNITS; @@ -332,7 +332,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) if (retModel->numMaterials <= 0) // Always at least one skin, duh retModel->numMaterials = 1; - retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); + retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); // int t; for (t = 0; t < retModel->numMaterials; t++) @@ -409,9 +409,9 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) float *uvptr; dataScale = 0.015624f; // 1 / 64.0f - retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, 0); + retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, NULL); retModel->meshes[0].numVertices = header->numXYZ; - retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); + retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); ptr = (char*)frames; for (i = 0; i < header->numFrames; i++, ptr += header->framesize) @@ -423,12 +423,12 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) md2vertex_t *vertex; md2frame_t *framePtr = (md2frame_t*)ptr; - retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, 0); - retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, 0); + retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, NULL); + retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag); - retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, 0); + retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, NULL); vertptr = retModel->meshes[0].tinyframes[i].vertices; normptr = retModel->meshes[0].tinyframes[i].normals; @@ -484,8 +484,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) char *ptr; retModel->meshes[0].numVertices = header->numTris * 3; - retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, 0); - retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); + retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, NULL); + retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, NULL); trisPtr = tris; uvptr = retModel->meshes[0].uvs; @@ -507,8 +507,8 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) md2vertex_t *vertex; md2frame_t *framePtr = (md2frame_t*)ptr; - retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); - retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); + retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); + retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag); //float *vertptr, *normptr; diff --git a/src/hardware/hw_md3load.c b/src/hardware/hw_md3load.c index 53f6034c0..b536c7e73 100644 --- a/src/hardware/hw_md3load.c +++ b/src/hardware/hw_md3load.c @@ -168,7 +168,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) if (!f) return NULL; - retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); + retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); // find length of file fseek(f, 0, SEEK_END); @@ -201,7 +201,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) if (retModel->numMaterials <= 0) // Always at least one skin, duh retModel->numMaterials = 1; - retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); + retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, NULL); for (t = 0; t < retModel->numMaterials; t++) { @@ -225,7 +225,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) retModel->materials[t].spheremap = false; } - retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, 0); + retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, NULL); matCount = 0; for (i = 0, surfEnd = 0; i < mdh->numSurfaces; i++) @@ -298,9 +298,9 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) unsigned short *indexptr; md3Triangle *mdT; - retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, 0); + retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, NULL); retModel->meshes[i].numVertices = mdS->numVerts; - retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, 0); + retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, NULL); for (j = 0; j < mdS->numFrames; j++) { short *vertptr; @@ -308,12 +308,12 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) // char *tanptr; int k; md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); - retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, 0); - retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, 0); + retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, NULL); + retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, NULL); // if (retModel->materials[0].lightmap) // retModel->meshes[i].tinyframes[j].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag); - retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, 0); + retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, NULL); vertptr = retModel->meshes[i].tinyframes[j].vertices; normptr = retModel->meshes[i].tinyframes[j].normals; @@ -374,16 +374,16 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) int k; retModel->meshes[i].numVertices = mdS->numTriangles * 3;//mdS->numVerts; - retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, 0); - retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, 0); + retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, NULL); + retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, NULL); for (j = 0; j < mdS->numFrames; j++) { float *vertptr; float *normptr; md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); - retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0); - retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0); + retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); + retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); // if (retModel->materials[i].lightmap) // retModel->meshes[i].frames[j].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag); vertptr = retModel->meshes[i].frames[j].vertices; diff --git a/src/hardware/hw_model.c b/src/hardware/hw_model.c index 8698365e4..274c23394 100644 --- a/src/hardware/hw_model.c +++ b/src/hardware/hw_model.c @@ -189,7 +189,7 @@ model_t *LoadModel(const char *filename, int ztag) return NULL; } - model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, 0); + model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, NULL); strcpy(model->mdlFilename, filename); Optimize(model); @@ -237,7 +237,7 @@ void GenerateVertexNormals(model_t *model) { mdlframe_t *frame = &mesh->frames[j]; int memTag = PU_STATIC; - float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, 0); + float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, NULL); int k; float *vertPtr = frame->vertices; float *oldNormals; @@ -309,7 +309,7 @@ static boolean AddMaterialToList(materiallist_t **head, material_t *material) } // Didn't find it, so add to the list - newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, 0); + newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, NULL); newMatNode->material = material; ListAdd(newMatNode, (listitem_t**)head); return true; @@ -351,7 +351,7 @@ void Optimize(model_t *model) } memTag = PU_STATIC; - newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, 0); + newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, NULL); i = 0; for (node = matListHead; node; node = node->next) @@ -377,14 +377,14 @@ void Optimize(model_t *model) newMesh->numFrames = 1; newMesh->numTriangles = numTriangles; newMesh->numVertices = numTriangles * 3; - newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0); - newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0); + newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, NULL); + newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, NULL); curFrame = &newMesh->frames[0]; curFrame->material = curMat; - curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); - curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); - curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0); + curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); + curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, NULL); + curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, NULL); // Now traverse the meshes of the model, adding in // vertices/normals/uvs that match the current material diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index edd2f51a7..fab0a8a6d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -98,10 +98,10 @@ static size_t textureBufferSize = 0; static LTListItem *LightTablesTail = NULL; static LTListItem *LightTablesHead = NULL; -static RGBA_t screenPalette[256] = {0}; // the palette for the postprocessing step in palette rendering +static RGBA_t screenPalette[256] = {}; // the palette for the postprocessing step in palette rendering static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table -RGBA_t myPaletteData[256] = {0}; // the palette for converting textures to RGBA +RGBA_t myPaletteData[256] = {}; // the palette for converting textures to RGBA static GLint gltexformat = GL_RGB5_A1; GLint screen_width = 0; // used by Draw2DLine() @@ -127,9 +127,9 @@ GLuint gl_num_extensions; int majorGL = 0, minorGL = 0; //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) -GLfloat modelMatrix[16] = {0}; -GLfloat projMatrix[16] = {0}; -static GLint viewport[4]; +GLfloat modelMatrix[16] = {}; +GLfloat projMatrix[16] = {}; +static GLint viewport[4]; #ifdef USE_FBO_OGL enum @@ -171,7 +171,7 @@ boolean supportstencil = false; // flush all of the stored textures, leaving them unavailable at times such as between levels // These need to start at 0 and be set to their number, and be reset to 0 when deleted so that Intel GPUs // can know when the textures aren't there, as textures are always considered resident in their virtual memory -static GLuint screenTextures[NUMSCREENTEXTURES] = {0}; +static GLuint screenTextures[NUMSCREENTEXTURES] = {}; #define byte2float(byte) (GLfloat)(byte / 255.0f) diff --git a/src/http-mserv.c b/src/http-mserv.c index 8e35f905d..fd63c5f69 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -189,7 +189,7 @@ HMS_connect (const char *format, ...) seek = strlen(hms_api) + 1;/* + '/' */ va_start (ap, format); - url = malloc(seek + vsnprintf(0, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); + url = malloc(seek + vsnprintf(NULL, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); va_end (ap); sprintf(url, "%s/", hms_api); @@ -471,8 +471,8 @@ HMS_fetch_servers (msg_server_t *list, int query_id) *end = '\0'; address = strtok(p, " "); - port = strtok(0, " "); - contact = strtok(0, ""); + port = strtok(NULL, " "); + contact = strtok(NULL, ""); if (address && port) { @@ -539,7 +539,7 @@ HMS_compare_mod_version (char *buffer, size_t buffer_size) if (HMS_do(hms)) { version = strtok(hms->buffer, " "); - version_name = strtok(0, "\n"); + version_name = strtok(NULL, "\n"); if (version && version_name) { diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 45c3a9f19..9bd5f5203 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -475,7 +475,7 @@ int mobj_localskin_setter(lua_State *L) } else { - mo->localskin = 0; + mo->localskin = NULL; mo->skinlocal = false; } } diff --git a/src/m_cheat.c b/src/m_cheat.c index 2890c7196..58bc1401d 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -80,7 +80,7 @@ static UINT8 cheatf_warp(void) if (success) { G_SaveGameData(true); //G_SetGameModified(false); - S_StartSound(0, sfx_kc42); + S_StartSound(NULL, sfx_kc42); } // Refresh secrets menu existing. @@ -117,13 +117,13 @@ static UINT8 cheatf_devmode(void) #endif static cheatseq_t cheat_warp = { - 0, cheatf_warp, + NULL, cheatf_warp, //{ SCRAMBLE('r'), SCRAMBLE('e'), SCRAMBLE('d'), SCRAMBLE('x'), SCRAMBLE('v'), SCRAMBLE('i'), 0xff } { SCRAMBLE('b'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), SCRAMBLE('n'), SCRAMBLE('a'), 0xff } }; static cheatseq_t cheat_warp_joy = { - 0, cheatf_warp, + NULL, cheatf_warp, /*{ SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_UPARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), @@ -136,7 +136,7 @@ static cheatseq_t cheat_warp_joy = { #ifdef DEVELOP static cheatseq_t cheat_devmode = { - 0, cheatf_devmode, + NULL, cheatf_devmode, { SCRAMBLE('d'), SCRAMBLE('e'), SCRAMBLE('v'), SCRAMBLE('m'), SCRAMBLE('o'), SCRAMBLE('d'), SCRAMBLE('e'), 0xff } }; #endif diff --git a/src/m_cond.c b/src/m_cond.c index acf78e6ef..126d5a49a 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -235,7 +235,7 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1 wnum = conditionSets[set - 1].numconditions; num = ++conditionSets[set - 1].numconditions; - conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, 0); + conditionSets[set - 1].condition = Z_Realloc(conditionSets[set - 1].condition, sizeof(condition_t)*num, PU_STATIC, NULL); cond = conditionSets[set - 1].condition; diff --git a/src/m_menu.c b/src/m_menu.c index c2978fe82..55112356b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5385,7 +5385,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na { CONS_Printf("custom settings menu initiation\n"); for (CVARSETUP = 0; CVARSETUP < MAXMENUCCVARS; ++CVARSETUP) - OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", 0, INT16_MAX}; + OP_CustomCvarMenu[CVARSETUP] = (menuitem_t){IT_DISABLED, NULL, "", NULL, INT16_MAX}; } if (category && ((ccvarposition == 0 && category[0] != '\0') || !fasticmp(category, OP_CustomCvarMenu[ccvarlaststheader].text))) @@ -7494,7 +7494,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) if ((lumpnum = W_CheckNumForName(va("%sE", mapname))) != LUMPERROR) mappingforencore = (patch_t *)W_CachePatchNum(lumpnum, PU_PATCH);*/ - V_DrawFixedPatch((x+w)<>1), (staty+67)<>1, 0, statlr, flashcol); V_DrawFixedPatch((statx+40+GRIDSTATOFFSET)<>1, 0, statud, flashcol); // bg - V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<>1), (staty+73)<>1, 0, statbg, 0); + V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<>1), (staty+73)<>1, 0, statbg, NULL); for (i = 0; i < numskins; i++) // draw the stat dots { @@ -8218,7 +8218,7 @@ static void M_DrawSetupMultiPlayerMenu(void) V_DrawFixedPatch((statx+64)<flags2 & MF2_FRET) { P_SetMobjState(actor, S_BLACKEGG_DESTROYPLAT1); - S_StartSound(0, sfx_s3k53); + S_StartSound(NULL, sfx_s3k53); actor->flags2 &= ~MF2_FRET; return; } @@ -6011,7 +6011,7 @@ void A_Boss7Chase(void *thing) { // Punch him! P_SetMobjState(actor, actor->info->meleestate); - S_StartSound(0, sfx_begrnd); // warning sound + S_StartSound(NULL, sfx_begrnd); // warning sound return; } } @@ -6057,7 +6057,7 @@ void A_Boss7Chase(void *thing) case 2: // Homing Missile A_FaceTarget(actor); P_SetMobjState(actor, actor->info->missilestate); - S_StartSound(0, sfx_beflap); + S_StartSound(NULL, sfx_beflap); break; } @@ -10739,7 +10739,7 @@ void A_BrakChase(void *thing) { actor->reactiontime--; if (actor->reactiontime == 0 && actor->type == MT_CYBRAKDEMON) - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } // modify target threshold diff --git a/src/p_mobj.c b/src/p_mobj.c index ad7982d87..581edf2f0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3606,10 +3606,10 @@ static void P_CalculatePrecipFloor(precipmobj_t *mobj) // Just the identification of a precip thinker. The thinker // should never actually be called! // -void P_NullPrecipThinker(precipmobj_t *mobj) +FUNCNORETURN void P_NullPrecipThinker(precipmobj_t *mobj) { (void)mobj; - I_Assert("P_NullPrecipThinker should not be called" == 0); + I_Error("P_NullPrecipThinker should not be called"); } boolean P_PrecipThinker(precipmobj_t *mobj) @@ -4012,7 +4012,7 @@ static void P_Boss3Thinker(mobj_t *mobj) if ((UINT32)mobj->extravalue1 + TICRATE*2 < leveltime) { mobj->extravalue1 = (INT32)leveltime; - S_StartSound(0, sfx_buzz1); + S_StartSound(NULL, sfx_buzz1); } // If in the center, check to make sure @@ -4631,7 +4631,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (mobj->health > 0) mobj->health--; - S_StartSound(0, (mobj->health) ? sfx_behurt : sfx_bedie2); + S_StartSound(NULL, (mobj->health) ? sfx_behurt : sfx_bedie2); mobj->reactiontime /= 3; @@ -4670,7 +4670,7 @@ static void P_Boss7Thinker(mobj_t *mobj) INT32 i; mobj->state->nextstate = mobj->info->painstate; // Reset - S_StartSound(0, sfx_bedeen); + S_StartSound(NULL, sfx_bedeen); for (i = 0; i < MAXPLAYERS; i++) { @@ -4694,7 +4694,7 @@ static void P_Boss7Thinker(mobj_t *mobj) mobj->state->nextstate = mobj->info->spawnstate; // Laugh - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } } } @@ -4714,7 +4714,7 @@ static void P_Boss7Thinker(mobj_t *mobj) var2 = 2*TICRATE + (80<<16); A_LobShot(mobj); - S_StartSound(0, sfx_begoop); + S_StartSound(NULL, sfx_begoop); } } else if (mobj->state == &states[S_BLACKEGG_SHOOT2]) @@ -4738,7 +4738,7 @@ static void P_Boss7Thinker(mobj_t *mobj) S_StopSound(missile); if (leveltime & 1) - S_StartSound(0, sfx_beshot); + S_StartSound(NULL, sfx_beshot); } else if (mobj->state == &states[S_BLACKEGG_JUMP1] && mobj->tics == 1) { @@ -4871,7 +4871,7 @@ static void P_Boss7Thinker(mobj_t *mobj) fixed_t x,y,z; mobj_t *mo2; - S_StartSound(0, sfx_befall); + S_StartSound(NULL, sfx_befall); z = mobj->floorz; for (j = 0; j < 2; j++) @@ -4910,13 +4910,13 @@ static void P_Boss7Thinker(mobj_t *mobj) P_DamageMobj(players[i].mo, mobj, mobj, 1); // Laugh - S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); + S_StartSound(NULL, sfx_bewar1 + P_RandomKey(4)); } P_SetMobjState(mobj, mobj->info->spawnstate); } else if (mobj->state == &states[mobj->info->deathstate] && mobj->tics == mobj->state->tics) - S_StartSound(0, sfx_bedie1 + (P_RandomFixed() & 1)); + S_StartSound(NULL, sfx_bedie1 + (P_RandomFixed() & 1)); } // Metal Sonic battle boss @@ -10711,7 +10711,7 @@ void P_SpawnPlayer(INT32 playernum) // the dead body mobj retains the skin through the 'spritedef' override). mobj->skin = &skins[p->skin]; - mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : 0); + mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : NULL); mobj->skinlocal = p->skinlocal; mobj->health = p->health; diff --git a/src/p_setup.c b/src/p_setup.c index bf40afe9d..612530882 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1022,7 +1022,7 @@ void P_WriteThings(lumpnum_t lumpnum) size_t i, length; mapthing_t *mt; UINT8 *data; - savebuffer_t save = {0}; + savebuffer_t save = {}; INT16 temp; data = W_CacheLumpNum(lumpnum, PU_LEVEL); @@ -1166,7 +1166,7 @@ static void P_LoadLineDefs2(void) for (; i--; ld++) { ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here - ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; + ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : NULL; // Repeat count for midtexture if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff)) diff --git a/src/p_spec.c b/src/p_spec.c index 66901d234..5045a8287 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4579,8 +4579,8 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor) if (!sec->ffloors) { sec->ffloors = ffloor; - ffloor->next = 0; - ffloor->prev = 0; + ffloor->next = NULL; + ffloor->prev = NULL; return; } @@ -4588,7 +4588,7 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor) rover->next = ffloor; ffloor->prev = rover; - ffloor->next = 0; + ffloor->next = NULL; } /** Adds a 3Dfloor. diff --git a/src/r_main.cpp b/src/r_main.cpp index fecfba580..e3bfb83fa 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1087,7 +1087,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) ret = &subsectors[nodenum & ~NF_SUBSECTOR]; for (i = 0; i < ret->numlines; i++) if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side) - return 0; + return NULL; return ret; } diff --git a/src/r_skins.c b/src/r_skins.c index 538b8c38a..41971788c 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -302,7 +302,7 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) if (player->mo) { - player->mo->localskin = 0; + player->mo->localskin = NULL; player->mo->skinlocal = false; } } diff --git a/src/r_things.cpp b/src/r_things.cpp index cab9512e3..77b02b78c 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -532,8 +532,8 @@ void R_ClearSprites(void) visspritecount = numvisiblesprites = clippedvissprites = 0; } -static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0}; -static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {0}; +static INT16 *vissprite_clipbot[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {}; +static INT16 *vissprite_cliptop[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {}; static void R_AllocVisSpriteChunkMemory(UINT32 chunk) { diff --git a/src/s_sound.c b/src/s_sound.c index e8075469c..7f931671d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -884,7 +884,7 @@ static void S_StopChannel(INT32 cnum) if (cnum != i && c->sfxinfo == channels[i].sfxinfo) break; - c->sfxinfo = 0; + c->sfxinfo = NULL; } c->origin = NULL; @@ -1271,7 +1271,7 @@ static musicdef_t *S_AddMusicCredit(void) return &musicdefs[chunk][i]; } -struct cursongcredit cursongcredit = {0}; // Currently displayed song credit info +struct cursongcredit cursongcredit = {}; // Currently displayed song credit info static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicdef_t **defp) { @@ -1704,7 +1704,7 @@ static void S_UnloadMusic(void) music.flags = 0; music.looping = false; - music_refade_cv = 0; + music_refade_cv = NULL; } static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) diff --git a/src/s_sound.h b/src/s_sound.h index 9e0296d2b..c7f487e92 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -253,9 +253,9 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 void S_ChangeMusicSpecial (const char *mmusic); -void S_SetRestoreMusicFadeInCvar (consvar_t *cvar); +void S_SetRestoreMusicFadeInCvar(consvar_t *cvar); #define S_ClearRestoreMusicFadeInCvar() \ - S_SetRestoreMusicFadeInCvar(0) + S_SetRestoreMusicFadeInCvar(NULL) int S_GetRestoreMusicFadeIn (void); // Stops the music. diff --git a/src/strcasestr.c b/src/strcasestr.c index d24a36e54..f50141dcf 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -73,8 +73,8 @@ nongnu_strcasestr (const char *s, const char *q) up = strchr(s, uc); lp = strchr(s, lc); - if (!( (intptr_t)up|(intptr_t)lp )) - return 0; + if (up == NULL || lp == NULL) + return NULL; if (!lp || ( up && up < lp )) { @@ -100,12 +100,12 @@ nongnu_strcasestr (const char *s, const char *q) if (trycmp(ppa, cpa, q, qn) == 0) return (*ppa); - if (!( (intptr_t)up|(intptr_t)lp )) + if (up == NULL || lp == NULL) break; if (!(*ppa) || ( (*ppb) && (*ppb) < (*ppa) )) swapp(&ppa, &ppb, &cpa, &cpb); } - return 0; + return NULL; } diff --git a/src/w_wad.c b/src/w_wad.c index 7e1ec30df..432f1421f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -697,12 +697,12 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lump_p->name, '\0', 9); // Making sure they're initialized to 0. Is it necessary? @@ -1667,9 +1667,9 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si if (fread(rawData, 1, rawSize, handle) < rawSize) I_Error("wad %d, lump %d: cannot read compressed data", wad, lump); - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; + strm.zalloc = NULL; + strm.zfree = NULL; + strm.opaque = NULL; strm.total_in = strm.avail_in = rawSize; strm.total_out = strm.avail_out = decSize; @@ -2238,14 +2238,14 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. if (*trimname) // Ignore directories, well kinda { - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? @@ -2483,14 +2483,14 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); // Strip away file address and extension for the 8char name. - if ((trimname = strrchr(fullname, '/')) != 0) + if ((trimname = strrchr(fullname, '/')) != NULL) trimname++; else trimname = fullname; // Care taken for root files. if (*trimname) // Ignore directories, well kinda { - if ((dotpos = strrchr(trimname, '.')) == 0) + if ((dotpos = strrchr(trimname, '.')) == NULL) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? diff --git a/src/y_inter.c b/src/y_inter.c index d35fa7825..27e794ffc 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -104,7 +104,7 @@ typedef struct } y_voteclient; // votescreen stuff -votescreen_t VoteScreen = {0}; +votescreen_t VoteScreen = {}; static y_votelvlinfo levelinfo[5]; static y_voteclient voteclient; @@ -1093,7 +1093,7 @@ void Y_VoteDrawer(void) V_DrawSmallScaledPatch(BASEVIDWIDTH-100, y, V_SNAPTORIGHT, pic); else { - V_DrawFixedPatch((BASEVIDWIDTH-20)< Date: Thu, 8 Jan 2026 00:27:06 +0100 Subject: [PATCH 069/589] K_SpawnSparkleTrail: check for blend effect apply outside the loop tiny optimization --- src/k_kart.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index bb4da62a5..342414738 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3595,6 +3595,8 @@ void K_SpawnSparkleTrail(mobj_t *mo) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); + const boolean shouldblend = (mo->player && K_PlayerEffectsShouldBlend(mo->player)); + for (i = 0; i < 3; i++) { fixed_t newx = mo->x + mo->momx + (P_RandomRange(-rad, rad)<color = mo->color; - if (mo->player && K_PlayerEffectsShouldBlend(mo->player)) + if (shouldblend) sparkle->blendmode = AST_ADD; } From d938e38ad3d00a8fb0797d1d489446e026a4ab83 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 8 Jan 2026 00:26:02 +0100 Subject: [PATCH 070/589] Acessability: add basic "reducevfx" toggle to disable/reduce certain effects toggles certain effects, which may be troublesome to some players -disabled hyudoro flashing, instead makes player translucent - Makes rainbow colour effects, such as invul, change colours very slowly - Disables underwater and heatwave screen effects - Disables palette flashing - Disables vhs effect not the most pretty implementation, but im lazy and this works feel free to suggest more things --- src/g_game.h | 1 + src/hardware/hw_main.cpp | 24 ++++- src/hardware/hw_md2.c | 11 ++- src/k_kart.c | 11 ++- src/p_mobj.c | 3 +- src/r_things.cpp | 11 ++- src/v_video.c | 197 ++++++++++++++++++++------------------- 7 files changed, 150 insertions(+), 108 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index 509749c5f..6ecc69dfa 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -130,6 +130,7 @@ extern consvar_t cv_spinoutroll; extern consvar_t cv_squishdance, cv_squishdancespeed; extern consvar_t cv_playerblendeffects; +extern consvar_t cv_reducevfx; extern consvar_t cv_cechotoggle; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 70a5a3a8d..1622a4528 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3786,8 +3786,15 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } - if (cv_playerfade.value && sprmo->player) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + if (sprmo->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0) + Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + + if (cv_playerfade.value) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + } if (HWR_UseShader()) { @@ -4076,8 +4083,15 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } - if (cv_playerfade.value && sprmo->player) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + if (sprmo->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0) + Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + + if (cv_playerfade.value) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + } if (HWR_UseShader()) { @@ -6100,7 +6114,7 @@ static void HWR_DoPostProcessor(void) const camera_t *thiscam = &camera[0]; // Not supported in splitscreen - someone want to add support? - const boolean screenwave = (!splitscreen && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); + const boolean screenwave = (!splitscreen && !cv_reducevfx.value && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); // Capture the screen for intermission and screen waving if ((lastdraw || screenwave) && gamestate != GS_INTERMISSION) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 763fb873c..e45a56cda 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1198,8 +1198,15 @@ void HWR_DrawMD2(gl_vissprite_t *spr) Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); } - if (cv_playerfade.value && spr->mobj->player) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); + if (spr->mobj->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && spr->mobj->player->kartstuff[k_hyudorotimer] > 0) + Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + + if (cv_playerfade.value) + Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha); + } // dont forget to enabled the depth test because we can't do this like // before: polygons models are not sorted diff --git a/src/k_kart.c b/src/k_kart.c index 342414738..59271a1e4 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -47,6 +47,8 @@ consvar_t cv_airsparks = {"airdriftsparks", "Off", CV_SAVE, CV_OnOff, NULL, 0, N consvar_t cv_playerblendeffects = {"playerblendeffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_reducevfx = {"reducevfx", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + // funn-E streeetch static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; consvar_t cv_gravstretch = {"gravstretch", "MIN", CV_SAVE|CV_FLOAT, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -482,7 +484,8 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = { // UINT8 K_RainbowColor(void) { - return (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); + const INT32 time = cv_reducevfx.value ? (leveltime >> 3) : leveltime; + return (UINT8)(1 + (time % (MAXSKINCOLORS-1))); } // Define for getting accurate color brightness readings according to how the human eye sees them. @@ -764,6 +767,8 @@ void K_RegisterClientKartStuff(void) CV_RegisterVar(&cv_playerblendeffects); + CV_RegisterVar(&cv_reducevfx); + CV_RegisterVar(&cv_saltyhop); CV_RegisterVar(&cv_saltyhopsfx); CV_RegisterVar(&cv_saltysquish); @@ -6768,7 +6773,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) { if (splitscreen) { - if (leveltime & 1) + if (!cv_reducevfx.value && leveltime & 1) player->mo->flags2 |= MF2_DONTDRAW; else player->mo->flags2 &= ~MF2_DONTDRAW; @@ -6794,7 +6799,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (P_IsDisplayPlayer(player) || (!P_IsDisplayPlayer(player) && (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)))) { - if (leveltime & 1) + if (!cv_reducevfx.value && leveltime & 1) player->mo->flags2 |= MF2_DONTDRAW; else player->mo->flags2 &= ~MF2_DONTDRAW; diff --git a/src/p_mobj.c b/src/p_mobj.c index 581edf2f0..d1b8b850a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12354,8 +12354,9 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 allowai // void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration) { - if (!pl) + if (!pl || cv_reducevfx.value) // no palette flashing with reducevfx return; + pl->flashcount = duration; pl->flashpal = type; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 77b02b78c..d1c856238 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1588,8 +1588,15 @@ static void R_ProjectSprite(mobj_t *thing) else trans = 0; - if (cv_playerfade.value && thing->player) - trans = static_cast(R_GetThingTransTable(R_DoPlayerFade(thing), static_cast(trans))); + if (thing->player) + { + // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap + if (cv_reducevfx.value && thing->player->kartstuff[k_hyudorotimer] > 0) + trans = static_cast(R_GetThingTransTable(FRACUNIT/2, static_cast(trans))); + + if (cv_playerfade.value) + trans = static_cast(R_GetThingTransTable(R_DoPlayerFade(thing), static_cast(trans))); + } //SoM: 3/17/2000: Disregard sprites that are out of view.. if (vflip) diff --git a/src/v_video.c b/src/v_video.c index ac85715ef..bb118d269 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -15,6 +15,7 @@ #include "doomdef.h" #include "d_main.h" +#include "g_game.h" #include "r_local.h" #include "p_local.h" #include "v_video.h" @@ -1755,6 +1756,9 @@ void V_DrawVhsEffect(boolean rewind) #endif SINT8 offs; + if (cv_reducevfx.value) + return; + barsize = vid.dup << 5; updistort = vid.dup << (rewind ? 5 : 3); downdistort = updistort >> 1; @@ -3639,127 +3643,130 @@ void V_DoPostProcessor(INT32 view, INT32 param) UINT8 *tmpscr = vid.screens[4]; UINT8 *srcscr = vid.screens[0]; - if (thiscam->postimg & POSTIMG_WATER) + if (!cv_reducevfx.value) { - INT32 y; - // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic - angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK; - INT32 newpix; - INT32 sine; - //UINT8 *transme = transtables + ((tr_trans50-1)<postimg & POSTIMG_WATER) { - sine = (FINESINE(disStart)*5)>>FRACBITS; - newpix = abs(sine); + INT32 y; + // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic + angle_t disStart = (((leveltime-1)*128) + (R_GetTimeFrac(RTF_LEVEL) / (FRACUNIT/128))) & FINEMASK; + INT32 newpix; + INT32 sine; + //UINT8 *transme = transtables + ((tr_trans50-1)<>FRACBITS; + newpix = abs(sine); - // Cleanup edge - while (newpix) + if (sine < 0) { - tmpscr[(y*vid.width)+xoffset+newpix] = srcscr[(y*vid.width)+xoffset]; - newpix--; - } - } - else - { - memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix); + memcpy(&tmpscr[(y*vid.width)+xoffset+newpix], &srcscr[(y*vid.width)+xoffset], viewwidth-newpix); - // Cleanup edge - while (newpix) + // Cleanup edge + while (newpix) + { + tmpscr[(y*vid.width)+xoffset+newpix] = srcscr[(y*vid.width)+xoffset]; + newpix--; + } + } + else { - tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)]; - newpix--; + memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix); + + // Cleanup edge + while (newpix) + { + tmpscr[(y*vid.width)+xoffset+viewwidth-newpix] = srcscr[(y*vid.width)+xoffset+(viewwidth-1)]; + newpix--; + } } + + /* + Unoptimized version + for (x = 0; x < vid.width; x++) + { + newpix = (x + sine); + + if (newpix < 0) + newpix = 0; + else if (newpix >= vid.width) + newpix = vid.width-1; + + tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); + }*/ + + disStart += 22;//the offset into the displacement map, increment each game loop + disStart &= FINEMASK; //clip it to FINEMASK } - /* - Unoptimized version - for (x = 0; x < vid.width; x++) - { - newpix = (x + sine); - - if (newpix < 0) - newpix = 0; - else if (newpix >= vid.width) - newpix = vid.width-1; - - tmpscr[y*vid.width + x] = srcscr[y*vid.width+newpix]; // *(transme + (srcscr[y*vid.width+x]<<8) + srcscr[y*vid.width+newpix]); - }*/ - - disStart += 22;//the offset into the displacement map, increment each game loop - disStart &= FINEMASK; //clip it to FINEMASK + UINT8 *tmp = tmpscr; + tmpscr = srcscr; + srcscr = tmp; } - - UINT8 *tmp = tmpscr; - tmpscr = srcscr; - srcscr = tmp; - } - else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave - { - INT32 y; - - // Make sure table is built - if (heatshifter == NULL || lastheight != viewheight) + else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave { - if (heatshifter) - Z_Free(heatshifter); + INT32 y; - heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL); - - for (y = 0; y < viewheight; y++) + // Make sure table is built + if (heatshifter == NULL || lastheight != viewheight) { - if (M_RandomChance(FRACUNIT/8)) // 12.5% - heatshifter[y] = true; + if (heatshifter) + Z_Free(heatshifter); + + heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL); + + for (y = 0; y < viewheight; y++) + { + if (M_RandomChance(FRACUNIT/8)) // 12.5% + heatshifter[y] = true; + } + + heatindex[0] = heatindex[1] = heatindex[2] = heatindex[3] = 0; + lastheight = viewheight; } - heatindex[0] = heatindex[1] = heatindex[2] = heatindex[3] = 0; - lastheight = viewheight; - } - - for (y = yoffset; y < yoffset+viewheight; y++) - { - if (heatshifter[heatindex[view]++]) + for (y = yoffset; y < yoffset+viewheight; y++) { - // Shift this row of pixels to the right by 2 - tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset]; - memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup); + if (heatshifter[heatindex[view]++]) + { + // Shift this row of pixels to the right by 2 + tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset]; + memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup); + } + else + memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); + + heatindex[view] %= viewheight; } - else - memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); - heatindex[view] %= viewheight; + if (renderisnewtic) // This isn't interpolated... but how do you interpolate a one-pixel shift? + { + heatindex[view]++; + heatindex[view] %= vid.height; + } + + UINT8 *tmp = tmpscr; + tmpscr = srcscr; + srcscr = tmp; } - if (renderisnewtic) // This isn't interpolated... but how do you interpolate a one-pixel shift? - { - heatindex[view]++; - heatindex[view] %= vid.height; - } - - UINT8 *tmp = tmpscr; - tmpscr = srcscr; - srcscr = tmp; - } - #ifdef MOTIONBLUR - if (thiscam->postimg & POSTIMG_MOTION) // Motion Blur! - { - INT32 x, y; - - // TODO: Add a postimg_param so that we can pick the translucency level... - UINT8 *transme = transtables + ((param-1)<postimg & POSTIMG_MOTION) // Motion Blur! { - for (x = xoffset; x < xoffset+viewwidth; x++) - tmpscr[y*vid.width + x] = colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))]; + INT32 x, y; + + // TODO: Add a postimg_param so that we can pick the translucency level... + UINT8 *transme = transtables + ((param-1)<postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down { From bdc326b14e49d73ff19784cc7ce391f8cb57a95e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 8 Jan 2026 00:43:35 +0100 Subject: [PATCH 071/589] leveltime be tic_t :chaosleep: --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 59271a1e4..6496f3e8e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -484,7 +484,7 @@ UINT8 colortranslations[MAXTRANSLATIONS][16] = { // UINT8 K_RainbowColor(void) { - const INT32 time = cv_reducevfx.value ? (leveltime >> 3) : leveltime; + const tic_t time = cv_reducevfx.value ? (leveltime >> 3) : leveltime; return (UINT8)(1 + (time % (MAXSKINCOLORS-1))); } From 8fe3d13935370048eaf2b3c20bf750a876625848 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 9 Jan 2026 11:08:10 +0100 Subject: [PATCH 072/589] fix InitColorLUT --- src/v_video.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index bb118d269..dbb3b385b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3821,7 +3821,7 @@ void InitColorLUT(colorlookup_t *lut, RGBA_t *palette, boolean makecolors) lut->init = true; memcpy(lut->palette, palette, palsize); - for (i = 0; i < 0xFFFF; i++) + for (i = 0; i < 0x10000; i++) lut->table[i] = 0xFFFF; if (makecolors) @@ -3834,7 +3834,9 @@ void InitColorLUT(colorlookup_t *lut, RGBA_t *palette, boolean makecolors) { for (b = 0; b < 0xFF; b++) { - lut->table[i] = GetColorLUT(lut, r, g, b); + i = CLUTINDEX(r, g, b); + if (lut->table[i] == 0xFFFF) + lut->table[i] = NearestPaletteColor(r, g, b, palette); } } } From 291a4dbb25472b459d6b74b3b40f378140322fd4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 9 Jan 2026 13:00:47 +0100 Subject: [PATCH 073/589] disable midnight channel border flicker with "reducevfx" --- src/st_stuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 99188e919..5ca3f9d91 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -720,7 +720,7 @@ void ST_DrawDemoTitleEntry(void) static void ST_MayonakaStatic(void) { INT32 flag; - if (cv_lessflicker.value) + if (cv_lessflicker.value || cv_reducevfx.value) flag = V_70TRANS; else flag = (leveltime%2) ? V_90TRANS : V_70TRANS; From bf1aa4785444bb528a0fb39c8087187d1cafa999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Tue, 6 Jan 2026 12:54:25 +0100 Subject: [PATCH 074/589] Simplify textcmd handling --- src/d_clisrv.c | 43 ++++++++----------------------------------- 1 file changed, 8 insertions(+), 35 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4da62742f..1ec57eaaf 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -212,14 +212,9 @@ tic_t firstconnectattempttime = 0; // engine -// Must be a power of two -#define TEXTCMD_HASH_SIZE 4 - typedef struct textcmdtic_s { - tic_t tic; UINT8 *playercmds[MAXPLAYERS]; - struct textcmdtic_s *next; } textcmdtic_t; typedef struct textcmdbuf_s textcmdbuf_t; @@ -234,7 +229,7 @@ static textcmdbuf_t *textcmdbuf[MAXSPLITSCREENPLAYERS] = {NULL}; static ticcmd_t playercmds[MAXPLAYERS]; ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS] = {}; -static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL}; +static textcmdtic_t *textcmds[BACKUPTICS] = {NULL}; consvar_t cv_showjoinaddress = {"showjoinaddress", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -396,20 +391,10 @@ void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_ // Frees all textcmd memory for the specified tic static void D_FreeTextcmd(tic_t tic) { - textcmdtic_t **tctprev = &textcmds[tic & (TEXTCMD_HASH_SIZE - 1)]; - textcmdtic_t *textcmdtic = *tctprev; - - while (textcmdtic && textcmdtic->tic != tic) - { - tctprev = &textcmdtic->next; - textcmdtic = textcmdtic->next; - } + textcmdtic_t *textcmdtic = textcmds[tic%BACKUPTICS]; if (textcmdtic) { - // Remove this tic from the list. - *tctprev = textcmdtic->next; - // Free all players. for (INT32 i = 0; i < MAXPLAYERS; i++) { @@ -418,14 +403,14 @@ static void D_FreeTextcmd(tic_t tic) // Free this tic's own memory. Z_Free(textcmdtic); + textcmds[tic%BACKUPTICS] = NULL; } } // Gets the buffer for the specified ticcmd, or NULL if there isn't one static UINT8* D_GetExistingTextcmd(tic_t tic, INT32 playernum) { - textcmdtic_t *textcmdtic = textcmds[tic & (TEXTCMD_HASH_SIZE - 1)]; - while (textcmdtic && textcmdtic->tic != tic) textcmdtic = textcmdtic->next; + textcmdtic_t *textcmdtic = textcmds[tic%BACKUPTICS]; // Do we have an entry for the tic? If so, look for player. if (textcmdtic) @@ -441,22 +426,11 @@ static UINT8* D_GetExistingTextcmd(tic_t tic, INT32 playernum) // Gets the buffer for the specified ticcmd, creating one if necessary static UINT8* D_GetTextcmd(tic_t tic, INT32 playernum) { - textcmdtic_t *textcmdtic = textcmds[tic & (TEXTCMD_HASH_SIZE - 1)]; - textcmdtic_t **tctprev = &textcmds[tic & (TEXTCMD_HASH_SIZE - 1)]; - - // Look for the tic. - while (textcmdtic && textcmdtic->tic != tic) - { - tctprev = &textcmdtic->next; - textcmdtic = textcmdtic->next; - } + textcmdtic_t *textcmdtic = textcmds[tic%BACKUPTICS]; // If we don't have an entry for the tic, make it. if (!textcmdtic) - { - textcmdtic = *tctprev = (textcmdtic_t*)Z_Calloc(sizeof (textcmdtic_t), PU_STATIC, NULL); - textcmdtic->tic = tic; - } + textcmds[tic%BACKUPTICS] = textcmdtic = (textcmdtic_t*)Z_Calloc(sizeof(textcmdtic_t), PU_STATIC, NULL); // If we don't have an entry for the player, make it. if (!textcmdtic->playercmds[playernum]) @@ -540,9 +514,8 @@ void D_ResetTiccmds(void) } // Reset the net command list - for (i = 0; i < TEXTCMD_HASH_SIZE; i++) - while (textcmds[i]) - D_Clearticcmd(textcmds[i]->tic); + for (i = 0; i < BACKUPTICS; i++) + D_Clearticcmd(i); } void SendKick(UINT8 playernum, UINT8 msg) From 0914d5b8e29496a5662fb318f44739ffb7aa69d4 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 11 Jan 2026 00:49:48 +0300 Subject: [PATCH 075/589] -Wzero-as-null-pointer-constant is valid for c only since GCC 15.2 (from what i see) --- src/Makefile.d/versions.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index e57119fb9..9a1706cc7 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,10 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference -Wzero-as-null-pointer-constant +WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference +ifdef GCC152 +WFLAGS+-Wzero-as-null-pointer-constant +endif ifndef GCC295 #WFLAGS+=-Wno-packed endif From 310f67a06c20a8594d740b6b10a9feeaf70bc745 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 11 Jan 2026 03:49:07 +0300 Subject: [PATCH 076/589] Fix smol mistake in strcasestr --- src/strcasestr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/strcasestr.c b/src/strcasestr.c index f50141dcf..3eb6af60f 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -73,7 +73,7 @@ nongnu_strcasestr (const char *s, const char *q) up = strchr(s, uc); lp = strchr(s, lc); - if (up == NULL || lp == NULL) + if (up == NULL && lp == NULL) return NULL; if (!lp || ( up && up < lp )) @@ -100,7 +100,7 @@ nongnu_strcasestr (const char *s, const char *q) if (trycmp(ppa, cpa, q, qn) == 0) return (*ppa); - if (up == NULL || lp == NULL) + if (up == NULL && lp == NULL) break; if (!(*ppa) || ( (*ppb) && (*ppb) < (*ppa) )) From e88773da4e81c51248666539c40d12be8b4f60aa Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 11 Jan 2026 13:08:23 +0300 Subject: [PATCH 077/589] How did i miss the = --- src/Makefile.d/versions.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 9a1706cc7..c3989bb4f 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -22,7 +22,7 @@ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference ifdef GCC152 -WFLAGS+-Wzero-as-null-pointer-constant +WFLAGS+=-Wzero-as-null-pointer-constant endif ifndef GCC295 #WFLAGS+=-Wno-packed From 264c9e38ad81235f8b7855cebb43ce5d0ec44533 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 11 Jan 2026 19:46:34 +0100 Subject: [PATCH 078/589] d_netfil: dont use zone memory in CURLGetFile --- src/d_netfil.c | 11 ++++++++--- src/d_netfil.h | 1 - 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index a4478fcc9..ed186bba5 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -131,6 +131,8 @@ static UINT32 curl_origtotalfilesize; static char *curl_realname = NULL; fileneeded_t *curl_curfile = NULL; HTTP_login *curl_logins = NULL; + +static void CURLGetFile(void); #endif /** Fills a serverinfo packet with information about wad files loaded. @@ -1305,6 +1307,7 @@ void CURLPrepareFile(const char* url, int dfilenum) if (!multi_handle) { cc = curl_global_init(CURL_GLOBAL_ALL); + if (cc < 0) { I_OutputMsg("libcurl: curl_global_init() returned %d\n", cc); @@ -1313,6 +1316,7 @@ void CURLPrepareFile(const char* url, int dfilenum) { multi_handle = curl_multi_init(); } + if (!multi_handle) { I_OutputMsg("libcurl: curl_multi_init() failed\n"); @@ -1441,7 +1445,7 @@ void CURLAbortFile(void) #endif } -void CURLGetFile(void) +static void CURLGetFile(void) { #ifdef HAVE_THREADS I_lock_mutex(&downloadmutex); @@ -1483,7 +1487,8 @@ void CURLGetFile(void) e = m->easy_handle; easyres = m->data.result; - char *filename = Z_StrDup(curl_realname); + char *filename = malloc(strlen(curl_realname)+1); + strcpy(filename, curl_realname); nameonly(filename); if (easyres != CURLE_OK) @@ -1521,7 +1526,7 @@ void CURLGetFile(void) } } - Z_Free(filename); + free(filename); curl_curfile->file = NULL; filedownload.remaining--; mc = curl_multi_remove_handle(multi_handle, e); diff --git a/src/d_netfil.h b/src/d_netfil.h index 3c7502451..268cd80be 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -119,7 +119,6 @@ size_t nameonlylength(const char *s); #ifdef HAVE_CURL void CURLPrepareFile(const char* url, int dfilenum); void CURLAbortFile(void); -void CURLGetFile(void); HTTP_login * CURLGetLogin (const char *url, HTTP_login ***return_prev_next); size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream); #endif From b145d7fd0e351f89371f1071c544aa125cb49991 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 12 Jan 2026 10:44:30 +0100 Subject: [PATCH 079/589] WIP: show 3d models in player setup this is incredibly ugly and hacked together theres some weird culling issues and shit doesent really "scale" with different resolutions which needs to be fixed but it kinda works --- src/hardware/hw_gl.h | 3 + src/hardware/hw_md2.c | 111 +++++++++++++++++++++++++++++++ src/hardware/hw_md2.h | 3 + src/hardware/r_opengl/r_opengl.c | 52 +++++++++++++++ src/m_menu.c | 51 +++++++++++--- 5 files changed, 212 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_gl.h b/src/hardware/hw_gl.h index 7e167485e..de5ac6338 100644 --- a/src/hardware/hw_gl.h +++ b/src/hardware/hw_gl.h @@ -80,6 +80,9 @@ UINT32 GL_CreateLightTable(RGBA_t *hw_lighttable); void GL_ClearLightTables(void); void GL_SetScreenPalette(RGBA_t *palette); +void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, + FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index e45a56cda..2579a3cdb 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1475,4 +1475,115 @@ void HWR_DrawMD2(gl_vissprite_t *spr) } } +// mostly copy paste of HWR_DrawMD2 +// very ugly but our model code kinda sucks +void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t color, const UINT8 *colormap, fixed_t scale, INT32 frame, angle_t angle) +{ + patch_t *gpatch, *blendgpatch; + GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; + FTransform p; + FSurfaceInfo Surf; + + if (!md2->model) + { + char filename[64]; + CONS_Debug(DBG_RENDER, "Loading model... (%s)\n", md2->filename); + sprintf(filename, "mdls/%s", md2->filename); + md2->model = md2_readModel(filename); + + if (md2->model) + { + md2_printModelInfo(md2->model); + GL_CreateModelVBOs(md2->model); + } + else + { + md2->error = true; + return; + } + } + + if (md2->model->meshes[0].numFrames > 0) + frame = frame % md2->model->meshes[0].numFrames; + else + frame = 0; + + gpatch = static_cast(md2->glpatch); + if (gpatch) + hwrPatch = ((GLPatch_t *)gpatch->hardware); + + if (!gpatch || !hwrPatch || + ((!hwrPatch->mipmap->format || !hwrPatch->mipmap->downloaded) && !md2->notexturefile)) + md2_loadTexture(md2); + + gpatch = static_cast(md2->glpatch); + if (gpatch) + hwrPatch = ((GLPatch_t *)gpatch->hardware); + + blendgpatch = static_cast(md2->blendglpatch); + if (blendgpatch) + hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); + + if ((gpatch && hwrPatch && hwrPatch->mipmap->format) && + (!blendgpatch || !hwrBlendPatch || + ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile))) + md2_loadBlendTexture(md2); + + blendgpatch = static_cast(md2->blendglpatch); + if (blendgpatch) + hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); + + memset(&Surf, 0x00, sizeof(FSurfaceInfo)); + Surf.PolyColor.rgba = 0xFFFFFFFF; + Surf.PolyFlags = PF_Occlude | PF_Modulated; + + Surf.LightInfo.light_level = 255; + Surf.LightInfo.fade_start = 0; + Surf.LightInfo.fade_end = 31; + + if (color != SKINCOLOR_NONE && + blendgpatch && hwrBlendPatch->mipmap->format && + gpatch->width == blendgpatch->width && gpatch->height == blendgpatch->height) + { + INT32 tcskinnum = TC_DEFAULT; + + if (color) + tcskinnum = skinnum; + + HWR_GetBlendedTexture(gpatch, blendgpatch, tcskinnum, colormap, color); + } + else if (hwrPatch && hwrPatch->mipmap->format) + { + GL_SetTexture(hwrPatch->mipmap); + } + + memset(&p, 0x00, sizeof(FTransform)); + + p.x = x; + p.y = -400.0f; // idk man, but this makes the model not cull, kinda? + p.z = y; // for whatever reason y and z are switched here + + p.angley = FixedToFloat(AngleFixed(angle)); + p.anglex = 0.0f; + p.anglez = 0.0f; + + p.roll = false; + + p.fliptype = TRANSFORM_NONE; + + GL_Draw2DModel( + md2->model, + frame, + 0.0f, + 0.0f, + -1, + &p, + FixedToFloat(scale), + FixedToFloat(scale), + true, + false, + &Surf + ); +} + #endif //HWRENDER diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 62de1f35e..0f8bd5342 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -45,6 +45,9 @@ void HWR_InitMD2(void); void HWR_DrawMD2(gl_vissprite_t *spr); void HWR_AddPlayerMD2(INT32 skin, boolean local); void HWR_AddSpriteMD2(size_t spritenum); +void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, + skincolors_t color, const UINT8 *colormap, + fixed_t scale, INT32 frame, angle_t angle); #ifdef __cplusplus } // extern "C" diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index fab0a8a6d..c4c3fc47e 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -404,6 +404,14 @@ static PFNglEnableClientState pglEnableClientState; typedef void (APIENTRY * PFNglDisableClientState) (GLenum cap); static PFNglDisableClientState pglDisableClientState; +typedef void (APIENTRY * PFNglOrtho) (GLdouble left, + GLdouble right, + GLdouble bottom, + GLdouble top, + GLdouble nearVal, + GLdouble farVal); +static PFNglOrtho pglOrtho; + /* Lighting */ typedef void (APIENTRY * PFNglShadeModel) (GLenum mode); static PFNglShadeModel pglShadeModel; @@ -858,6 +866,8 @@ void SetupGLFunc4(void) GetGLfunc(glUniform3fv); GetGLfunc(glGetUniformLocation); + GetGLfunc(glOrtho); + #ifdef GLDEBUGMESSAGE GetGLfunc(glDebugMessageCallback); #endif @@ -3090,6 +3100,48 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics pglDisable(GL_NORMALIZE); } +void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, + FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface) +{ + // save our matrix´s + pglMatrixMode(GL_PROJECTION); + pglPushMatrix(); + pglMatrixMode(GL_MODELVIEW); + pglPushMatrix(); + + pglMatrixMode(GL_PROJECTION); + pglLoadIdentity(); + + // switch to ortho mode to make our lives easier + // thisll make sure our coords will be remapped to pixel coords + // try to scale it to the base width and height + // shit still be weird, and needs accounting for diff resolutions + pglOrtho(0.0f, (float)BASEVIDWIDTH, (float)BASEVIDHEIGHT, 0.0f, ZCLIP_PLANE, FAR_ZCLIP_DEFAULT); + + pglMatrixMode(GL_MODELVIEW); + pglLoadIdentity(); + + //pglDepthRange(0.0f, 1.0f); + pglClearDepth(1.0f); //Hurdler: all that are permanen states + pglDepthRange(ZCLIP_PLANE, FAR_ZCLIP_DEFAULT); // idk man im confused here tbh + pglDepthFunc(GL_LEQUAL); + pglClear(GL_DEPTH_BUFFER_BIT); + //GL_ClearBuffer(false, true, false, NULL); + + // FIXME: theres some weird culling issues i cant wrap my head around + // so until then gotta disable depth testing until i can figure this out + //pglDisable(GL_DEPTH_TEST); + GL_DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, + pos, hscale, vscale, flipped, hflipped, Surface); + //pglEnable(GL_DEPTH_TEST); + + // restore the matrix´s + pglMatrixMode(GL_PROJECTION); + pglPopMatrix(); + pglMatrixMode(GL_MODELVIEW); + pglPopMatrix(); +} + // -----------------+ // SetTransform : // -----------------+ diff --git a/src/m_menu.c b/src/m_menu.c index 55112356b..f94407284 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -12,6 +12,8 @@ /// \file m_menu.c /// \brief XMOD's extremely revamped menu system. +#include "screen.h" +#include "tables.h" #ifdef __GNUC__ #include #endif @@ -8523,7 +8525,7 @@ static void M_DrawSetupMultiPlayerMenu(void) const INT32 skinnum = R_SkinAvailable(skins[skintodisplay].name); - if (skinnum != -1) + if (skinnum > 0 || skinnum < MAXSKINS) sprdef = &skins[skinnum].spritedef; else sprdef = &skins[0].spritedef; @@ -8549,23 +8551,56 @@ static void M_DrawSetupMultiPlayerMenu(void) // draw box around guy V_DrawFill(mx + 36 - (charw/2), my+65, charw, 84, 239); +#undef charw // draw player sprite if (setupm_fakecolor) // inverse should never happen { UINT8 *colormap = R_GetTranslationColormap(skintodisplay, setupm_fakecolor, GTC_MENUCACHE); - if (skins[skintodisplay].flags & SF_HIRES) +#ifdef HWRENDER + md2_t *md2 = NULL; + + if (skinnum > 0 || skinnum < MAXSKINS) + md2 = &md2_playermodels[skinnum]; + else + md2 = &md2_playermodels[0]; + + // if we have 3d models enabled and a model exists + // try to show it instead of the sprite + if (rendermode == render_opengl && cv_glmdls.value + && !md2->error && !md2->notfound) { - V_DrawFixedPatch((mx+36)< Date: Mon, 12 Jan 2026 18:08:22 +0300 Subject: [PATCH 080/589] Make HWR_Draw2DModel not depend on resolution, make 3d skin select use skinselectspin cvar --- src/hardware/hw_md2.c | 6 +++--- src/hardware/r_opengl/r_opengl.c | 2 +- src/m_menu.c | 13 +++---------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 2579a3cdb..00d4b955f 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1559,7 +1559,7 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c memset(&p, 0x00, sizeof(FTransform)); - p.x = x; + p.x = x + (vid.width/vid.dup - BASEVIDWIDTH)/4; p.y = -400.0f; // idk man, but this makes the model not cull, kinda? p.z = y; // for whatever reason y and z are switched here @@ -1578,8 +1578,8 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c 0.0f, -1, &p, - FixedToFloat(scale), - FixedToFloat(scale), + FixedToFloat(scale) * (BASEVIDWIDTH / ((float)vid.width/vid.dup)), + FixedToFloat(scale) * (BASEVIDHEIGHT / ((float)vid.height/vid.dup)), true, false, &Surf diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index c4c3fc47e..773d19013 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3123,7 +3123,7 @@ void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics //pglDepthRange(0.0f, 1.0f); pglClearDepth(1.0f); //Hurdler: all that are permanen states - pglDepthRange(ZCLIP_PLANE, FAR_ZCLIP_DEFAULT); // idk man im confused here tbh + pglDepthRange(0.f, FAR_ZCLIP_DEFAULT); // idk man im confused here tbh pglDepthFunc(GL_LEQUAL); pglClear(GL_DEPTH_BUFFER_BIT); //GL_ClearBuffer(false, true, false, NULL); diff --git a/src/m_menu.c b/src/m_menu.c index f94407284..ea2cdc9c6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -8574,18 +8574,11 @@ static void M_DrawSetupMultiPlayerMenu(void) mx += 36; my += 131; - static angle_t angle = ANGLE_180; + const angle_t ROTATE_PER_TIC = (UINT64)ANGLE_45 * cv_skinselectspin.value / TICRATE; - // idk but those magic numbers work, gotta figure out smth proper - //x += vid.width/3; - //y += vid.height/2; - mx += BASEVIDWIDTH/8; - my -= BASEVIDHEIGHT/10; + angle_t angle = I_GetTime()*ROTATE_PER_TIC + FixedMul(cv_uncappedhud.value ? renderdeltatics : FRACUNIT, ROTATE_PER_TIC); - // just for testing - angle += FRACUNIT * 3; - - HWR_Draw2DModel(md2, mx, my, skinnum, (skincolors_t)setupm_fakecolor, colormap, 4*FRACUNIT/3, 0, angle); + HWR_Draw2DModel(md2, mx, my, skinnum, (skincolors_t)setupm_fakecolor, colormap, 8*FRACUNIT/3, frame, angle); } else #endif From e17a8a505cb3fde85bdd47572246bcac27a58ce7 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 12 Jan 2026 16:48:50 +0100 Subject: [PATCH 081/589] fix the culling issues i hope this is right....... --- src/hardware/hw_md2.c | 4 ++-- src/hardware/r_opengl/r_opengl.c | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 00d4b955f..3cf3f060c 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1559,8 +1559,8 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c memset(&p, 0x00, sizeof(FTransform)); - p.x = x + (vid.width/vid.dup - BASEVIDWIDTH)/4; - p.y = -400.0f; // idk man, but this makes the model not cull, kinda? + p.x = x + (vid.width/(float)vid.dup - BASEVIDWIDTH)/4; + p.y = -100.0f; // idk man, but this makes the model not cull, kinda? p.z = y; // for whatever reason y and z are switched here p.angley = FixedToFloat(AngleFixed(angle)); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 773d19013..223cb359f 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3116,23 +3116,22 @@ void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics // thisll make sure our coords will be remapped to pixel coords // try to scale it to the base width and height // shit still be weird, and needs accounting for diff resolutions - pglOrtho(0.0f, (float)BASEVIDWIDTH, (float)BASEVIDHEIGHT, 0.0f, ZCLIP_PLANE, FAR_ZCLIP_DEFAULT); + pglOrtho(0.0f, (float)BASEVIDWIDTH, (float)BASEVIDHEIGHT, 0.0f, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); pglMatrixMode(GL_MODELVIEW); pglLoadIdentity(); - //pglDepthRange(0.0f, 1.0f); - pglClearDepth(1.0f); //Hurdler: all that are permanen states - pglDepthRange(0.f, FAR_ZCLIP_DEFAULT); // idk man im confused here tbh - pglDepthFunc(GL_LEQUAL); + pglEnable(GL_DEPTH_TEST); + pglDepthMask(GL_TRUE); pglClear(GL_DEPTH_BUFFER_BIT); - //GL_ClearBuffer(false, true, false, NULL); // FIXME: theres some weird culling issues i cant wrap my head around // so until then gotta disable depth testing until i can figure this out //pglDisable(GL_DEPTH_TEST); GL_DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, hscale, vscale, flipped, hflipped, Surface); + + //pglDepthMask(GL_TRUE); //pglEnable(GL_DEPTH_TEST); // restore the matrix´s From c01818e2e393d4932dd7be2f3e52ba9b95b00f14 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 12 Jan 2026 17:22:04 +0100 Subject: [PATCH 082/589] simplify skinnum bounds check lul --- src/m_menu.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index ea2cdc9c6..f6145d205 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7948,6 +7948,7 @@ static void M_DrawSetupMultiPlayerMenu(void) UINT8 i; UINT8 s, w; const UINT8 *flashcol = V_GetStringColormap(highlightflags); + INT32 skinnum = 0; INT32 statx, staty; UINT32 speenframe; INT32 sltw, actw, hetw; @@ -8523,12 +8524,12 @@ static void M_DrawSetupMultiPlayerMenu(void) break; } - const INT32 skinnum = R_SkinAvailable(skins[skintodisplay].name); + skinnum = R_SkinAvailable(skins[skintodisplay].name); - if (skinnum > 0 || skinnum < MAXSKINS) - sprdef = &skins[skinnum].spritedef; - else - sprdef = &skins[0].spritedef; + if (skinnum < 0 || skinnum >= MAXSKINS) + skinnum = 0; + + sprdef = &skins[skinnum].spritedef; if (!sprdef->numframes) // No frames ?? return; // Can't render! @@ -8557,14 +8558,8 @@ static void M_DrawSetupMultiPlayerMenu(void) if (setupm_fakecolor) // inverse should never happen { UINT8 *colormap = R_GetTranslationColormap(skintodisplay, setupm_fakecolor, GTC_MENUCACHE); - #ifdef HWRENDER - md2_t *md2 = NULL; - - if (skinnum > 0 || skinnum < MAXSKINS) - md2 = &md2_playermodels[skinnum]; - else - md2 = &md2_playermodels[0]; + md2_t *md2 = &md2_playermodels[skinnum]; // if we have 3d models enabled and a model exists // try to show it instead of the sprite From 7a0fb016262f753acd745073b5cd136fb1bbf51d Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 12 Jan 2026 20:14:17 +0300 Subject: [PATCH 083/589] Make glOrtho remap coordinates to vid.width and vid.height, this makes calculating coordinates in HWR_Draw2DModel easier --- src/hardware/hw_md2.c | 10 +++++----- src/hardware/r_opengl/r_opengl.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 3cf3f060c..f971e1945 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1559,9 +1559,9 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c memset(&p, 0x00, sizeof(FTransform)); - p.x = x + (vid.width/(float)vid.dup - BASEVIDWIDTH)/4; - p.y = -100.0f; // idk man, but this makes the model not cull, kinda? - p.z = y; // for whatever reason y and z are switched here + p.x = x*vid.dup + (vid.width - BASEVIDWIDTH*vid.dup)/2; + p.y = -200.0f; // idk man, but this makes the model not cull, kinda? + p.z = y*vid.dup + (vid.height - BASEVIDHEIGHT*vid.dup)/2; // for whatever reason y and z are switched here p.angley = FixedToFloat(AngleFixed(angle)); p.anglex = 0.0f; @@ -1578,8 +1578,8 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c 0.0f, -1, &p, - FixedToFloat(scale) * (BASEVIDWIDTH / ((float)vid.width/vid.dup)), - FixedToFloat(scale) * (BASEVIDHEIGHT / ((float)vid.height/vid.dup)), + FixedToFloat(scale*vid.dup), + FixedToFloat(scale*vid.dup), true, false, &Surf diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 223cb359f..25d9c0431 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3116,7 +3116,7 @@ void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics // thisll make sure our coords will be remapped to pixel coords // try to scale it to the base width and height // shit still be weird, and needs accounting for diff resolutions - pglOrtho(0.0f, (float)BASEVIDWIDTH, (float)BASEVIDHEIGHT, 0.0f, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); + pglOrtho(0.0f, (float)vid.width, (float)vid.height, 0.0f, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); pglMatrixMode(GL_MODELVIEW); pglLoadIdentity(); From 0c091256f40faa6634fcc8bc9831309a3bd1f714 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 12 Jan 2026 18:26:32 +0100 Subject: [PATCH 084/589] tiny cleanup + warning fix --- src/hardware/hw_md2.c | 23 ++++++++++++----------- src/hardware/r_opengl/r_opengl.c | 8 -------- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index f971e1945..c00297ff8 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1559,28 +1559,29 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c memset(&p, 0x00, sizeof(FTransform)); - p.x = x*vid.dup + (vid.width - BASEVIDWIDTH*vid.dup)/2; - p.y = -200.0f; // idk man, but this makes the model not cull, kinda? - p.z = y*vid.dup + (vid.height - BASEVIDHEIGHT*vid.dup)/2; // for whatever reason y and z are switched here + p.x = x*vid.dup + (float)(vid.width - BASEVIDWIDTH*vid.dup)/2.f; + p.y = -200.f; // push it back to prevent wonky culling, idk lul + p.z = y*vid.dup + (float)(vid.height - BASEVIDHEIGHT*vid.dup)/2.f; p.angley = FixedToFloat(AngleFixed(angle)); - p.anglex = 0.0f; - p.anglez = 0.0f; + p.anglex = 0.f; + p.anglez = 0.f; p.roll = false; - p.fliptype = TRANSFORM_NONE; + const float fscale = FixedToFloat(scale*vid.dup); + GL_Draw2DModel( md2->model, frame, - 0.0f, - 0.0f, + 0.f, + 0.f, -1, &p, - FixedToFloat(scale*vid.dup), - FixedToFloat(scale*vid.dup), - true, + fscale, + fscale, + true, // flip it vertically lul false, &Surf ); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 25d9c0431..2d1f8e255 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3114,8 +3114,6 @@ void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics // switch to ortho mode to make our lives easier // thisll make sure our coords will be remapped to pixel coords - // try to scale it to the base width and height - // shit still be weird, and needs accounting for diff resolutions pglOrtho(0.0f, (float)vid.width, (float)vid.height, 0.0f, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); pglMatrixMode(GL_MODELVIEW); @@ -3125,15 +3123,9 @@ void GL_Draw2DModel(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics pglDepthMask(GL_TRUE); pglClear(GL_DEPTH_BUFFER_BIT); - // FIXME: theres some weird culling issues i cant wrap my head around - // so until then gotta disable depth testing until i can figure this out - //pglDisable(GL_DEPTH_TEST); GL_DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, hscale, vscale, flipped, hflipped, Surface); - //pglDepthMask(GL_TRUE); - //pglEnable(GL_DEPTH_TEST); - // restore the matrix´s pglMatrixMode(GL_PROJECTION); pglPopMatrix(); From faadd3e89fef20276833856c05479a5adc5ba657 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 12 Jan 2026 18:39:52 +0100 Subject: [PATCH 085/589] support the uhhh localskin setup with 3d models --- src/m_menu.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index f6145d205..3f0dca46d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9920,12 +9920,12 @@ static void M_DrawLocalSkinMenu(void) // skin 0 is default player sprite skintodisplay = R_AnySkinAvailable(cv_fakelocalskin.string); - if (skintodisplay == -1) + if (skintodisplay < 0) { // ATTEMPT TO FIND REAL SKIN skintodisplay = R_AnySkinAvailable(cv_skin.string); - if (skintodisplay == -1) // STILL NOTHIN? use sonic instead + if (skintodisplay < 0) // STILL NOTHIN? use sonic instead { skintodisplay = 0; } @@ -9958,6 +9958,7 @@ static void M_DrawLocalSkinMenu(void) // draw box around guy V_DrawFill(mx + 220 - (charw/2), my+54, charw, 84, 239); +#undef charw // draw player sprite UINT8 *colormap = R_GetLocalTranslationColormap(&skins[displayskin.localnum], (displayskin.localskin ? &localskins[displayskin.localnum] : NULL), cv_playercolor.value, GTC_MENUCACHE, displayskin.localskin); @@ -9972,13 +9973,34 @@ static void M_DrawLocalSkinMenu(void) else V_DrawString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, displayskin.realname); - if (displayskin.flags & SF_HIRES) + // draw player sprite +#ifdef HWRENDER + md2_t *md2 = (displayskin.localskin ? &md2_localplayermodels[skintodisplay] : &md2_playermodels[skintodisplay]); + + // if we have 3d models enabled and a model exists + // try to show it instead of the sprite + if (rendermode == render_opengl && cv_glmdls.value + && !md2->error && !md2->notfound) { - V_DrawFixedPatch((mx+220)< Date: Mon, 12 Jan 2026 19:13:08 +0100 Subject: [PATCH 086/589] push back models even further bigger models still had parts being culled, hope this is generous enough idk --- src/hardware/hw_md2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index c00297ff8..0fdd62623 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1560,7 +1560,7 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c memset(&p, 0x00, sizeof(FTransform)); p.x = x*vid.dup + (float)(vid.width - BASEVIDWIDTH*vid.dup)/2.f; - p.y = -200.f; // push it back to prevent wonky culling, idk lul + p.y = -420.f; // push it back to prevent wonky culling, idk lul p.z = y*vid.dup + (float)(vid.height - BASEVIDHEIGHT*vid.dup)/2.f; p.angley = FixedToFloat(AngleFixed(angle)); From 6fd64383d3f9c413ea96ff7c4c80243089e2bfd5 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 12 Jan 2026 22:33:30 +0300 Subject: [PATCH 087/589] This isn't ceepeepee rn :SmolBuncle: --- src/hardware/hw_md2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 0fdd62623..0a79ba6ec 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1508,7 +1508,7 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c else frame = 0; - gpatch = static_cast(md2->glpatch); + gpatch = (patch_t *)(md2->glpatch); if (gpatch) hwrPatch = ((GLPatch_t *)gpatch->hardware); @@ -1516,11 +1516,11 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c ((!hwrPatch->mipmap->format || !hwrPatch->mipmap->downloaded) && !md2->notexturefile)) md2_loadTexture(md2); - gpatch = static_cast(md2->glpatch); + gpatch = (patch_t*)(md2->glpatch); if (gpatch) hwrPatch = ((GLPatch_t *)gpatch->hardware); - blendgpatch = static_cast(md2->blendglpatch); + blendgpatch = (patch_t*)(md2->blendglpatch); if (blendgpatch) hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); @@ -1529,7 +1529,7 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c ((!hwrBlendPatch->mipmap->format || !hwrBlendPatch->mipmap->downloaded) && !md2->noblendfile))) md2_loadBlendTexture(md2); - blendgpatch = static_cast(md2->blendglpatch); + blendgpatch = (patch_t*)(md2->blendglpatch); if (blendgpatch) hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); From 1b8d7b1541ccab0d796043e4596812b4ee79f4f6 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 16 Jan 2026 11:11:36 +0300 Subject: [PATCH 088/589] I_Error when dedi tries to go to main error This will not fix the issue entirely but will at least prevent server getting stuck and backtrace will show where did it try to go into menu from --- src/d_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index 3e474cec3..81fd3d830 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -946,6 +946,9 @@ void D_ClearState(void) // void D_StartTitle(void) { + if (dedicated) + I_Error("D_StartTitle is called on dedicated server"); + D_ClearState(); multiplayer = netgame = false; // title menu shouldnt be a netgame or multiplayer lmao F_StartTitleScreen(); From ac3a1ad5eb841c78c0500b933bf2341b62864323 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 16 Jan 2026 12:02:21 +0300 Subject: [PATCH 089/589] Add gcc 13.3 into list of supported versions --- src/Makefile.d/detect.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk index 7ff978397..0816c5a03 100644 --- a/src/Makefile.d/detect.mk +++ b/src/Makefile.d/detect.mk @@ -66,7 +66,7 @@ endif gcc_versions:=\ 152 151 150 15\ 142 141 140 14\ - 132 131 130 13\ + 133 132 131 130 13\ 123 122 121 120 12\ 114 113 112 111 110 11\ 105 104 103 102 101 100 10\ From 29f187b751c3dbab1217704ce9efba9c0f4986c4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 16 Jan 2026 12:53:27 +0100 Subject: [PATCH 090/589] fix some windoze specific "-Wzero-as-null-pointer-constant" warnings --- src/win32/win_dbg.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/win32/win_dbg.c b/src/win32/win_dbg.c index a5d1adc3f..d47117698 100644 --- a/src/win32/win_dbg.c +++ b/src/win32/win_dbg.c @@ -187,13 +187,13 @@ static VOID ShowModuleInfo(HANDLE LogFile, HMODULE ModuleHandle) // Open the code module file so that we can get its file date // and size. ModuleFile = CreateFileA(ModName, GENERIC_READ, - FILE_SHARE_READ, 0, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, 0); + FILE_SHARE_READ, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); if (ModuleFile != INVALID_HANDLE_VALUE) { FILETIME LastWriteTime; - FileSize = GetFileSize(ModuleFile, 0); - if (GetFileTime(ModuleFile, 0, 0, &LastWriteTime)) + FileSize = GetFileSize(ModuleFile, NULL); + if (GetFileTime(ModuleFile, NULL, NULL, &LastWriteTime)) { wsprintfA(TimeBuffer, " - file date is "); PrintTime(TimeBuffer + strlen(TimeBuffer), LastWriteTime); @@ -227,7 +227,7 @@ static VOID RecordModuleList(HANDLE LogFile) size_t PageSize; size_t NumPages; size_t pageNum = 0; - LPVOID LastAllocationBase = 0; + LPVOID LastAllocationBase = NULL; FPrintf(LogFile, "\r\n" "\tModule list: names, addresses, sizes, time stamps " @@ -385,7 +385,7 @@ LONG WINAPI RecordExceptionInfo(PEXCEPTION_POINTERS data/*, LPCSTR Message, LPST } // Append to the error log. - SetFilePointer(fileHandle, 0, 0, FILE_END); + SetFilePointer(fileHandle, 0, NULL, FILE_END); // Print out some blank lines to separate this error log from any previous ones. FPrintf(fileHandle, "Email Sonic Team Junior so we can fix the bugs\r\n"); // Tails From 08e7ce3b5ba27f2fe113d5c4c0268485664a0d9a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 16 Jan 2026 13:25:38 +0100 Subject: [PATCH 091/589] m_menu: clean up the skin display stuff a little --- src/m_menu.c | 114 +++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 3f0dca46d..a98a230d5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7902,7 +7902,7 @@ static void M_HandleConnectIP(INT32 choice) if (exitmenu) { if (currentMenu->prevMenu) - M_SetupNextMenu (currentMenu->prevMenu); + M_SetupNextMenu(currentMenu->prevMenu); else M_ClearMenus(true); } @@ -8271,10 +8271,9 @@ static void M_DrawSetupMultiPlayerMenu(void) INT32 curx = (((setupm_skinselect % SKINGRIDNEWWIDTH) * 18) + ((BASEVIDWIDTH / 2) - (18 * SKINGRIDNEWWIDTH/2)) + SKINXSHIFT) + 20; INT32 cury = (((setupm_skinselect / SKINGRIDNEWWIDTH) - setupm_skinypos) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2))+ gridyoffset); - UINT8 cursorframe = (I_GetTime() / 4) % 7; - - cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); - V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); + UINT8 cursorframe = (I_GetTime() / 4) % 7; + cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); + V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); } break; @@ -8313,14 +8312,12 @@ static void M_DrawSetupMultiPlayerMenu(void) if (setupm_skinselect < numskins) { UINT8 *cmap = R_GetTranslationColormap(setupm_skinselect, setupm_fakecolor, GTC_MENUCACHE); - cursor = facewantprefix[skinsorted[setupm_skinselect]]; V_DrawFixedPatch(((curx-8) << FRACBITS), ((cury-8) << FRACBITS), FRACUNIT, 0, cursor, cmap); } else { UINT8 cursorframe = (I_GetTime() / 4) % 7; - cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); } @@ -8384,7 +8381,6 @@ static void M_DrawSetupMultiPlayerMenu(void) else { UINT8 cursorframe = (I_GetTime() / 4) % 7; - cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL); } @@ -8509,7 +8505,7 @@ static void M_DrawSetupMultiPlayerMenu(void) switch (cv_skinselectmenu.value) { case SKINMENUTYPE_2D: - skintodisplay = setupm_fakeskin; + skintodisplay = (UINT8)setupm_fakeskin; if (setupm_skinlockedselect) // show the skin we are trying to select skintodisplay = skinstats[setupm_skinxpos][setupm_skinypos][setupm_skinselect]; else if (skinstatscount[setupm_skinxpos][setupm_skinypos] && itemOn == 1) @@ -8517,13 +8513,16 @@ static void M_DrawSetupMultiPlayerMenu(void) break; case SKINMENUTYPE_EXTENDED: case SKINMENUTYPE_GRID: - skintodisplay = (itemOn == 1 && setupm_skinselect < numskins ? skinsorted[setupm_skinselect] : setupm_fakeskin); + skintodisplay = ((itemOn == 1 && (setupm_skinselect < numskins)) ? skinsorted[setupm_skinselect] : (UINT8)setupm_fakeskin); break; default: - skintodisplay = setupm_fakeskin; + skintodisplay = (UINT8)setupm_fakeskin; break; } + if (skintodisplay >= MAXSKINS) + skintodisplay = 0; + skinnum = R_SkinAvailable(skins[skintodisplay].name); if (skinnum < 0 || skinnum >= MAXSKINS) @@ -8538,18 +8537,6 @@ static void M_DrawSetupMultiPlayerMenu(void) if (frame >= sprdef->numframes) // Walking animation missing frame = 0; // Try to use standing frame - sprframe = &sprdef->spriteframes[frame]; - - // minenice's speen css, it's a piece of shit but hey - speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; - - // this is a very shitty solution for checking if a sprite needs flipping - // but it works - if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe])) - flags = V_FLIP; // This sprite is left/right flipped! - - patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); - // draw box around guy V_DrawFill(mx + 36 - (charw/2), my+65, charw, 84, 239); #undef charw @@ -8560,33 +8547,47 @@ static void M_DrawSetupMultiPlayerMenu(void) UINT8 *colormap = R_GetTranslationColormap(skintodisplay, setupm_fakecolor, GTC_MENUCACHE); #ifdef HWRENDER md2_t *md2 = &md2_playermodels[skinnum]; - +#endif + mx += 36; + my += 131; +#ifdef HWRENDER // if we have 3d models enabled and a model exists // try to show it instead of the sprite if (rendermode == render_opengl && cv_glmdls.value && !md2->error && !md2->notfound) { - mx += 36; - my += 131; - const angle_t ROTATE_PER_TIC = (UINT64)ANGLE_45 * cv_skinselectspin.value / TICRATE; - angle_t angle = I_GetTime()*ROTATE_PER_TIC + FixedMul(cv_uncappedhud.value ? renderdeltatics : FRACUNIT, ROTATE_PER_TIC); - HWR_Draw2DModel(md2, mx, my, skinnum, (skincolors_t)setupm_fakecolor, colormap, 8*FRACUNIT/3, frame, angle); } else #endif { + sprframe = &sprdef->spriteframes[frame]; + + // minenice's speen css, it's a piece of shit but hey + speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; + + // this is a very shitty solution for checking if a sprite needs flipping + // but it works + if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe])) + { + flags = V_FLIP; // This sprite is left/right flipped! + } + + patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); + if (skins[skintodisplay].flags & SF_HIRES) { - V_DrawFixedPatch((mx+36)<= sprdef->numframes) // Walking animation missing frame = 0; // Try to use standing frame - sprframe = &sprdef->spriteframes[frame]; - - //minenice's speen css, it's a piece of shit but hey - //patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[1], PU_PATCH); - speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; - - //this is a very shitty solution for checking if a sprite needs flipping - //but it works - if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe])) - { - flags = V_FLIP; // This sprite is left/right flipped! - } - patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); - // draw box around guy V_DrawFill(mx + 220 - (charw/2), my+54, charw, 84, 239); #undef charw - // draw player sprite UINT8 *colormap = R_GetLocalTranslationColormap(&skins[displayskin.localnum], (displayskin.localskin ? &localskins[displayskin.localnum] : NULL), cv_playercolor.value, GTC_MENUCACHE, displayskin.localskin); V_DrawMappedPatch(mx, my+50, 0, (patch_t *)W_CachePatchName(displayskin.facewant, PU_PATCH), colormap); @@ -9974,6 +9960,9 @@ static void M_DrawLocalSkinMenu(void) V_DrawString(mx+20, my+118, V_ALLOWLOWERCASE|highlightflags, displayskin.realname); // draw player sprite + mx += 220; + my += 120; + #ifdef HWRENDER md2_t *md2 = (displayskin.localskin ? &md2_localplayermodels[skintodisplay] : &md2_playermodels[skintodisplay]); @@ -9982,24 +9971,35 @@ static void M_DrawLocalSkinMenu(void) if (rendermode == render_opengl && cv_glmdls.value && !md2->error && !md2->notfound) { - mx += 220; - my += 120; - const angle_t ROTATE_PER_TIC = (UINT64)ANGLE_45 * cv_skinselectspin.value / TICRATE; - angle_t angle = I_GetTime()*ROTATE_PER_TIC + FixedMul(cv_uncappedhud.value ? renderdeltatics : FRACUNIT, ROTATE_PER_TIC); - HWR_Draw2DModel(md2, mx, my, skintodisplay, (skincolors_t)cv_playercolor.value, colormap, 8*FRACUNIT/3, frame, angle); } else #endif { + sprframe = &sprdef->spriteframes[frame]; + + // minenice's speen css, it's a piece of shit but hey + speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8; + + // this is a very shitty solution for checking if a sprite needs flipping + // but it works + if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe])) + { + flags = V_FLIP; // This sprite is left/right flipped! + } + + patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH); + if (displayskin.flags & SF_HIRES) { - V_DrawFixedPatch((mx+220)< Date: Sun, 18 Jan 2026 07:39:45 +0100 Subject: [PATCH 092/589] remove unused stuff from joyinfo --- src/g_input.c | 8 +++----- src/sdl/i_system.cpp | 41 ++++++++++++----------------------------- src/sdl/i_video.c | 2 +- src/sdl/sdlmain.h | 8 ++++---- 4 files changed, 20 insertions(+), 39 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 0082df273..1a420c996 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -945,6 +945,8 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color) static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum) { + I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); + if (cv_gamepadled[playernum].value == 0) { I_SetGamepadIndicatorColor(playernum, 0, 0, 255); @@ -973,13 +975,8 @@ void G_DeviceLEDTick(void) newcolor = G_GetSkinColorForGamepad(i); - // compiler be absolutely tripping - // delet this if this gets fixed within gcc -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Warray-bounds" if (curcolor[i] == newcolor) // dont update if same colour continue; -#pragma GCC diagnostic pop G_SetPlayerGamepadIndicatorColor(i, newcolor); curcolor[i] = newcolor; @@ -994,6 +991,7 @@ void G_ResetDeviceLED(void) static void G_ResetPlayerDeviceRumble(INT32 playernum) { + I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); I_GamepadRumble(playernum, 0, 0, 0); } diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 36859ef54..15ba76917 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -727,12 +727,11 @@ static void JoyReset(SDLJoyInfo_t *JoySet) JoySet->dev = NULL; JoySet->oldjoy = -1; JoySet->id = -1; - JoySet->axises = JoySet->buttons = JoySet->hats = JoySet->balls = 0; } /** \brief SDL info about joystick */ -SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS]; +SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS] = {}; INT32 numcontrollers = 0; // @@ -740,26 +739,26 @@ INT32 numcontrollers = 0; // void I_JoyScale(void) { - Joystick[0].bGamepadStyle = cv_joyscale[0].value==0; - JoyInfo[0].scale = Joystick[0].bGamepadStyle?1:cv_joyscale[0].value; + Joystick[0].bGamepadStyle = cv_joyscale[0].value == 0; + JoyInfo[0].scale = Joystick[0].bGamepadStyle ? 1 : cv_joyscale[0].value; } void I_JoyScale2(void) { - Joystick[1].bGamepadStyle = cv_joyscale[1].value==0; - JoyInfo[1].scale = Joystick[1].bGamepadStyle?1:cv_joyscale[1].value; + Joystick[1].bGamepadStyle = cv_joyscale[1].value == 0; + JoyInfo[1].scale = Joystick[1].bGamepadStyle ? 1 : cv_joyscale[1].value; } void I_JoyScale3(void) { - Joystick[2].bGamepadStyle = cv_joyscale[2].value==0; - JoyInfo[2].scale = Joystick[2].bGamepadStyle?1:cv_joyscale[2].value; + Joystick[2].bGamepadStyle = cv_joyscale[2].value == 0; + JoyInfo[2].scale = Joystick[2].bGamepadStyle ? 1 : cv_joyscale[2].value; } void I_JoyScale4(void) { - Joystick[3].bGamepadStyle = cv_joyscale[3].value==0; - JoyInfo[3].scale = Joystick[3].bGamepadStyle?1:cv_joyscale[3].value; + Joystick[3].bGamepadStyle = cv_joyscale[3].value == 0; + JoyInfo[3].scale = Joystick[3].bGamepadStyle ? 1 : cv_joyscale[3].value; } // Cheat to get the device index for a joystick handle @@ -931,33 +930,18 @@ static int joy_open(int playerIndex, int joyIndex) } JoyInfo[playerIndex].dev = newdev; - JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev); if (JoyInfo[playerIndex].dev == NULL) { CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: Couldn't open device - %s\n"), SDL_GetError()); return -1; } - else - { - CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev)); - JoyInfo[playerIndex].axises = SDL_CONTROLLER_AXIS_MAX; - if (JoyInfo[playerIndex].axises > JOYAXISSET*2) - JoyInfo[playerIndex].axises = JOYAXISSET*2; + CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev)); - JoyInfo[playerIndex].buttons = SDL_CONTROLLER_BUTTON_MAX ; // dpad is 4 buttons - if (JoyInfo[playerIndex].buttons > JOYBUTTONS) - JoyInfo[playerIndex].buttons = JOYBUTTONS; + JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev); - JoyInfo[playerIndex].hats = 4; - if (JoyInfo[playerIndex].hats > JOYHATS) - JoyInfo[playerIndex].hats = JOYHATS; - - JoyInfo[playerIndex].balls = 0; - - return JoyInfo[playerIndex].axises; - } + return SDL_CONTROLLER_AXIS_MAX; } // @@ -1002,7 +986,6 @@ void I_InitJoystick(UINT8 index) JoyInfo[index].dev = NULL; JoyInfo[index].oldjoy = -1; JoyInfo[index].id = -1; - JoyInfo[index].axises = JoyInfo[index].buttons = JoyInfo[index].hats = JoyInfo[index].balls = 0; if (cv_usejoystick[index].value) newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 72354ca1e..1c23af6cd 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -467,7 +467,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) } else { - raxis = JoyInfo[pid].scale!=1?((raxis/JoyInfo[pid].scale)*JoyInfo[pid].scale):raxis; + raxis = JoyInfo[pid].scale != 1 ? ((raxis/JoyInfo[pid].scale)*JoyInfo[pid].scale) : raxis; #ifdef SDL_JDEADZONE if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE) diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index e5bdca395..f7f4c011c 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -44,15 +44,15 @@ typedef struct SDLJoyInfo_s /// number of old joystick int oldjoy; /// number of axies - int axises; + //int axises; /// scale of axises INT32 scale; /// number of buttons - int buttons; + //int buttons; /// number of hats - int hats; + //int hats; /// number of balls - int balls; + //int balls; } SDLJoyInfo_t; /** \brief SDL info about controller 1 From 104b8260fb715102cd0b7f03761b09ffa7c07906 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 19 Jan 2026 14:35:02 +0100 Subject: [PATCH 093/589] add reducevfx to accesability menu If there are things that should be handled by that toggle def feel free to suggest them! --- src/m_menudefs.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index e6129d2d8..0c4aef0d4 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1633,33 +1633,34 @@ static menuitem_t OP_AccessibilityMenu[] = {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "Saturation", &cv_globalsaturation, 25}, {IT_SUBMENU|IT_STRING, NULL, "Video Color Settings...", &OP_ColorOptionsDef, 30}, - {IT_STRING|IT_CVAR, NULL, "Midnight Channel Flicker", &cv_lessflicker, 35}, + {IT_STRING|IT_CVAR, NULL, "Reduce Effects", &cv_reducevfx, 35}, + {IT_STRING|IT_CVAR, NULL, "Midnight Channel Flicker", &cv_lessflicker, 40}, // obsolete now? or still better be a seperate toggle? - {IT_STRING|IT_CVAR, NULL, "Minimum Sector Brightness", &cv_secbright, 40}, + {IT_STRING|IT_CVAR, NULL, "Minimum Sector Brightness", &cv_secbright, 45}, #ifdef HWRENDER - {IT_STRING|IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 45}, + {IT_STRING|IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 50}, #endif - {IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 50}, + {IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 55}, - {IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 55}, + {IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 60}, - {IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 60}, + {IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 65}, - {IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 65}, + {IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 70}, - {IT_HEADER, NULL, "Audio", NULL, 75}, + {IT_HEADER, NULL, "Audio", NULL, 80}, - {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 85}, - {IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 90}, + {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 90}, + {IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 95}, - {IT_HEADER, NULL, "Controls", NULL, 100}, + {IT_HEADER, NULL, "Controls", NULL, 105}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 110}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 115}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 120}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 125}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 115}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 120}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 125}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 130}, }; static const char* OP_AccessibilityTooltips[] = @@ -1669,10 +1670,11 @@ static const char* OP_AccessibilityTooltips[] = "Gamma (brightness) of the game.", "Saturation of the game.", "Advanced color settings of the game.", + "Reduces or disables certain effects players might be sensitive to\nSuch as flashing, flickering, certain screen effects and more.", "Disables the flicker effect on Midnight Channel.", "Sets minimum sector brightness, useful for dark areas", #ifdef HWRENDER - "Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.", + "Disabling Screen Textures will disable the Underwater and Heat screen effects.", #endif "Toggles the ripple effect on water surfaces", "Fades other Players that are close to the camera in and out", From aa96f9ceb3f8a7d35218fd814485dab03c363baf Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Jan 2026 14:57:18 +0100 Subject: [PATCH 094/589] V_DrawVhsEffect: fix scaling with highreshudscale, fix downwards bar going out of screen bounds this shouldnt account for highreshudscale at all on very high resolutions the bars are still only half size, but atleast they dont become minuscule or just dont draw at all also ensures both bars are clamped, on some resolutions sometimes they just go out of visible screen range --- src/v_video.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index dbb3b385b..b5be19a97 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1742,6 +1742,7 @@ void V_DrawHorizontallyScaledFullScreenPatch(patch_t *patch) void V_DrawVhsEffect(boolean rewind) { fixed_t uby, dby; + // upbary is the bar going from top to bottom for some reason static fixed_t upbary = 100*FRACUNIT, downbary = 150*FRACUNIT; UINT8 barsize, updistort, downdistort; @@ -1759,20 +1760,26 @@ void V_DrawVhsEffect(boolean rewind) if (cv_reducevfx.value) return; - barsize = vid.dup << 5; - updistort = vid.dup << (rewind ? 5 : 3); + const INT32 dup = min(vid.width / BASEVIDWIDTH, vid.height / BASEVIDHEIGHT); + + barsize = dup << 5; + updistort = dup << (rewind ? 5 : 3); downdistort = updistort >> 1; if (rewind) V_DrawVhsEffect(false); // experimentation - upbary -= renderdeltatics * (vid.dup * (rewind ? 3 : 1.8f)); - downbary += renderdeltatics * (vid.dup * (rewind ? 2 : 1)); + upbary -= renderdeltatics * (fixed_t)(dup * (rewind ? 3 : 1.8f)); + downbary += renderdeltatics * (dup * (rewind ? 2 : 1)); if (upbary < -barsize*FRACUNIT) upbary = vid.height << FRACBITS; + if (upbary > vid.height << FRACBITS) + upbary = -barsize*FRACUNIT; if (downbary > vid.height << FRACBITS) downbary = -barsize*FRACUNIT; + if (downbary < -barsize*FRACUNIT) + downbary = vid.height << FRACBITS; uby = upbary >> FRACBITS; dby = downbary >> FRACBITS; From 43d3ac102d1273f7874b43b0a5e4477bd85165c2 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Jan 2026 15:42:37 +0100 Subject: [PATCH 095/589] HWR_RenderPlane: cleanup code that does nothing --- src/hardware/hw_main.cpp | 45 +++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 1622a4528..24d3af8ae 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -101,7 +101,8 @@ sector_t *gl_backsector = NULL; static constexpr float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; // values for bsp culling // slightly higher than the far clipping plane to compensate for impreciseness -static constexpr INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT, +static constexpr INT32 bsp_culling_distances[] = { + (1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT, (6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT}; // Performance stats @@ -587,15 +588,11 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool const sector_t *sec = FOFsector ? FOFsector : gl_frontsector; // Get the slope pointer to simplify future code - if (sec->f_slope && !isceiling) + if (!isceiling && sec->f_slope) slope = sec->f_slope; - else if (sec->c_slope && isceiling) + else if (isceiling && sec->c_slope) slope = sec->c_slope; - // Set fixedheight to the slope's height from our viewpoint, if we have a slope - if (slope) - fixedheight = P_GetSlopeZAt(slope, viewx, viewy); - height = FixedToFloat(fixedheight); // Allocate plane-vertex buffer if we need to @@ -687,18 +684,19 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool vert->s = (tempxsow * cosangf) - (tempytow * sinangf);\ vert->t = (tempxsow * sinangf) + (tempytow * cosangf);\ }\ +\ + if (slope)\ + {\ + fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\ + height = FixedToFloat(fixedheight);\ + }\ \ vert->x = (vx);\ vert->y = height;\ vert->z = (vy);\ \ - if (slope)\ - {\ - fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\ - vert->y = FixedToFloat(fixedheight);\ - }\ } - for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++) + for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++, pv++) SETUP3DVERT(v3d, pv->x, pv->y); if (slope) @@ -1785,10 +1783,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // Single sided line... Deal only with the middletexture (if one exists) if (gl_midtexture && gl_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL { - glTex = HWR_GetTexture(gl_midtexture, noencore); - fixed_t texturevpeg; + glTex = HWR_GetTexture(gl_midtexture, noencore); + // PEGGING if ((gl_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) texturevpeg = gl_frontsector->floorheight + textureheight[gl_sidedef->midtexture] - gl_frontsector->ceilingheight + gl_sidedef->rowoffset; @@ -1875,8 +1873,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom //Hurdler: 3d-floors test if (!gl_drawing_stencil && gl_backsector && gl_frontsector->tag != gl_backsector->tag && (gl_backsector->ffloors || gl_frontsector->ffloors)) { - ffloor_t * rover; - fixed_t highcut = 0, lowcut = 0; + ffloor_t *rover; + fixed_t highcut = 0, lowcut = 0; fixed_t lowcutslope = 0, highcutslope = 0; // Used for height comparisons and etc across FOFs and slopes @@ -2947,7 +2945,7 @@ static void HWR_Subsector(size_t num) static sector_t tempsec; //SoM: 4/7/2000 INT32 floorlightlevel; INT32 ceilinglightlevel; - INT32 locFloorHeight, locCeilingHeight; + INT32 locFloorHeight = 0, locCeilingHeight = 0; INT32 cullFloorHeight, cullCeilingHeight; INT32 light = 0; extracolormap_t *floorcolormap; @@ -2993,11 +2991,12 @@ static void HWR_Subsector(size_t num) cullFloorHeight = P_GetSectorFloorZAt (gl_frontsector, viewx, viewy); cullCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, viewx, viewy); - locFloorHeight = P_GetSectorFloorZAt (gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); - locCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); if (gl_frontsector->ffloors) { + locFloorHeight = P_GetSectorFloorZAt (gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); + locCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); + boolean anyMoved = gl_frontsector->moved; if (anyMoved == false) @@ -3052,8 +3051,7 @@ static void HWR_Subsector(size_t num) { HWR_GetFlat(levelflats[gl_frontsector->floorpic].lumpnum, R_NoEncore(gl_frontsector, false)); HWR_RenderPlane(sub, &extrasubsectors[num], false, - // Hack to make things continue to work around slopes. - locFloorHeight == cullFloorHeight ? locFloorHeight : gl_frontsector->floorheight, + gl_frontsector->floorheight, // We now return you to your regularly scheduled rendering. PF_Occlude, floorlightlevel, levelflats[gl_frontsector->floorpic].lumpnum, NULL, 255, floorcolormap); } @@ -3068,8 +3066,7 @@ static void HWR_Subsector(size_t num) { HWR_GetFlat(levelflats[gl_frontsector->ceilingpic].lumpnum, R_NoEncore(gl_frontsector, true)); HWR_RenderPlane(sub, &extrasubsectors[num], true, - // Hack to make things continue to work around slopes. - locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gl_frontsector->ceilingheight, + gl_frontsector->ceilingheight, // We now return you to your regularly scheduled rendering. PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum, NULL, 255, ceilingcolormap); } From 073b35690b52a9673bf62236cfdea66877358fc1 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Jan 2026 16:25:07 +0100 Subject: [PATCH 096/589] dont attempt to show sdl message box on non dedicated builds running as dedicated --- src/sdl/i_system.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 15ba76917..b868d34c0 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1776,9 +1776,10 @@ FUNCNORETURN static ATTRNORETURN void newsignalhandler_Warn(const char *pr) I_OutputMsg("%s\n", text); - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Startup error", - text, NULL); + if (!M_CheckParm("-dedicated")) + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, + "Startup error", + text, NULL); I_ShutdownConsole(); exit(-1); @@ -1979,9 +1980,10 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) // Implement message box with SDL_ShowSimpleMessageBox, // which should fail gracefully if it can't put a message box up // on the target system - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "SRB2Kart " VERSIONSTRING " Recursive Error", - buffer, NULL); + if (!M_CheckParm("-dedicated")) + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, + "SRB2Kart " VERSIONSTRING " Recursive Error", + buffer, NULL); W_Shutdown(); exit(-1); // recursive errors detected @@ -2024,7 +2026,8 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) // Implement message box with SDL_ShowSimpleMessageBox, // which should fail gracefully if it can't put a message box up // on the target system - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SRB2Kart " VERSIONSTRING " Error", buffer, NULL); + if (!M_CheckParm("-dedicated")) + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SRB2Kart " VERSIONSTRING " Error", buffer, NULL); // Note that SDL_ShowSimpleMessageBox does *not* require SDL to be // initialized at the time, so calling it after SDL_Quit() is // perfectly okay! In addition, we do this on purpose so the From 5289f138918a1f2b279dd06cdb1ebd1d2dc3a151 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Jan 2026 17:31:58 +0100 Subject: [PATCH 097/589] Show report issue button also on I_Error also make wrapper functions for everything, to reduce code dupe --- src/sdl/i_system.cpp | 84 ++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 38 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index b868d34c0..eeeb2373c 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1629,24 +1629,13 @@ static int I_OpenURL(const char *url) #endif } -static void I_ReportSignal(int num, int coredumped) +static void I_ShowErrorBox(const char *title, const char *msg) { - char sigmsg[512]; - char signame[128]; - char sigttl[512] = "Process killed by signal: "; - const char *reportmsg = "\n\n\nTo help us figure out the cause, please report the issue to our github page with " CRASH_LOGFILE_NAME " attached.\n\nSorry for the inconvenience!"; - - I_PrintSignal(num, coredumped, sigmsg, signame); - - size_t len = strlen(sigmsg); - snprintf(sigmsg + len, sizeof(sigmsg) - len, "\n\nCrash report has been saved into %s", CRASH_LOGFILE_NAME); - - strcat(sigttl, signame); - I_OutputMsg("\n%s\n\n", sigttl); - if (M_CheckParm("-dedicated")) return; + const char *reportmsg = "\n\n\nTo help us figure out the cause, please report the issue to our github page with " CRASH_LOGFILE_NAME " attached.\n\nSorry for the inconvenience!"; + const SDL_MessageBoxButtonData buttons[] = { { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "OK" }, { 0, 1, "Report Issue" }, @@ -1655,8 +1644,8 @@ static void I_ReportSignal(int num, int coredumped) const SDL_MessageBoxData messageboxdata = { SDL_MESSAGEBOX_ERROR, /* .flags */ NULL, /* .window */ - sigttl, /* .title */ - va("%s %s", sigmsg, reportmsg), /* .message */ + title, /* .title */ + va("%s %s", msg, reportmsg), /* .message */ SDL_arraysize(buttons), /* .numbuttons */ buttons, /* .buttons */ NULL /* .colorScheme */ @@ -1670,6 +1659,39 @@ static void I_ReportSignal(int num, int coredumped) I_OpenURL("https://github.com/Indev450/SRB2Kart-Saturn/issues"); } +static void I_ShowSimpleErrorBox(const char *title, char *msg) +{ + if (M_CheckParm("-dedicated")) + return; + + // Implement message box with SDL_ShowSimpleMessageBox, + // which should fail gracefully if it can't put a message box up + // on the target system + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, msg, NULL); + // Note that SDL_ShowSimpleMessageBox does *not* require SDL to be + // initialized at the time, so calling it after SDL_Quit() is + // perfectly okay! In addition, we do this on purpose so the + // fullscreen window is closed before displaying the error message + // in case the fullscreen window blocks it for some absurd reason. +} + +static void I_ReportSignal(int num, int coredumped) +{ + char sigmsg[512]; + char signame[128]; + char sigttl[512] = "Process killed by signal: "; + + I_PrintSignal(num, coredumped, sigmsg, signame); + + size_t len = strlen(sigmsg); + snprintf(sigmsg + len, sizeof(sigmsg) - len, "\n\nCrash report has been saved into %s", CRASH_LOGFILE_NAME); + + strcat(sigttl, signame); + I_OutputMsg("\n%s\n\n", sigttl); + //I_ShowSimpleErrorBox(sigttl, sigmsg); + I_ShowErrorBox(sigttl, sigmsg); +} + #ifndef NEWSIGNALHANDLER FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) { @@ -1775,11 +1797,7 @@ FUNCNORETURN static ATTRNORETURN void newsignalhandler_Warn(const char *pr) ); I_OutputMsg("%s\n", text); - - if (!M_CheckParm("-dedicated")) - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Startup error", - text, NULL); + I_ShowSimpleErrorBox("Startup error", text); I_ShutdownConsole(); exit(-1); @@ -1941,6 +1959,7 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) { va_list argptr; char buffer[8192]; + const char *sigttl = ""; #ifdef HAVE_THREADS if (std::this_thread::get_id() != g_main_thread_id) @@ -1977,13 +1996,9 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) va_start(argptr, error); vsnprintf(buffer, 8192, error, argptr); va_end(argptr); - // Implement message box with SDL_ShowSimpleMessageBox, - // which should fail gracefully if it can't put a message box up - // on the target system - if (!M_CheckParm("-dedicated")) - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "SRB2Kart " VERSIONSTRING " Recursive Error", - buffer, NULL); + + sigttl = "SRB2Kart " VERSIONSTRING " Recursive Error"; + I_ShowSimpleErrorBox(sigttl, buffer); W_Shutdown(); exit(-1); // recursive errors detected @@ -2023,16 +2038,9 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) I_ShutdownSystem(); SDL_Quit(); - // Implement message box with SDL_ShowSimpleMessageBox, - // which should fail gracefully if it can't put a message box up - // on the target system - if (!M_CheckParm("-dedicated")) - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SRB2Kart " VERSIONSTRING " Error", buffer, NULL); - // Note that SDL_ShowSimpleMessageBox does *not* require SDL to be - // initialized at the time, so calling it after SDL_Quit() is - // perfectly okay! In addition, we do this on purpose so the - // fullscreen window is closed before displaying the error message - // in case the fullscreen window blocks it for some absurd reason. + sigttl = "SRB2Kart " VERSIONSTRING " Error"; + //I_ShowSimpleErrorBox(sigttl, buffer); + I_ShowErrorBox(sigttl, buffer); W_Shutdown(); From c9fc3b48203935c6d3f250141959b7f85d200792 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 18:23:21 +0100 Subject: [PATCH 098/589] fixup cmake for macos mostly based on the patch from https://github.com/Bijman/srb2bld with some changes from https://github.com/Indev450/SRB2Kart-Saturn/pull/216 but doesent completely replace the build system with what blan has compiles fine on nix, but needs testing on mac --- CMakeLists.txt | 6 +++- src/CMakeLists.txt | 43 +++++++++++++++-------- src/command.h | 6 ++-- src/d_netcmd.c | 3 ++ src/dedicated/i_system.c | 4 --- src/doomdef.h | 41 +++++++++++++++++----- src/m_emotes.h | 8 ++--- src/p_local.h | 8 ++--- src/p_tick.h | 8 +++++ src/r_fps.h | 8 ++--- src/r_main.h | 8 ++--- src/r_segs.cpp | 2 ++ src/sdl/CMakeLists.txt | 4 +-- src/sdl/i_system.cpp | 7 ++-- src/sdl/i_threads.c | 4 +++ src/sdl/macosx/mac_alert.c | 64 ---------------------------------- src/sdl/macosx/mac_alert.h | 27 -------------- src/sdl/macosx/mac_resources.h | 8 ++++- src/strcasestr.c | 4 +++ 19 files changed, 115 insertions(+), 148 deletions(-) delete mode 100644 src/sdl/macosx/mac_alert.c delete mode 100644 src/sdl/macosx/mac_alert.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b7d280190..c5e12d93d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,11 @@ cmake_minimum_required(VERSION 3.5) # Version change is fine. project(SRB2 VERSION 1.6 - LANGUAGES C) + LANGUAGES C CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) # optional but recommended: disables GNU extensions, forces pure ISO C++ if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 361386622..251195414 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,8 @@ # Core sources set(SRB2_CORE_SOURCES + core/memory.cpp + core/thread_pool.cpp am_map.c b_bot.c command.c @@ -18,17 +20,21 @@ set(SRB2_CORE_SOURCES f_wipe.c filesrch.c g_game.c + g_demo.c g_input.c hu_stuff.c i_tcp.c info.c + k_hud.c lzf.c m_aatree.c m_anigif.c m_argv.c m_bbox.c m_cheat.c + m_curl.c m_cond.c + m_emotes.cpp m_fixed.c m_menu.c m_textinput.c @@ -40,19 +46,25 @@ set(SRB2_CORE_SOURCES mserv.c http-mserv.c qs22j.c + r_skins.c s_sound.c screen.c sounds.c st_stuff.c - #string.c + #strcasestr.c tables.c v_video.c w_wad.c y_inter.c - z_zone.c + z_zone.cpp ) set(SRB2_CORE_HEADERS + core/memory.h + core/thread_pool.h + m_curl.h + m_emotes.h + k_hud.h am_map.h b_bot.h byteptr.h @@ -78,6 +90,7 @@ set(SRB2_CORE_HEADERS fastcmp.h filesrch.h g_game.h + g_demo.h g_input.h g_state.h hu_stuff.h @@ -109,6 +122,7 @@ set(SRB2_CORE_HEADERS md5.h mserv.h qs22j.h + r_skins.h s_sound.h screen.h sounds.h @@ -123,18 +137,18 @@ set(SRB2_CORE_HEADERS ) set(SRB2_CORE_RENDER_SOURCES - r_bsp.c + r_bsp.cpp r_data.c - r_draw.c - r_fps.c - r_main.c - r_patch.c - r_patchrotation.c - r_plane.c - r_segs.c + r_draw.cpp + r_fps.cpp + r_main.cpp + r_patch.cpp + r_patchrotation.cpp + r_plane.cpp + r_segs.cpp r_sky.c r_splats.c - r_things.c + r_things.cpp r_portal.c r_bsp.h @@ -162,7 +176,7 @@ set(SRB2_CORE_GAME_SOURCES p_inter.c p_lights.c p_map.c - p_maputl.c + p_maputl.cpp p_mobj.c p_polyobj.c p_saveg.c @@ -475,10 +489,10 @@ if(${SRB2_CONFIG_HWRENDER}) ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c @@ -493,7 +507,6 @@ if(${SRB2_CONFIG_HWRENDER}) ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_gl.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h diff --git a/src/command.h b/src/command.h index 7074158e1..d3bf09127 100644 --- a/src/command.h +++ b/src/command.h @@ -13,13 +13,13 @@ #ifndef __COMMAND_H__ #define __COMMAND_H__ +#include +#include "doomdef.h" + #ifdef __cplusplus extern "C" { #endif -#include -#include "doomdef.h" - //=================================== // Command buffer & command execution //=================================== diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 781120be2..641a026fd 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -54,6 +54,9 @@ #include "fastcmp.h" #include "m_perfstats.h" +#include "r_data.h" +#include "r_skins.h" + #ifdef NETGAME_DEVMODE #define CV_RESTRICT CV_NETVAR #else diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 4d52ffa70..437439010 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -180,10 +180,6 @@ static char returnWadPath[256]; #include "../m_argv.h" -#ifdef MAC_ALERT -#include "macosx/mac_alert.h" -#endif - #include "../d_main.h" #if !defined(NOMUMBLE) && defined(HAVE_MUMBLE) diff --git a/src/doomdef.h b/src/doomdef.h index 492fa1185..23768d0f4 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -40,22 +40,45 @@ #define ASMCALL #endif -#ifdef __cplusplus -extern "C" { -#endif - #include "doomtype.h" +#ifdef __cplusplus /* Only when compiled as C++ */ + #include /* std::min, std::max, std::sort, … */ +#endif + +#ifdef __cplusplus +// Force libc++ to expose std::min/std::max even when is included first (Apple clang quirk) +#ifndef _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES +#define _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES +#endif +#ifndef _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS +#define _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS +#endif + +// Optional: only try if it actually exists (newer Xcode) +#if __has_include() +#include +#endif + +#define _USE_MATH_DEFINES +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#else +#include #include #include #include +#include #include -#define _USE_MATH_DEFINES // fixes M_PI errors in r_plane.c for Visual Studio -#ifdef __cplusplus -#include -#else -#include +#include #endif #include diff --git a/src/m_emotes.h b/src/m_emotes.h index 594e219f8..d87dd438f 100644 --- a/src/m_emotes.h +++ b/src/m_emotes.h @@ -12,14 +12,14 @@ #ifndef __M_EMOTES__ #define __M_EMOTES__ -#ifdef __cplusplus -extern "C" { -#endif - #include "doomdef.h" #include "m_fixed.h" #include "command.h" +#ifdef __cplusplus +extern "C" { +#endif + extern consvar_t cv_emotes; #define MAXEMOTENAME 32 diff --git a/src/p_local.h b/src/p_local.h index 3c16b5c62..82e3fb673 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -14,10 +14,6 @@ #ifndef __P_LOCAL__ #define __P_LOCAL__ -#ifdef __cplusplus -extern "C" { -#endif - #include "command.h" #include "d_player.h" #include "d_think.h" @@ -28,6 +24,10 @@ extern "C" { #include "p_maputl.h" #include "doomstat.h" // MAXSPLITSCREENPLAYERS +#ifdef __cplusplus +extern "C" { +#endif + #define FLOATSPEED (FRACUNIT*4) //#define VIEWHEIGHTS "41" diff --git a/src/p_tick.h b/src/p_tick.h index a903be0fd..e0fcd899c 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -20,6 +20,10 @@ #pragma interface #endif +#ifdef __cplusplus +extern "C" { +#endif + extern tic_t leveltime; // Called by G_Ticker. Carries out all thinking of enemies and players. @@ -38,6 +42,10 @@ mobj_t *P_SetTarget2(mobj_t **mo, mobj_t *target #endif ); +#ifdef __cplusplus +} +#endif + #ifdef PARANOIA #define P_SetTarget(...) P_SetTarget2(__VA_ARGS__, __FILE__, __LINE__) #else diff --git a/src/r_fps.h b/src/r_fps.h index 89efc6cfb..bf3f48362 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -15,16 +15,16 @@ #ifndef __R_FPS_H__ #define __R_FPS_H__ -#ifdef __cplusplus -extern "C" { -#endif - #include "m_fixed.h" #include "p_local.h" #include "r_state.h" #include "r_things.h" #include "m_perfstats.h" +#ifdef __cplusplus +extern "C" { +#endif + extern consvar_t cv_fpscap, cv_fpscapbg; extern ps_metric_t ps_interp_frac; diff --git a/src/r_main.h b/src/r_main.h index d33d67606..e8b7393e3 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -14,14 +14,14 @@ #ifndef __R_MAIN__ #define __R_MAIN__ -#ifdef __cplusplus -extern "C" { -#endif - #include "d_player.h" #include "r_data.h" #include "m_perfstats.h" +#ifdef __cplusplus +extern "C" { +#endif + // // POV related. // diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 3fe8042ae..6751befc9 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -15,6 +15,8 @@ #include "r_local.h" #include "r_sky.h" +#include + #include "r_portal.h" #include "r_splats.h" #include "r_fps.h" // newview diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index e4b0d4f37..fe29c5d2f 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -32,7 +32,7 @@ set(SRB2_SDL2_SOURCES hwsym_sdl.c i_main.c i_net.c - i_system.c + i_system.cpp i_ttf.c i_video.c i_threads.c @@ -123,8 +123,6 @@ if(${SDL2_FOUND}) set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns) set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") set(SRB2_SDL2_MAC_SOURCES - macosx/mac_alert.c - macosx/mac_alert.h macosx/mac_resources.c macosx/mac_resources.h macosx/Srb2mac.icns diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index eeeb2373c..48dfa9fd2 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -30,6 +30,7 @@ #endif #include +#include #ifdef _WIN32 #define RPC_NO_WINDOWS_H @@ -201,10 +202,6 @@ static char returnWadPath[256]; #include "../s_sound.h" -#ifdef MAC_ALERT -#include "macosx/mac_alert.h" -#endif - #include "../d_main.h" #if !defined(NOMUMBLE) && defined(HAVE_MUMBLE) @@ -2466,7 +2463,7 @@ static const char *locateWad(void) return NULL; } -const char *I_LocateWad(void) +extern "C" const char *I_LocateWad(void) { const char *waddir = NULL; diff --git a/src/sdl/i_threads.c b/src/sdl/i_threads.c index 078f4e0f4..26d3bbefe 100644 --- a/src/sdl/i_threads.c +++ b/src/sdl/i_threads.c @@ -9,6 +9,8 @@ /// \file i_threads.c /// \brief Multithreading abstraction +#ifdef HAVE_THREADS + #include "../doomdef.h" #include "../i_threads.h" @@ -354,3 +356,5 @@ I_wake_all_cond ( if (SDL_CondBroadcast(cond) == -1) abort(); } + +#endif // HAVE_THREADS diff --git a/src/sdl/macosx/mac_alert.c b/src/sdl/macosx/mac_alert.c deleted file mode 100644 index 2a139041a..000000000 --- a/src/sdl/macosx/mac_alert.c +++ /dev/null @@ -1,64 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Graphical Alerts for MacOSX -/// -/// Shows alerts, since we can't just print these to the screen when -/// launched graphically on a mac. - -#ifdef __APPLE_CC__ - -#include "mac_alert.h" -#include - -#define CFSTRINGIFY(x) CFStringCreateWithCString(NULL, x, kCFStringEncodingASCII) - -int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3) -{ - CFOptionFlags results; - - CFStringRef cf_title = CFSTRINGIFY(title); - CFStringRef cf_message = CFSTRINGIFY(message); - CFStringRef cf_button1 = NULL; - CFStringRef cf_button2 = NULL; - CFStringRef cf_button3 = NULL; - - if (button1 != NULL) - cf_button1 = CFSTRINGIFY(button1); - if (button2 != NULL) - cf_button2 = CFSTRINGIFY(button2); - if (button3 != NULL) - cf_button3 = CFSTRINGIFY(button3); - - CFOptionFlags alert_flags = kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag; - - CFUserNotificationDisplayAlert(0, alert_flags, NULL, NULL, NULL, cf_title, cf_message, - cf_button1, cf_button2, cf_button3, &results); - - if (cf_button1 != NULL) - CFRelease(cf_button1); - if (cf_button2 != NULL) - CFRelease(cf_button2); - if (cf_button3 != NULL) - CFRelease(cf_button3); - CFRelease(cf_message); - CFRelease(cf_title); - - return (int)results; -} - -#endif diff --git a/src/sdl/macosx/mac_alert.h b/src/sdl/macosx/mac_alert.h deleted file mode 100644 index 82a28d120..000000000 --- a/src/sdl/macosx/mac_alert.h +++ /dev/null @@ -1,27 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Graphical Alerts for MacOSX -/// -/// Shows alerts, since we can't just print these to the screen when -/// launched graphically on a mac. - -#ifdef __APPLE_CC__ - -extern int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3); - -#endif diff --git a/src/sdl/macosx/mac_resources.h b/src/sdl/macosx/mac_resources.h index 727ac9f6b..d63232dac 100644 --- a/src/sdl/macosx/mac_resources.h +++ b/src/sdl/macosx/mac_resources.h @@ -1,5 +1,11 @@ #ifndef __MAC_RESOURCES_H__ #define __MAC_RESOURCES_H__ +#ifdef __cplusplus +extern "C" { +#endif void OSX_GetResourcesPath(char * buffer); -#endif \ No newline at end of file +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/strcasestr.c b/src/strcasestr.c index 3eb6af60f..f05449778 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -23,6 +23,10 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include +#include +#include + static inline int trycmp (char **pp, char *cp, const char *q, size_t qn) From f7bbde398237d395f0b1ff6895cf42a29e575521 Mon Sep 17 00:00:00 2001 From: cobalt2727 <60624944+cobalt2727@users.noreply.github.com> Date: Wed, 8 Feb 2023 14:46:09 -0500 Subject: [PATCH 099/589] fix ARM builds being completely broken If merged, this is the quickest approach to resolve https://github.com/STJr/SRB2/issues/513 ...alternatively, we could just remove the option altogether but I don't have the time right now to test whether it's needed or not To the best of my knowledge, this covers all possible amd64 `CMAKE_SYSTEM_PROCESSOR` values based on what I'm seeing at https://stackoverflow.com/questions/70475665/what-are-the-possible-values-of-cmake-system-processor --- src/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 251195414..cc49bc0b4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -549,8 +549,11 @@ endif() # Compatibility flag with later versions of GCC # We should really fix our code to not need this -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64|em64t|EM64T)") + set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) + endif() + set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs) endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") From cb2c65e9d93a30187166427b631446880a859c9e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:08:52 +0100 Subject: [PATCH 100/589] more cmake fixups - skip asset install for linux - pass fwrapv flag - fix asset hash stuff - pass rdynamic flag - add saturn specific stuff, saturnpak, saturnjoin, libbacktrace and fix screen fbo stuff --- CMakeLists.txt | 1 + assets/CMakeLists.txt | 5 +++ cmake/Modules/Findlibbacktrace.cmake | 33 +++++++++++++++++ src/CMakeLists.txt | 55 ++++++++++++++++++++++------ src/config.h.in | 41 ++------------------- src/d_main.c | 25 +++++++++++++ src/sdl/CMakeLists.txt | 5 +++ 7 files changed, 116 insertions(+), 49 deletions(-) create mode 100644 cmake/Modules/Findlibbacktrace.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index c5e12d93d..7c55117ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,7 @@ endif() # OS macros if (UNIX) add_definitions(-DUNIXCOMMON) + add_link_options(-rdynamic) # Use -rdynamic so a backtrace log shows function names endif() if(CMAKE_COMPILER_IS_GNUCC) diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index 12be1c470..a34cf2dfc 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -1,5 +1,10 @@ ## Assets Target Configuration ## +if(${CMAKE_SYSTEM} MATCHES Linux) + # Asset installation isn't part of the Linux target + return() +endif() + # For prepending the current source path, later FUNCTION(PREPEND var prefix) SET(listVar "") diff --git a/cmake/Modules/Findlibbacktrace.cmake b/cmake/Modules/Findlibbacktrace.cmake new file mode 100644 index 000000000..81ebeb9dc --- /dev/null +++ b/cmake/Modules/Findlibbacktrace.cmake @@ -0,0 +1,33 @@ +include(LibFindMacros) + +libfind_pkg_check_modules(LIBBACKTRACE_PKGCONF LIBBACKTRACE) + +find_path(LIBBACKTRACE_INCLUDE_DIR + NAMES backtrace.h + PATHS + ${LIBBACKTRACE_PKGCONF_INCLUDE_DIRS} + "/usr/include" + "/usr/local/include" +) + +find_library(LIBBACKTRACE_LIBRARY + NAMES backtrace + PATHS + ${LIBBACKTRACE_PKGCONF_LIBRARY_DIRS} + "/usr/lib" + "/usr/local/lib" +) + +set(LIBBACKTRACE_PROCESS_INCLUDES LIBBACKTRACE_INCLUDE_DIR) +set(LIBBACKTRACE_PROCESS_LIBS LIBBACKTRACE_LIBRARY) +libfind_process(LIBBACKTRACE) + +if(LIBBACKTRACE_FOUND AND NOT TARGET libbacktrace) + add_library(libbacktrace UNKNOWN IMPORTED) + set_target_properties( + libbacktrace + PROPERTIES + IMPORTED_LOCATION "${LIBBACKTRACE_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${LIBBACKTRACE_INCLUDE_DIR}" + ) +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cc49bc0b4..0d144ec4c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -240,11 +240,19 @@ set(SRB2_CONFIG_HWRENDER ON CACHE BOOL "Enable hardware rendering through OpenGL.") set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL "Use statically linked OpenGL. NOT RECOMMENDED.") -set(SRB2_CONFIG_USE_FBO_OGL ON CACHE BOOL - "Enable OpenGL FBO Downsampling support.") +set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL + "Enable hardware renderer (OpenGL) FBO downsampling support") set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL "Build a dedicated server.") +set(SRB2_CONFIG_SATURNPAK ON CACHE BOOL + "Enable Saturn specific special packet. Required for using the newer resynch system") +set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL + "Enable Saturn specific allowjoin toggle.") + +set(SRB2_CONFIG_LIBBACKTRACE ON CACHE BOOL + "Enable using libbacktrace for crashlogs") + if(${SRB2_CONFIG_DEDICATED}) set(SRB2_CONFIG_HAVE_GME NO) set(SRB2_CONFIG_HAVE_OPENMPT NO) @@ -483,6 +491,27 @@ if(${SRB2_CONFIG_HAVE_CURL}) endif() endif() +if(${SRB2_CONFIG_LIBBACKTRACE}) + if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) + if(${SRB2_SYSTEM_BITS} EQUAL 64) + set(LIBBACKTRACE_FOUND ON) + set(LIBBACKTRACE_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/libbacktrace/include) + set(LIBBACKTRACE_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/libbacktrace/lib/x86_64 -lbacktrace") + else() # 32-bit + message(WARNING "libbacktrace is unsupported on 32-bit builds.") + endif() + else() + find_package(libbacktrace) + endif() + if(${LIBBACKTRACE_FOUND}) + set(SRB2_HAVE_LIBBACKTRACE ON) + add_definitions(-DHAVE_LIBBACKTRACE) + add_compile_options(-g) + else() + message(WARNING "You have specified that libbacktrace is available but it was not found.") + endif() +endif() + if(${SRB2_CONFIG_HWRENDER}) add_definitions(-DHWRENDER) set(SRB2_HWRENDER_SOURCES @@ -536,29 +565,33 @@ if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL}) else() message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.") endif() -endif() -if(${SRB2_CONFIG_HWRENDER}) - if(${SRB2_CONFIG_USE_FBO_OGL}) - set(SRB2_USE_FBO_OGL ON) + if(${SRB2_CONFIG_SCREENFBO}) add_definitions(-DUSE_FBO_OGL) endif() endif() +if(${SRB2_CONFIG_SATURNPAK}) + add_definitions(-DDOSATURNPAK) +endif() + +if(${SRB2_CONFIG_SATURNJOIN}) + add_definitions(-DDOSATURNJOIN) +endif() + # Targets # Compatibility flag with later versions of GCC # We should really fix our code to not need this if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|x64|amd64|AMD64|em64t|EM64T)") - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -mno-ms-bitfields) + add_compile_options(-mno-ms-bitfields) endif() - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs) + add_compile_options(-Wno-trigraphs) endif() -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) -endif() +# TODO: fix prng and P_CreateBlockmap overflow at some point +add_compile_options(-fwrapv) add_definitions(-DCMAKECONFIG) diff --git a/src/config.h.in b/src/config.h.in index 5225c8b0b..4028ef2f0 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -11,21 +11,6 @@ #ifdef CMAKECONFIG -// Base SRB2 hashes -#define ASSET_HASH_SRB2_SRB "${SRB2_ASSET_srb2.srb_HASH}" -#ifdef USE_PATCH_DTA -#define ASSET_HASH_PATCH_DTA "${SRB2_ASSET_patch.dta_HASH}" -#endif - -// SRB2Kart-specific hashes -#define ASSET_HASH_GFX_KART "${SRB2_ASSET_gfx.kart_HASH}" -#define ASSET_HASH_TEXTURES_KART "${SRB2_ASSET_textures.kart_HASH}" -#define ASSET_HASH_CHARS_KART "${SRB2_ASSET_chars.kart_HASH}" -#define ASSET_HASH_MAPS_KART "${SRB2_ASSET_maps.kart_HASH}" -#ifdef USE_PATCH_KART -#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000" -#endif - #define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}" #define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}" @@ -33,30 +18,10 @@ #else -/* Manually defined asset hashes for non-CMake builds - * Last updated 2015 / 05 / 03 - SRB2 v2.1.15 - srb2.srb - * Last updated 2018 / 12 / 23 - SRB2 v2.1.22 - patch.dta - * Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets - * Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart - * Last updated 2022 / 08 / 16 - Kart v1.4 - Main assets - * Last updated 2022 / 08 / 19 - Kart v1.5 - gfx.kart - * Last updated 2022 / 11 / 01 - Kart v1.6 - gfx.kart, maps.kart - */ +#define SRB2_COMP_REVISION "" +#define SRB2_COMP_BRANCH "" -// Base SRB2 hashes -#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7" -#ifdef USE_PATCH_DTA -#define ASSET_HASH_PATCH_DTA "b04fd9624bfd94dc96dcf4f400f7deb4" -#endif - -// SRB2Kart-specific hashes -#define ASSET_HASH_GFX_KART "06f86ee16136eb8a7043b15001797034" -#define ASSET_HASH_TEXTURES_KART "abb53d56aba47c3a8cb0f764da1c8b80" -#define ASSET_HASH_CHARS_KART "e2c428347dde52858a3dacd29fc5b964" -#define ASSET_HASH_MAPS_KART "d051e55141ba736582228c456953cd98" -#ifdef USE_PATCH_KART -#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000" -#endif +#define CMAKE_ASSETS_DIR "" #endif #endif diff --git a/src/d_main.c b/src/d_main.c index 81fd3d830..c5499fb57 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -80,6 +80,31 @@ #include "lua_script.h" +/* Manually defined asset hashes for non-CMake builds + * Last updated 2015 / 05 / 03 - SRB2 v2.1.15 - srb2.srb + * Last updated 2018 / 12 / 23 - SRB2 v2.1.22 - patch.dta + * Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets + * Last updated 2020 / 08 / 30 - Kart v1.3 - patch.kart + * Last updated 2022 / 08 / 16 - Kart v1.4 - Main assets + * Last updated 2022 / 08 / 19 - Kart v1.5 - gfx.kart + * Last updated 2022 / 11 / 01 - Kart v1.6 - gfx.kart, maps.kart + */ + +// Base SRB2 hashes +#define ASSET_HASH_SRB2_SRB "c1b9577687f8a795104aef4600720ea7" +#ifdef USE_PATCH_DTA +#define ASSET_HASH_PATCH_DTA "b04fd9624bfd94dc96dcf4f400f7deb4" +#endif + +// SRB2Kart-specific hashes +#define ASSET_HASH_GFX_KART "06f86ee16136eb8a7043b15001797034" +#define ASSET_HASH_TEXTURES_KART "abb53d56aba47c3a8cb0f764da1c8b80" +#define ASSET_HASH_CHARS_KART "e2c428347dde52858a3dacd29fc5b964" +#define ASSET_HASH_MAPS_KART "d051e55141ba736582228c456953cd98" +#ifdef USE_PATCH_KART +#define ASSET_HASH_PATCH_KART "00000000000000000000000000000000" +#endif + #ifdef CMAKECONFIG #include "config.h" #else diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index fe29c5d2f..546b92fcd 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -165,6 +165,11 @@ if(${SDL2_FOUND}) ${DISCORDRPC_LIBRARIES} ) + if(${SRB2_HAVE_LIBBACKTRACE}) + target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES}) + endif() + + if(${CMAKE_SYSTEM} MATCHES Linux) target_link_libraries(SRB2SDL2 PRIVATE m From 4eeb0b4b20da403878df839d7e613f3415fa7c10 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:16:05 +0100 Subject: [PATCH 101/589] update readme to reflect this --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d538288bb..698f55a9c 100644 --- a/README.md +++ b/README.md @@ -22,14 +22,14 @@ We also have a Flatpak available on [Flathub](https://flathub.org/en/apps/org.sr See [SRB2 Wiki/Source code compiling](http://wiki.srb2.org/wiki/Source_code_compiling). The compiling process for SRB2Kart is largely identical to SRB2. -Currently only the Makefile build system with GCC or Clang compiler is supported. -CMake is NOT supported at the moment, but will be availible again soon. - +For Windows only the Makefile build system with GCC or Clang compiler is supported. Visual C++ (MSVC) is unsupported. 64-bit Windows builds are supported and recommended over 32-bit builds, they will build automatically when using the MSYS2 MinGW 64-bit executable (requires the mingw-w64-x86_64-gcc package), no extra flags needed! The specific DLLs can be found under /libs/dll-binaries/(i686 for 32bit/x86_64 for 64-bit)/ or in the Release packages +MacOS and Linux can be build with CMake, but it is recommended to use the Makefile for Linux over CMake + Alternatively the [srb2bld](https://github.com/Bijman/srb2bld) script by Bijman can be used aswell! ## Disclaimer From af952870c3f03ab272dc7e23516f401602f60606 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:22:40 +0100 Subject: [PATCH 102/589] fix fbo oopsie --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0d144ec4c..07179882d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -565,10 +565,10 @@ if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL}) else() message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.") endif() +endif() - if(${SRB2_CONFIG_SCREENFBO}) - add_definitions(-DUSE_FBO_OGL) - endif() +if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_SCREENFBO}) + add_definitions(-DUSE_FBO_OGL) endif() if(${SRB2_CONFIG_SATURNPAK}) From 186421fe85cae9a945fa9d3dd899e0cf6ce8b0a7 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:23:36 +0100 Subject: [PATCH 103/589] cmake: link with peethread --- src/sdl/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index 546b92fcd..1c7d52344 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -174,6 +174,7 @@ if(${SDL2_FOUND}) target_link_libraries(SRB2SDL2 PRIVATE m rt + pthread ) endif() From 8e91c16e97636409399e0e6c4782d857634fa1bf Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:34:38 +0100 Subject: [PATCH 104/589] cmake: enable gnu extensions we rely on some of them like the cleanup macro dont want those breaking or smth --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c55117ad..1acd092bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,9 @@ project(SRB2 set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) # optional but recommended: disables GNU extensions, forces pure ISO C++ +#set(CMAKE_CXX_EXTENSIONS OFF) # optional but recommended: disables GNU extensions, forces pure ISO C++ +set(CMAKE_CXX_EXTENSIONS ON) +set(CMAKE_C_EXTENSIONS ON) if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") From 4e75d9902653db35ba2349612479d977cfbf04bb Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:49:26 +0100 Subject: [PATCH 105/589] simplify LUA_Alloc Z_Realloc already handles everything internally, no need to manually free anything --- src/lua_infolib.c | 2 +- src/lua_script.c | 39 ++++++++++++++++++--------------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 68ca6b4d0..4c84c48d5 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -25,7 +25,7 @@ #include "lua_hook.h" // cmd errors boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor); -state_t *astate; +state_t *astate = NULL; boolean actionsoverridden[NUMACTIONS] = {false}; diff --git a/src/lua_script.c b/src/lua_script.c index 2aa88cd52..8982688a1 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -45,20 +45,20 @@ int hook_defrosting = 0; // List of internal libraries to load from SRB2 static lua_CFunction liblist[] = { - LUA_EnumLib, // global metatable for enums - LUA_SOCLib, // A_Action functions, freeslot - LUA_BaseLib, // string concatination by +, CONS_Printf, p_local.h stuff (P_InstaThrust, P_Move), etc. - LUA_MathLib, // fixed_t and angle_t math functions - LUA_HookLib, // hookAdd and hook-calling functions - LUA_ConsoleLib, // console command/variable functions and structs - LUA_InfoLib, // info.h stuff: mobjinfo_t, mobjinfo[], state_t, states[] - LUA_MobjLib, // mobj_t, mapthing_t - LUA_PlayerLib, // player_t - LUA_SkinLib, // skin_t, skins[] - LUA_ThinkerLib, // thinker_t - LUA_MapLib, // line_t, side_t, sector_t, subsector_t - LUA_BlockmapLib, // blockmap stuff - LUA_HudLib, // HUD stuff + LUA_EnumLib, // global metatable for enums + LUA_SOCLib, // A_Action functions, freeslot + LUA_BaseLib, // string concatination by +, CONS_Printf, p_local.h stuff (P_InstaThrust, P_Move), etc. + LUA_MathLib, // fixed_t and angle_t math functions + LUA_HookLib, // hookAdd and hook-calling functions + LUA_ConsoleLib, // console command/variable functions and structs + LUA_InfoLib, // info.h stuff: mobjinfo_t, mobjinfo[], state_t, states[] + LUA_MobjLib, // mobj_t, mapthing_t + LUA_PlayerLib, // player_t + LUA_SkinLib, // skin_t, skins[] + LUA_ThinkerLib, // thinker_t + LUA_MapLib, // line_t, side_t, sector_t, subsector_t + LUA_BlockmapLib, // blockmap stuff + LUA_HudLib, // HUD stuff NULL }; @@ -66,12 +66,8 @@ static lua_CFunction liblist[] = { static void *LUA_Alloc(void *ud, void *ptr, size_t osize, size_t nsize) { (void)ud; - if (nsize == 0) { - if (osize != 0) - Z_Free(ptr); - return NULL; - } else - return Z_Realloc(ptr, nsize, PU_LUA, NULL); + (void)osize; + return Z_Realloc(ptr, nsize, PU_LUA, NULL); } // Panic function Lua calls when there's an unprotected error. @@ -213,7 +209,8 @@ void LUA_ClearState(void) lua_setfield(L, LUA_REGISTRYINDEX, LREG_VALID); // open srb2 libraries - for(i = 0; liblist[i]; i++) { + for (i = 0; liblist[i]; i++) + { lua_pushcfunction(L, liblist[i]); lua_call(L, 0, 0); } From 59c9af97c2d9dbfcb5405acf7c6d6a5403132d28 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 19:53:49 +0100 Subject: [PATCH 106/589] joy_open: make debug prints actually print the player number --- src/sdl/i_system.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index eeeb2373c..ea10ed34c 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -885,13 +885,13 @@ static int joy_open(int playerIndex, int joyIndex) if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) { - CONS_Printf(M_GetText("Joystick subsystem not started\n")); + CONS_Printf("Joystick subsystem not started\n"); return -1; } if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0) { - CONS_Printf(M_GetText("Game Controller subsystem not started\n")); + CONS_Printf("Game Controller subsystem not started\n"); return -1; } @@ -902,7 +902,7 @@ static int joy_open(int playerIndex, int joyIndex) if (num_joy == 0) { - CONS_Printf("%s", M_GetText("Found no joysticks on this system\n")); + CONS_Printf("%s", "Found no joysticks on this system\n"); return -1; } @@ -925,7 +925,7 @@ static int joy_open(int playerIndex, int joyIndex) return SDL_CONTROLLER_AXIS_MAX; // Else, we're changing devices, so send neutral joy events - CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n"); + CONS_Debug(DBG_GAMELOGIC, "Joystick %d device is changing; resetting events...\n", playerIndex+1); I_ShutdownJoystick(playerIndex); } @@ -933,11 +933,11 @@ static int joy_open(int playerIndex, int joyIndex) if (JoyInfo[playerIndex].dev == NULL) { - CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: Couldn't open device - %s\n"), SDL_GetError()); + CONS_Debug(DBG_GAMELOGIC, "Joystick %d: Couldn't open device - %s\n", playerIndex+1, SDL_GetError()); return -1; } - CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_GameControllerName(JoyInfo[playerIndex].dev)); + CONS_Debug(DBG_GAMELOGIC, "Joystick %d: %s\n", playerIndex+1, SDL_GameControllerName(JoyInfo[playerIndex].dev)); JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev); From 276cf0a8cbfa143a31a874160db2cec993685c6f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 20:04:19 +0100 Subject: [PATCH 107/589] fix string.c include whoops, not sure why that was even done like that string.c will include strcasestr.c and SRB2_HAVE_STRLCPY will ensure eitherways we dont use the included strlcpy stuff --- src/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 07179882d..f09b95633 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -51,7 +51,7 @@ set(SRB2_CORE_SOURCES screen.c sounds.c st_stuff.c - #strcasestr.c + string.c tables.c v_video.c w_wad.c @@ -207,10 +207,6 @@ set(SRB2_CORE_GAME_SOURCES k_stats.h ) -if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - set(SRB2_CORE_SOURCES ${SRB2_CORE_SOURCES} string.c) -endif() - prepend_sources(SRB2_CORE_SOURCES) prepend_sources(SRB2_CORE_HEADERS) prepend_sources(SRB2_CORE_RENDER_SOURCES) From 7dbb08315c820e4ee0ba90a3cbd1d43821110bc6 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 20:48:04 +0100 Subject: [PATCH 108/589] fix cmake --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f09b95633..02dab08da 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,7 +54,7 @@ set(SRB2_CORE_SOURCES string.c tables.c v_video.c - w_wad.c + w_wad.cpp y_inter.c z_zone.cpp ) From 8e4b304bed833e73dcacb8abffdfcb77fe1ea07b Mon Sep 17 00:00:00 2001 From: PAS Date: Wed, 9 Jul 2025 23:15:33 -0400 Subject: [PATCH 109/589] CMake: don't configure before CPACK_PACKAGE_DESCRIPTION_SUMMARY is set --- CMakeLists.txt | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1acd092bc..2d8354b44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,28 @@ if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") endif() +##### PACKAGE CONFIGURATION ##### + +if(${CMAKE_SYSTEM} MATCHES "Windows") + set(CPACK_GENERATOR "ZIP") +endif() +if(${CMAKE_SYSTEM} MATCHES "Linux") + set(CPACK_GENERATOR "TGZ") +endif() +if(${CMAKE_SYSTEM} MATCHES "Darwin") + set(CPACK_GENERATOR "DragNDrop") +endif() + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes") +set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes") +#set(CPACK_PACKAGE_DESCRIPTION_FILE ) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH}) +set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}") +include(CPack) + # Set up CMAKE path set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") @@ -100,16 +122,11 @@ endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") -# Set EXE names so the assets CMakeLists can refer to its target -set(SRB2_SDL2_EXE_NAME srb2kart CACHE STRING "Executable binary output name") -set(SRB2_WIN_EXE_NAME srb2kartdd CACHE STRING "Executable binary output name for DirectDraw build") - include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) add_subdirectory(src) add_subdirectory(assets) - ## config.h generation set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary") include(GitUtilities) @@ -118,25 +135,3 @@ git_current_branch(SRB2_GIT_BRANCH "${CMAKE_SOURCE_DIR}") set(SRB2_COMP_BRANCH "${SRB2_GIT_BRANCH}") set(SRB2_COMP_REVISION "${SRB2_COMP_COMMIT}") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/config.h) - -##### PACKAGE CONFIGURATION ##### - -if(${CMAKE_SYSTEM} MATCHES "Windows") - set(CPACK_GENERATOR "ZIP") -endif() -if(${CMAKE_SYSTEM} MATCHES "Linux") - set(CPACK_GENERATOR "TGZ") -endif() -if(${CMAKE_SYSTEM} MATCHES "Darwin") - set(CPACK_GENERATOR "DragNDrop") -endif() - -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes") -set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes") -#set(CPACK_PACKAGE_DESCRIPTION_FILE ) -set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") -set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR}) -set(CPACK_PACKAGE_VERSION_MINOR ${SRB2_VERSION_MINOR}) -set(CPACK_PACKAGE_VERSION_PATCH ${SRB2_VERSION_PATCH}) -set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMAKE_VERSION_MAJOR}.${CMAKE_VERSION_MINOR}") -include(CPack) From 9f5a5a735b17cc74040ff3eea4c906cbf7decc7e Mon Sep 17 00:00:00 2001 From: PAS Date: Wed, 9 Jul 2025 23:22:57 -0400 Subject: [PATCH 110/589] Allow changing Cpak generator (from upstream) --- CMakeLists.txt | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d8354b44..84aa73968 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,9 @@ cmake_minimum_required(VERSION 3.5) + +if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) + message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") +endif() + # DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string. # Version change is fine. project(SRB2 @@ -11,22 +16,21 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS ON) set(CMAKE_C_EXTENSIONS ON) -if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) - message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") -endif() - ##### PACKAGE CONFIGURATION ##### -if(${CMAKE_SYSTEM} MATCHES "Windows") - set(CPACK_GENERATOR "ZIP") -endif() -if(${CMAKE_SYSTEM} MATCHES "Linux") - set(CPACK_GENERATOR "TGZ") -endif() -if(${CMAKE_SYSTEM} MATCHES "Darwin") - set(CPACK_GENERATOR "DragNDrop") +set(SRB2_CPACK_GENERATOR "" CACHE STRING "Generator to use for making a package. E.g., ZIP, TGZ, DragNDrop (OSX only). Leave blank for default generator.") + +if("${SRB2_CPACK_GENERATOR}" STREQUAL "") + if("${CMAKE_SYSTEM_NAME}" MATCHES "Windows") + set(SRB2_CPACK_GENERATOR "ZIP") + elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") + set(SRB2_CPACK_GENERATOR "TGZ") + elseif("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") + set(SRB2_CPACK_GENERATOR "TGZ") + endif() endif() +set(CPACK_GENERATOR ${SRB2_CPACK_GENERATOR}) set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes") set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes") #set(CPACK_PACKAGE_DESCRIPTION_FILE ) From 346b1456cd1f6aed166272fa4d9a56c3712af087 Mon Sep 17 00:00:00 2001 From: PAS Date: Mon, 21 Apr 2025 16:51:31 -0400 Subject: [PATCH 111/589] CMake: Fix FindOPENMPT --- cmake/Modules/FindOPENMPT.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/FindOPENMPT.cmake b/cmake/Modules/FindOPENMPT.cmake index 2d334b6f0..305a55ee1 100644 --- a/cmake/Modules/FindOPENMPT.cmake +++ b/cmake/Modules/FindOPENMPT.cmake @@ -1,6 +1,6 @@ include(LibFindMacros) -libfind_pkg_check_modules(OPENMPT_PKGCONF OPENMPT) +libfind_pkg_check_modules(OPENMPT_PKGCONF LIBOPENMPT) find_path(OPENMPT_INCLUDE_DIR NAMES libopenmpt.h @@ -8,6 +8,7 @@ find_path(OPENMPT_INCLUDE_DIR ${OPENMPT_PKGCONF_INCLUDE_DIRS} "/usr/include/libopenmpt" "/usr/local/include/libopenmpt" + PATH_SUFFIXES libopenmpt ) find_library(OPENMPT_LIBRARY @@ -20,4 +21,4 @@ find_library(OPENMPT_LIBRARY set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR) set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY) -libfind_process(OPENMPT) \ No newline at end of file +libfind_process(OPENMPT) From e7efd464196cae77d694a5f6bb34fd662877c944 Mon Sep 17 00:00:00 2001 From: PAS Date: Mon, 21 Apr 2025 17:51:48 -0400 Subject: [PATCH 112/589] Fix FindGME pkg-config command, update LibFindMacros.cmake --- cmake/Modules/FindGME.cmake | 4 +-- cmake/Modules/LibFindMacros.cmake | 55 +++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/cmake/Modules/FindGME.cmake b/cmake/Modules/FindGME.cmake index ea80af454..641274e75 100644 --- a/cmake/Modules/FindGME.cmake +++ b/cmake/Modules/FindGME.cmake @@ -1,6 +1,6 @@ include(LibFindMacros) -libfind_pkg_check_modules(GME_PKGCONF GME) +libfind_pkg_check_modules(GME_PKGCONF LIBGME) find_path(GME_INCLUDE_DIR NAMES gme.h @@ -20,4 +20,4 @@ find_library(GME_LIBRARY set(GME_PROCESS_INCLUDES GME_INCLUDE_DIR) set(GME_PROCESS_LIBS GME_LIBRARY) -libfind_process(GME) \ No newline at end of file +libfind_process(GME) diff --git a/cmake/Modules/LibFindMacros.cmake b/cmake/Modules/LibFindMacros.cmake index 81fef7d8e..0e29dea5e 100644 --- a/cmake/Modules/LibFindMacros.cmake +++ b/cmake/Modules/LibFindMacros.cmake @@ -1,4 +1,4 @@ -# Version 2.2 +# Version 2.4 # Public Domain, originally written by Lasse Kärkkäinen # Maintained at https://github.com/Tronic/cmake-modules # Please send your improvements as pull requests on Github. @@ -52,6 +52,10 @@ function (libfind_pkg_detect PREFIX) if (libraryargs) find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}) endif() + # Read pkg-config version + if (${PREFIX}_PKGCONF_VERSION) + set(${PREFIX}_VERSION ${${PREFIX}_PKGCONF_VERSION} PARENT_SCOPE) + endif() endfunction() # Extracts a version #define from a version.h file, output stored to _VERSION. @@ -125,24 +129,39 @@ function (libfind_process PREFIX) # Process deps to add to foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES}) - if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS) + if (DEFINED ${i}_INCLUDE_OPTS) # The package seems to export option lists that we can use, woohoo! list(APPEND includeopts ${${i}_INCLUDE_OPTS}) + else() + if (DEFINED ${i}_INCLUDE_DIR) + # Singular forms can be used + list(APPEND includeopts ${i}_INCLUDE_DIR) + else() + if (DEFINED ${i}_INCLUDE_DIRS) + # Plural forms can be used + list(APPEND includeopts ${i}_INCLUDE_DIRS) + else() + # Oh no, we don't know the option names + message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes. Aieeh!") + endif() + endif() + endif() + + if (DEFINED ${i}_LIBRARY_OPTS) + # The package seems to export option lists that we can use, woohoo! list(APPEND libraryopts ${${i}_LIBRARY_OPTS}) else() - # If plural forms don't exist or they equal singular forms - if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR - ({i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES)) + if (DEFINED ${i}_LIBRARY) # Singular forms can be used - if (DEFINED ${i}_INCLUDE_DIR) - list(APPEND includeopts ${i}_INCLUDE_DIR) - endif() - if (DEFINED ${i}_LIBRARY) - list(APPEND libraryopts ${i}_LIBRARY) - endif() + list(APPEND libraryopts ${i}_LIBRARY) else() - # Oh no, we don't know the option names - message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!") + if (DEFINED ${i}_LIBRARIES) + # Plural forms can be used + list(APPEND libraryopts ${i}_LIBRARIES) + else() + # Oh no, we don't know the option names + message(FATAL_ERROR "We couldn't determine config variable names for ${i} libraries. Aieeh!") + endif() endif() endif() endforeach() @@ -209,12 +228,12 @@ function (libfind_process PREFIX) message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}") message(STATUS " ${PREFIX}_LIBRARIES=${libs}") endif() - set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE) - set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE) - set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE) - set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE) - set (${PREFIX}_FOUND TRUE PARENT_SCOPE) endif() + set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE) + set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE) + set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE) + set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE) + set (${PREFIX}_FOUND TRUE PARENT_SCOPE) return() endif() From 96eaf8850eb5d70bf6c4a2e727091bfc075055fb Mon Sep 17 00:00:00 2001 From: PAS Date: Wed, 20 Aug 2025 02:23:20 -0400 Subject: [PATCH 113/589] Add path suffix for libgme cmake module --- cmake/Modules/FindGME.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/Modules/FindGME.cmake b/cmake/Modules/FindGME.cmake index 641274e75..7e9087247 100644 --- a/cmake/Modules/FindGME.cmake +++ b/cmake/Modules/FindGME.cmake @@ -8,6 +8,7 @@ find_path(GME_INCLUDE_DIR ${GME_PKGCONF_INCLUDE_DIRS} "/usr/include/gme" "/usr/local/include/gme" + PATH_SUFFIXES gme ) find_library(GME_LIBRARY From d9a67faf4772fd9f6efaae2ea73c53c3de670b5a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 21 Jan 2026 21:09:33 +0100 Subject: [PATCH 114/589] fix windoze compile --- src/sdl/i_system.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 1d1a8b00f..52a78232f 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -30,7 +30,10 @@ #endif #include + +#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #include +#endif #ifdef _WIN32 #define RPC_NO_WINDOWS_H From a3557fadef9712f70c66ba4e166f7ea43be06c71 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 21 Jan 2026 23:38:41 +0300 Subject: [PATCH 115/589] P_PlayRinglossSound from lua might desynch so print warning about that --- src/lua_baselib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 0da8abfae..bc94e2949 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1293,6 +1293,7 @@ static int lib_pPlayRinglossSound(lua_State *L) player_t *player = NULL; mobj_t *damager = NULL; NOHUD + LUA_UsageWarning(L, "P_PlayRinglossSound: using this function from lua might cause desynchs, consider using S_StartSound(origin, sfx_khurt1 + P_RandomKey(2)) as workaround"); if (!source) return LUA_ErrInvalid(L, "mobj_t"); if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) From 4600da5782c5c5a6bcf25ef5d56a2ba40118e063 Mon Sep 17 00:00:00 2001 From: PAS Date: Wed, 21 Jan 2026 15:54:32 -0500 Subject: [PATCH 116/589] restore SRB2_SDL2_EXE_NAME --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84aa73968..3184252da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,9 @@ endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") +# Set EXE names so the assets CMakeLists can refer to its target +set(SRB2_SDL2_EXE_NAME srb2kart CACHE STRING "Executable binary output name") + include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) add_subdirectory(src) From 0f7001ef5c41eccfd9d64b8190f9899958ea8506 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Jan 2026 13:25:07 +0100 Subject: [PATCH 117/589] opengl: tiny optimiazation for vhs effect dont call rand within the loop, use xorshift instead while not massive, we dont need to call rand thousands of times, the xorshift is visually indistinguishable this is still rather slow due to the crapton of draw calls and should best be replaced by a shader or something --- src/hardware/r_opengl/r_opengl.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 2d1f8e255..e644f5bd0 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3591,22 +3591,29 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 1.0f, -1.0f, 1.0f }; - xfix = 1/((float)screen_texsizew/(float)screen_width); - yfix = 1/((float)screen_texsizeh/(float)screen_height); - const GLfloat scrwf = (float)screen_width; const GLfloat scrwh = (float)screen_height; + xfix = 1/((float)screen_texsizew/scrwf); + yfix = 1/((float)screen_texsizeh/scrwh); + + GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest); + // Slight fuzziness GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); - GL_SetBlend(PF_Modulated|PF_Translucent|PF_NoDepthTest); pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); - const float stride = 2.f/scrwh; + uint32_t r = rand(); + const float stride = 2.f/scrwh; for (i = 0; i < 1; i += stride) { - fix[2] = (float)(rand() % 128) / -22000.f * xfix; + // avoid calling rand thousands of times + r ^= r >> 13; + r ^= r >> 11; + r ^= r << 21; + + fix[2] = (float)(r & 127) / -22000.f * xfix; fix[0] = fix[2]; fix[6] = fix[0] + xfix; fix[4] = fix[2] + xfix; @@ -3648,6 +3655,7 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 fix[1] = fix[7] += (fix[3] - fix[7])*2; screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2; + pglTexCoordPointer(2, GL_FLOAT, 0, fix); pglVertexPointer(3, GL_FLOAT, 0, screenVerts); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); @@ -3673,6 +3681,7 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 fix[1] = fix[7] += (fix[3] - fix[7])*2; screenVerts[1] = screenVerts[10] += (screenVerts[4] - screenVerts[1])*2; + pglTexCoordPointer(2, GL_FLOAT, 0, fix); pglVertexPointer(3, GL_FLOAT, 0, screenVerts); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); @@ -3712,7 +3721,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh { float xfix, yfix; float origaspect, newaspect; - float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen + float xoff = 1.0f, yoff = 1.0f; // xoffset and yoffset for the polygon to have black bars around the screen static float off[12] = { @@ -3735,19 +3744,19 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh if (origaspect < newaspect) { xoff = origaspect / newaspect; - yoff = 1; + yoff = 1.0f; } else if (origaspect > newaspect) { - xoff = 1; + xoff = 1.0f; yoff = newaspect / origaspect; } // float off[12]; off[0] = off[3] = -xoff; off[1] = off[10] = -yoff; - off[4] = off[7] = yoff; - off[6] = off[9] = xoff; + off[4] = off[7] = yoff; + off[6] = off[9] = xoff; // float fix[8]; fix[3] = fix[5] = yfix; From 2e0f5c02a41e5fd0daee9322125e40f1cea6a845 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Jan 2026 13:25:56 +0100 Subject: [PATCH 118/589] opengl: make vhs effect bars be affected by "fuzzines" makes stuff slightly slower, but matches the software effect --- src/hardware/r_opengl/r_opengl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index e644f5bd0..0caf50636 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3631,8 +3631,8 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 } // Upward bar - //GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); - //pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); + GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); + pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); color[0] = color[1] = color[2] = 190; color[3] = 250; @@ -3661,8 +3661,8 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); // Downward bar - //GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); - //pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); + GL_MakeScreenTexture(HWD_SCREENTEXTURE_VHS); + pglBindTexture(GL_TEXTURE_2D, screenTextures[HWD_SCREENTEXTURE_VHS]); fix[0] = 0.0f; fix[6] = xfix; From a1f70b0b312fb00ee09beecf8e8f951ea0c3035b Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Jan 2026 14:18:06 +0100 Subject: [PATCH 119/589] opengl: attempt to scale vhs effect "fuzzyness" this makes it appear more or less the same in all resolutions, similar to software, while also improving performance quite a bit on higher resolutions --- src/hardware/r_opengl/r_opengl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 0caf50636..8bc68d15e 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3605,8 +3605,10 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 uint32_t r = rand(); - const float stride = 2.f/scrwh; - for (i = 0; i < 1; i += stride) + const float dup = min(scrwf / BASEVIDWIDTH, scrwh / BASEVIDHEIGHT); + const float ystep = 2.f/scrwh * dup/4.f; + + for (i = 0; i < 1; i += ystep) { // avoid calling rand thousands of times r ^= r >> 13; From bbf06b3376c87383d5f473279ae6d4500d5e9a8b Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Jan 2026 14:25:33 +0100 Subject: [PATCH 120/589] add "vid.udup" same as vid.dup but not scaled with "highreshudscale" --- src/hardware/r_opengl/r_opengl.c | 3 +-- src/screen.h | 1 + src/v_video.c | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 8bc68d15e..eeb40a8dc 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3605,8 +3605,7 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 uint32_t r = rand(); - const float dup = min(scrwf / BASEVIDWIDTH, scrwh / BASEVIDHEIGHT); - const float ystep = 2.f/scrwh * dup/4.f; + const float ystep = 2.f/scrwh * (float)vid.udup/4.f; for (i = 0; i < 1; i += ystep) { diff --git a/src/screen.h b/src/screen.h index 0a912e97a..bc42e4cd3 100644 --- a/src/screen.h +++ b/src/screen.h @@ -63,6 +63,7 @@ typedef struct viddef_s INT32 dup; // scale 1, 2, 3 value for menus & overlays INT32 fdup; // same as dup, but exact value when aspect ratio isn't 320/200 + INT32 udup; // same as dup but does not account for highreshudscale UINT8 smalldup; // factor for a little bit of scaling UINT8 meddup; // factor for moderate, but not full, scaling diff --git a/src/v_video.c b/src/v_video.c index b5be19a97..8a1f36c72 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1760,17 +1760,15 @@ void V_DrawVhsEffect(boolean rewind) if (cv_reducevfx.value) return; - const INT32 dup = min(vid.width / BASEVIDWIDTH, vid.height / BASEVIDHEIGHT); - - barsize = dup << 5; - updistort = dup << (rewind ? 5 : 3); + barsize = vid.udup << 5; + updistort = vid.udup << (rewind ? 5 : 3); downdistort = updistort >> 1; if (rewind) V_DrawVhsEffect(false); // experimentation - upbary -= renderdeltatics * (fixed_t)(dup * (rewind ? 3 : 1.8f)); - downbary += renderdeltatics * (dup * (rewind ? 2 : 1)); + upbary -= renderdeltatics * (fixed_t)(vid.udup * (rewind ? 3 : 1.8f)); + downbary += renderdeltatics * (vid.udup * (rewind ? 2 : 1)); if (upbary < -barsize*FRACUNIT) upbary = vid.height << FRACBITS; @@ -3930,6 +3928,8 @@ void V_Recalc(void) vid.fdup = (vid.height*FRACUNIT) / BASEVIDHEIGHT; } + vid.udup = vid.dup; + if (loaded_config // this could use a better name, since it is more and indicator that early startup is done and its safe to do sketchy shit now :chaosleep: && (vid.width > 720) && (vid.height > 1280)) // ehhhh well this thing has so many issues, so ill lock it to higher resolutions instead { From e2ecc315b4d5d045c31229e664f2e95ca8d50a1d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Jan 2026 14:44:47 +0100 Subject: [PATCH 121/589] cmake: attempt to fix dedicated build uhh building --- src/dedicated/CMakeLists.txt | 101 +++++++++++++++++++++++++++-------- 1 file changed, 79 insertions(+), 22 deletions(-) diff --git a/src/dedicated/CMakeLists.txt b/src/dedicated/CMakeLists.txt index 36f670251..84e36690f 100644 --- a/src/dedicated/CMakeLists.txt +++ b/src/dedicated/CMakeLists.txt @@ -1,21 +1,75 @@ # Declare dedicated interface sources -target_sourcefile(c) +set(SRB2_DEDICATED_SOURCES + i_system.c + i_main.c + i_video.c + i_sound.c + i_threads.c + dosstr.c + endtxt.c +) -target_sources(SRB2SDL2 PRIVATE) +set(SRB2_DEDICATED_HEADERS + endtxt.h +) + +source_group("Interface Code" FILES ${SRB2_DEDICATED_SOURCES} ${SRB2_DEDICATED_HEADERS}) + +set(SRB2_DEDICATED_TOTAL_SOURCES + ${SRB2_CORE_SOURCES} + ${SRB2_CORE_HEADERS} + ${SRB2_PNG_SOURCES} + ${SRB2_PNG_HEADERS} + ${SRB2_CORE_RENDER_SOURCES} + ${SRB2_CORE_GAME_SOURCES} + ${SRB2_LUA_SOURCES} + ${SRB2_LUA_HEADERS} + ${SRB2_BLUA_SOURCES} + ${SRB2_BLUA_HEADERS} + ${SRB2_DEDICATED_SOURCES} + ${SRB2_DEDICATED_HEADERS} +) + +source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS}) +source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES}) +source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES}) +source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS}) +source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS}) if(${CMAKE_SYSTEM} MATCHES Windows) - target_sources(SRB2SDL2 PRIVATE - ../win32/win_dbg.c - ../win32/Srb2win.rc) + set(SRB2_DEDICATED_TOTAL_SOURCES ${SRB2_DEDICATED_TOTAL_SOURCES} + ${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c + ${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc + ) endif() +add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_DEDICATED_TOTAL_SOURCES}) + if(${CMAKE_SYSTEM} MATCHES Windows) - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy) + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd) elseif(${CMAKE_SYSTEM} MATCHES Linux) - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2dlegacy) + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsrb2kartd) else() - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2legacy) + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2kartd) +endif() + +if(${CMAKE_SYSTEM} MATCHES Darwin) + find_library(CORE_FOUNDATION_LIBRARY "CoreFoundation") + target_link_libraries(SRB2SDL2 PRIVATE + ${CORE_FOUNDATION_LIBRARY} + ) + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") + + # Configure the app bundle icon and plist properties + target_sources(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns") + set_target_properties(SRB2SDL2 PROPERTIES + MACOSX_BUNDLE_ICON_FILE "Srb2mac" + MACOSX_BUNDLE_BUNDLE_NAME "Sonic Robo Blast 2" + MACOSX_BUNDLE_BUNDLE_VERSION ${SRB2_VERSION} + + RESOURCE "${CMAKE_CURRENT_SOURCE_DIR}/macosx/Srb2mac.icns" + ) endif() if(${CMAKE_SYSTEM} MATCHES Darwin) @@ -24,25 +78,27 @@ if(${CMAKE_SYSTEM} MATCHES Darwin) ${CORE_LIB} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} + ${CURL_LIBRARIES} ) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") else() target_link_libraries(SRB2SDL2 PRIVATE ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} + ${CURL_LIBRARIES} ) - if(${CMAKE_SYSTEM} MATCHES Linux) target_link_libraries(SRB2SDL2 PRIVATE m rt + pthread ) endif() endif() -#target_link_libraries(SRB2SDL2 PRIVATE SRB2Core) - -set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION}) +if(${SRB2_HAVE_LIBBACKTRACE}) + target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES}) +endif() if(${CMAKE_SYSTEM} MATCHES Windows) target_link_libraries(SRB2SDL2 PRIVATE @@ -60,19 +116,20 @@ target_include_directories(SRB2SDL2 PRIVATE target_compile_definitions(SRB2SDL2 PRIVATE -DDEDICATED + -DHAVE_THREADS ) ## strip debug symbols into separate file when using gcc -if(CMAKE_COMPILER_IS_GNUCC) - if(${CMAKE_BUILD_TYPE} MATCHES Debug) - message(STATUS "Will make separate debug symbols in *.debug") - add_custom_command(TARGET SRB2SDL2 POST_BUILD - COMMAND ${OBJCOPY} --only-keep-debug $ $.debug - COMMAND ${OBJCOPY} --strip-debug $ - COMMAND ${OBJCOPY} --add-gnu-debuglink=$.debug $ - ) - endif() -endif() +# if(CMAKE_COMPILER_IS_GNUCC) +# if(${CMAKE_BUILD_TYPE} MATCHES Debug) +# message(STATUS "Will make separate debug symbols in *.debug") +# add_custom_command(TARGET SRB2SDL2 POST_BUILD +# COMMAND ${OBJCOPY} --only-keep-debug $ $.debug +# COMMAND ${OBJCOPY} --strip-debug $ +# COMMAND ${OBJCOPY} --add-gnu-debuglink=$.debug $ +# ) +# endif() +# endif() #### Installation #### if(${CMAKE_SYSTEM} MATCHES Darwin) From 30539371c268d27dcd8a77cf9cc6fcff972b3584 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 22 Jan 2026 14:46:04 +0100 Subject: [PATCH 122/589] more cmake stuffs -add LTO option, enabled by default -set optimization level to O3 and O0 for debug builds -add ASAN and UBSAN options -always compile with gnu debug symbols --- src/CMakeLists.txt | 25 ++++++++++++++++++------- src/dedicated/CMakeLists.txt | 14 ++++++++++++++ src/sdl/CMakeLists.txt | 17 +++++++++++++++-- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f09b95633..77a1f40fa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -236,18 +236,23 @@ set(SRB2_CONFIG_HWRENDER ON CACHE BOOL "Enable hardware rendering through OpenGL.") set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL "Use statically linked OpenGL. NOT RECOMMENDED.") -set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL - "Enable hardware renderer (OpenGL) FBO downsampling support") set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL "Build a dedicated server.") +set(SRB2_CONFIG_LIBBACKTRACE ON CACHE BOOL + "Enable using libbacktrace for crashlogs.") +set(SRB2_CONFIG_LTO ON CACHE BOOL + "Enable link time optimizations, improves performance at the cost of longer link times.") +set(SRB2_CONFIG_ASAN OFF CACHE BOOL + "Compile with AddressSanitizer (libasan).") +set(SRB2_CONFIG_UBSAN OFF CACHE BOOL + "Compile with UndefinedBehaviorSanitizer (libubsan).") set(SRB2_CONFIG_SATURNPAK ON CACHE BOOL "Enable Saturn specific special packet. Required for using the newer resynch system") set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL "Enable Saturn specific allowjoin toggle.") - -set(SRB2_CONFIG_LIBBACKTRACE ON CACHE BOOL - "Enable using libbacktrace for crashlogs") +set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL + "Enable hardware renderer (OpenGL) FBO downsampling support") if(${SRB2_CONFIG_DEDICATED}) set(SRB2_CONFIG_HAVE_GME NO) @@ -502,7 +507,6 @@ if(${SRB2_CONFIG_LIBBACKTRACE}) if(${LIBBACKTRACE_FOUND}) set(SRB2_HAVE_LIBBACKTRACE ON) add_definitions(-DHAVE_LIBBACKTRACE) - add_compile_options(-g) else() message(WARNING "You have specified that libbacktrace is available but it was not found.") endif() @@ -550,7 +554,6 @@ if(${SRB2_CONFIG_HWRENDER}) set(SRB2_R_OPENGL_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.h ) - endif() if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL}) @@ -589,6 +592,14 @@ endif() # TODO: fix prng and P_CreateBlockmap overflow at some point add_compile_options(-fwrapv) +if (${CMAKE_BUILD_TYPE} MATCHES Debug) + add_compile_options(-O0) +else() + add_compile_options(-O3) +endif() + +add_compile_options(-g) + add_definitions(-DCMAKECONFIG) #add_library(SRB2Core STATIC diff --git a/src/dedicated/CMakeLists.txt b/src/dedicated/CMakeLists.txt index 84e36690f..38fb179f0 100644 --- a/src/dedicated/CMakeLists.txt +++ b/src/dedicated/CMakeLists.txt @@ -119,6 +119,20 @@ target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS ) +if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE) + set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) +endif() + +if(SRB2_CONFIG_ASAN) + target_compile_options(SRB2SDL2 PRIVATE -fsanitize=address) + target_link_options(SRB2SDL2 PRIVATE -fsanitize=address) +endif() + +if(SRB2_CONFIG_UBSAN) + target_compile_options(SRB2SDL2 PRIVATE -fsanitize=undefined) + target_link_options(SRB2SDL2 PRIVATE -fsanitize=undefined) +endif() + ## strip debug symbols into separate file when using gcc # if(CMAKE_COMPILER_IS_GNUCC) # if(${CMAKE_BUILD_TYPE} MATCHES Debug) diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index 1c7d52344..c7d612c80 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -169,7 +169,6 @@ if(${SDL2_FOUND}) target_link_libraries(SRB2SDL2 PRIVATE ${LIBBACKTRACE_LIBRARIES}) endif() - if(${CMAKE_SYSTEM} MATCHES Linux) target_link_libraries(SRB2SDL2 PRIVATE m @@ -230,6 +229,20 @@ if(${SDL2_FOUND}) -DHAVE_THREADS ) + if(SRB2_CONFIG_LTO AND NOT SRB2_CONFIG_DEBUGMODE) + set_property(TARGET SRB2SDL2 PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + endif() + + if(SRB2_CONFIG_ASAN) + target_compile_options(SRB2SDL2 PRIVATE -fsanitize=address) + target_link_options(SRB2SDL2 PRIVATE -fsanitize=address) + endif() + + if(SRB2_CONFIG_UBSAN) + target_compile_options(SRB2SDL2 PRIVATE -fsanitize=undefined) + target_link_options(SRB2SDL2 PRIVATE -fsanitize=undefined) + endif() + ## strip debug symbols into separate file when using gcc # if(CMAKE_COMPILER_IS_GNUCC) # if(${CMAKE_BUILD_TYPE} MATCHES Debug) @@ -296,7 +309,7 @@ if(${SDL2_FOUND}) else() find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}") list(APPEND win_extra_dll_list ${SRB2_SDL2_DLL_${dllname}}) - endif() + endif() endmacro() getwinlib(SDL2 "SDL2.dll") if(${SRB2_CONFIG_SDL2_USEMIXER}) From 522904527fd8173d61880da7cef4892d36ef4cb7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Jan 2026 10:08:35 +0100 Subject: [PATCH 123/589] add missing HAVE_CURL --- src/d_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index c5499fb57..90ff81cc9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -907,7 +907,9 @@ void D_ClearState(void) // okay, stop now // (otherwise the game still thinks we're playing!) +#ifdef HAVE_CURL CURLAbortFile(); +#endif SV_StopServer(); SV_ResetServer(); From 6c419ff22e569247e9d78ec2a9655da98120d588 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Jan 2026 18:33:08 +0100 Subject: [PATCH 124/589] fix few more implicit double/float conversions --- src/d_netcmd.c | 1 - src/hardware/hw_main.cpp | 2 +- src/m_cheat.c | 2 +- src/r_plane.cpp | 8 ++++---- src/r_portal.c | 1 - src/r_things.cpp | 4 ++-- src/sdl/mixer_sound.c | 2 +- src/v_video.c | 8 ++++---- 8 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 641a026fd..a92532a80 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2655,7 +2655,6 @@ static void Command_Map_f(void) return; } - last_map_cmd = I_GetTime(); size_t first_option; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 24d3af8ae..5cc8eacf7 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5444,7 +5444,7 @@ static void HWR_SetTransformAiming(FTransform *trans) fixed_t fixedaiming = AIMINGTODY(aimingangle); trans->viewaiming = FixedToFloat(fixedaiming) * (static_cast(vid.width) / static_cast(vid.height)) / (static_cast(BASEVIDWIDTH) / static_cast(BASEVIDHEIGHT)); if (splitscreen == 1) // only for 2 player splitscreen - trans->viewaiming *= 2.125; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used) + trans->viewaiming *= 2.125f; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used) trans->shearing = true; gl_aimingangle = 0; } diff --git a/src/m_cheat.c b/src/m_cheat.c index 58bc1401d..8223f2250 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -301,7 +301,7 @@ void Command_CheatNoTarget_f(void) void Command_Scale_f(void) { const double scaled = atof(COM_Argv(1)); - fixed_t scale = FLOAT_TO_FIXED(scaled); + fixed_t scale = DoubleToFixed(scaled); REQUIRE_DEVMODE; REQUIRE_INLEVEL; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index b2d30185d..c4ba7b8f1 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -920,12 +920,12 @@ static void R_SetSlopePlane(drawspandata_t* ds, pslope_t *slope, fixed_t xpos, f // m is the v direction vector in view space ang = ANG2RAD(ANGLE_180 - (angle + plangle)); - m->x = cos(ang); - m->z = sin(ang); + m->x = cosf(ang); + m->z = sinf(ang); // n is the u direction vector in view space - n->x = sin(ang); - n->z = -cos(ang); + n->x = sinf(ang); + n->z = -cosf(ang); plangle >>= ANGLETOFINESHIFT; temp = P_GetSlopeZAt(slope, xpos + FINESINE(plangle), ypos + FINECOSINE(plangle)); diff --git a/src/r_portal.c b/src/r_portal.c index 661034a3f..d84a99be4 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -246,7 +246,6 @@ static boolean TrimVisplaneBounds(const visplane_t* plane, INT16* start, INT16* if (!(*start < *end)) return true; - /** Trims a visplane's horizontal gap to match its render area. * * Visplanes' minx/maxx may sometimes exceed the area they're diff --git a/src/r_things.cpp b/src/r_things.cpp index d1c856238..aaff015a3 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -489,8 +489,8 @@ void R_InitSprites(void) for (angle = 1; angle < ROTANGLES; angle++) { fa = ANG2RAD(FixedAngle((ROTANGDIFF * angle)< 255.0f) working[0][q] = 255.0f; else if (working[0][q] < 0.0f) - working[0][q] = 0.0; + working[0][q] = 0.0f; } #undef dolerp From bb47b976a71317302778500e32c8e80f53003a78 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Jan 2026 18:32:31 +0100 Subject: [PATCH 125/589] software: fix drawseg xrange item coord type being too small both sprite and drawseg coords are int32 might fix some clipping issues --- src/r_things.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index aaff015a3..2ced7cde2 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -70,7 +70,7 @@ INT16 *screenheightarray = NULL; typedef struct drawseg_xrange_item_s { - INT16 x1, x2; + INT32 x1, x2; drawseg_t *user; } drawseg_xrange_item_t; From c4581bd9a674beaa710402d50519061b3d262e11 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 24 Jan 2026 18:12:42 +0100 Subject: [PATCH 126/589] Only save and keep track of controller ids on SDL versions 2.32.4 and up Older versions break and have unstable ids on Windows, cant check for linux but ill just add a version check at this point This was part of updating sdl with v9, which got reverted due to other issues but this was not reverted oopsie --- src/sdl/i_system.cpp | 22 +++++++++++++++++++++- src/sdl/i_video.c | 12 ++++++++++++ src/sdl/sdlmain.h | 4 ++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 52a78232f..4dd32161e 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -726,7 +726,9 @@ static void JoyReset(SDLJoyInfo_t *JoySet) JoySet->dev = NULL; JoySet->oldjoy = -1; +#if (SDL_VERSION_ATLEAST(2,32,4)) JoySet->id = -1; +#endif } /** \brief SDL info about joystick @@ -783,7 +785,11 @@ void I_UpdateJoystickDeviceIndex(UINT8 player) /////////////////////////////////////////////// if (JoyInfo[player].dev) { +#if (SDL_VERSION_ATLEAST(2,32,4)) cv_usejoystick[player].value = JoyInfo[player].id + 1; +#else + cv_usejoystick[player].value = I_GetJoystickDeviceIndex(JoyInfo[player].dev) + 1; +#endif } else { @@ -939,7 +945,9 @@ static int joy_open(int playerIndex, int joyIndex) CONS_Debug(DBG_GAMELOGIC, "Joystick %d: %s\n", playerIndex+1, SDL_GameControllerName(JoyInfo[playerIndex].dev)); +#if (SDL_VERSION_ATLEAST(2,32,4)) JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev); +#endif return SDL_CONTROLLER_AXIS_MAX; } @@ -985,7 +993,9 @@ void I_InitJoystick(UINT8 index) JoyInfo[index].dev = NULL; JoyInfo[index].oldjoy = -1; +#if (SDL_VERSION_ATLEAST(2,32,4)) JoyInfo[index].id = -1; +#endif if (cv_usejoystick[index].value) newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1); @@ -999,17 +1009,27 @@ void I_InitJoystick(UINT8 index) break; } +#if (SDL_VERSION_ATLEAST(2,32,4)) JoyInfo[index].id = I_GetJoystickDeviceIndex(JoyInfo[index].dev); +#endif if (newcontroller && i < MAXSPLITSCREENPLAYERS) // don't override an active device { +#if (SDL_VERSION_ATLEAST(2,32,4)) cv_usejoystick[index].value = JoyInfo[index].id + 1; +#else + cv_usejoystick[index].value = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1; +#endif } else if (newcontroller && joy_open(index, cv_usejoystick[index].value) != -1) { +#if (SDL_VERSION_ATLEAST(2,32,4)) + JoyInfo[index].oldjoy = JoyInfo[index].id + 1; +#else // SDL's device indexes are unstable, so cv_usejoystick may not match // the actual device index. So let's cheat a bit and find the device's current index. - JoyInfo[index].oldjoy = JoyInfo[index].id + 1; + JoyInfo[index].oldjoy = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1; +#endif } else { diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 1c23af6cd..8b2adfa7b 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -784,7 +784,11 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt) // Determine the Joystick IDs for each current open joystick for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { +#if (SDL_VERSION_ATLEAST(2,32,4)) if (evt.which == JoyInfo[i].id) +#else + if (evt.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev))) +#endif { event.type = ev_joystick + i; break; @@ -844,7 +848,11 @@ static void Impl_HandleControllerHatEvent(SDL_ControllerButtonEvent evt, Uint32 // Determine the Joystick IDs for each current open joystick for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { +#if (SDL_VERSION_ATLEAST(2,32,4)) if (evt.which == JoyInfo[i].id) +#else + if (evt.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev))) +#endif { event.data1 = hat_buttons_base[i]; break; @@ -906,7 +914,11 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint // Determine the Joystick IDs for each current open joystick for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { +#if (SDL_VERSION_ATLEAST(2,32,4)) if (evt.which == JoyInfo[i].id) +#else + if (evt.which == SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev))) +#endif { event.data1 = buttons_base[i]; break; diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index f7f4c011c..11287fe55 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -23,6 +23,8 @@ extern "C" { #endif +#include "SDL_version.h" + #include "../m_fixed.h" // SDL2 stub macro @@ -39,8 +41,10 @@ typedef struct SDLJoyInfo_s { /// Controller handle SDL_GameController *dev; +#if (SDL_VERSION_ATLEAST(2,32,4)) /// Controller index INT32 id; +#endif /// number of old joystick int oldjoy; /// number of axies From 3e476d7658ed82ee22a6002f4d895e87bc62675c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Jan 2026 18:06:22 +0100 Subject: [PATCH 127/589] implement allowing to load addons and gamestate only instead of joining server really messy, needs some cleanup, not sure if this is good at all --- src/d_clisrv.c | 62 ++++++++++++++++++++++++++++++++++------------- src/d_clisrv.h | 2 ++ src/m_menu.c | 65 ++++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 99 insertions(+), 30 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 68ab08c5a..31c309c17 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -100,6 +100,10 @@ static int map_icon_request_count; // current count of icon requests sent static UINT8 *map_icon_data; static patch_t *map_icon; +// if true, signals the game to only load addons AND gamestate +// instead of fully joining a server +boolean addonsonly = false; + plrinfo playerinfo[MAXPLAYERS] = {}; SINT8 joinnode = 0; // used for CL_VIEWSERVER @@ -1438,6 +1442,7 @@ static void CL_DrawConnectionStatus(void) // Buttons V_DrawFill(8, BASEVIDHEIGHT - 14, BASEVIDWIDTH - 16, 12, 239); V_DrawThinString(16, BASEVIDHEIGHT - 12, V_ALLOWLOWERCASE, va("[%sESC%s] = Abort", "\x82", "\x80")); + V_DrawCenteredThinString(BASEVIDWIDTH/2, BASEVIDHEIGHT - 12, V_ALLOWLOWERCASE, va("[%sSPACE%s] = Load Addons", "\x82", "\x80")); V_DrawRightAlignedThinString(BASEVIDWIDTH - 12, BASEVIDHEIGHT - 12, V_ALLOWLOWERCASE, va("[%sENTER%s] = Join", "\x82", "\x80")); } else if (filedownload.current != -1) @@ -2579,7 +2584,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) return true; } - cl_mode = (cv_serverinfoscreen.value) ? CL_VIEWSERVER : CL_CHECKFILES; + cl_mode = (cv_serverinfoscreen.value && !addonsonly) ? CL_VIEWSERVER : CL_CHECKFILES; } else { @@ -2600,6 +2605,17 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) return true; } +static void FreeMapIcon(void) +{ + if (map_icon != NULL) + Patch_Free(map_icon); + map_icon = NULL; + if (map_icon_data != NULL) + Z_Free(map_icon_data); + map_icon_data = NULL; + map_icon_request_count = 0; +} + /** Called by CL_ConnectToServer * * \param tmpsave The name of the gamestate file??? @@ -2624,7 +2640,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic case CL_ASKFULLFILELIST: if (cl_lastcheckedfilecount == UINT16_MAX) // All files retrieved - cl_mode = (cv_serverinfoscreen.value) ? CL_VIEWSERVER : CL_CHECKFILES; + cl_mode = (cv_serverinfoscreen.value && !addonsonly) ? CL_VIEWSERVER : CL_CHECKFILES; else if (fileneedednum != cl_lastcheckedfilecount || I_GetTime() >= *asksent) { if (CL_AskFileList(fileneedednum)) @@ -2757,7 +2773,19 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic { // Gamestate is now handled within CL_LoadReceivedSavegame() CL_LoadReceivedSavegame(false); - cl_mode = CL_CONNECTED; + + if (addonsonly) + { + // close connection after savegame load + // we want the actual server state + // in case theres some stuff like records to be synched + cl_mode = CL_ABORTED; + } + else + { + cl_mode = CL_CONNECTED; + } + break; } // don't break case continue to CL_CONNECTED else @@ -2771,7 +2799,6 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic case CL_ABORTED: cl_mode = CL_SEARCHING; return false; - } GetPackets(); @@ -2793,24 +2820,20 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic { if (key == KEY_ENTER || key == KEY_JOY1) { + addonsonly = false; cl_mode = CL_CHECKFILES; - if (map_icon != NULL) - Patch_Free(map_icon); - map_icon = NULL; - if (map_icon_data != NULL) - Z_Free(map_icon_data); - map_icon_data = NULL; + FreeMapIcon(); } else if (key == KEY_ESCAPE || key == KEY_JOY1+1) { cl_mode = CL_ABORTED; - if (map_icon != NULL) - Patch_Free(map_icon); - map_icon = NULL; - if (map_icon_data != NULL) - Z_Free(map_icon_data); - map_icon_data = NULL; - map_icon_request_count = 0; + FreeMapIcon(); + } + else if (key == KEY_SPACE || key == KEY_JOY1+2) + { + addonsonly = true; + cl_mode = CL_CHECKFILES; + FreeMapIcon(); } } @@ -2819,6 +2842,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic { CONS_Printf(M_GetText("Network game synchronization aborted.\n")); CL_AbortConnection(); + addonsonly = false; return false; } @@ -3315,6 +3339,10 @@ static void Command_connect(void) CONS_Alert(CONS_ERROR, M_GetText("There is no network driver\n")); } + // idk how that shit works + //if (*COM_Argv(3) && fasticmp(COM_Argv(3), "-addonsonly")) + //addonsonly = true; + CV_Set(&cv_lastserver, I_GetNodeAddress(servernode)); if (splitscreen != cv_splitplayers.value-1) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 430729bc2..13a8470dc 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -552,6 +552,8 @@ typedef enum KR_LEAVE, //Quit the game } kickreason_t; +extern boolean addonsonly; + /* the max number of name changes in some time period */ #define MAXNAMECHANGES (5) #define NAMECHANGERATE (60*TICRATE) diff --git a/src/m_menu.c b/src/m_menu.c index a98a230d5..a0c501af8 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -186,8 +186,8 @@ static INT16 itemOn = 1; // menu item skull is on, Hack by Tails 09-18-2002 static INT16 skullAnimCounter = 10; // skull animation counter static boolean interpTimerHackAllow = 0; -static UINT8 setupcontrolplayer; -static INT32 (*setupcontrols)[2]; // pointer to the gamecontrols of the player being edited +static UINT8 setupcontrolplayer; +static INT32 (*setupcontrols)[2]; // pointer to the gamecontrols of the player being edited // shhh... what am I doing... nooooo! static INT32 vidm_testingmode = 0; @@ -201,8 +201,8 @@ static char setupm_ip[64]; static textinput_t setupm_input_ip; -static fixed_t multi_tics; -static state_t *multi_state; +static fixed_t multi_tics; +static state_t *multi_state; // this is set before entering the MultiPlayer setup menu, // for either player 1 or 2 @@ -1024,9 +1024,9 @@ boolean M_Responder(event_t *ev) //case KEY_JOY1 + 2: ch = KEY_ENTER; break; - /*case KEY_JOY1 + 3: // Brake can function as 'n' for message boxes now. - ch = 'n'; - break;*/ + /*case KEY_JOY1 + 3: // Brake can function as 'n' for message boxes now. + ch = 'n'; + break;*/ case KEY_MOUSE1 + 1: //case KEY_JOY1 + 1: ch = KEY_BACKSPACE; @@ -1250,6 +1250,20 @@ boolean M_Responder(event_t *ev) routine = currentMenu->menuitems[itemOn].itemaction; + // really hacky but the whole menu system sucks so + // allows to just load addons and gamestate instead of joining + if (currentMenu == &MP_ConnectDef && + (routine && routine == M_Connect) && + (ch == gamecontrol[0][gc_lookback][0] || + ch == gamecontrol[0][gc_lookback][1])) + { + addonsonly = true; + noFurtherInput = true; + currentMenu->lastOn = itemOn; + routine(itemOn); + return true; + } + // Handle menuitems which need a specific key handling if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER) { @@ -1305,12 +1319,21 @@ boolean M_Responder(event_t *ev) { playback_last_menu_interaction_leveltime = leveltime; // Flip left/right with up/down for the playback menu, since it's a horizontal icon row. + switch (ch) { - case KEY_LEFTARROW: ch = KEY_UPARROW; break; - case KEY_UPARROW: ch = KEY_RIGHTARROW; break; - case KEY_RIGHTARROW: ch = KEY_DOWNARROW; break; - case KEY_DOWNARROW: ch = KEY_LEFTARROW; break; + case KEY_LEFTARROW: + ch = KEY_UPARROW; + break; + case KEY_UPARROW: + ch = KEY_RIGHTARROW; + break; + case KEY_RIGHTARROW: + ch = KEY_DOWNARROW; + break; + case KEY_DOWNARROW: + ch = KEY_LEFTARROW; + break; // arbitrary keyboard shortcuts because fuck you @@ -1361,7 +1384,8 @@ boolean M_Responder(event_t *ev) G_AdjustView(4, 1, true); break; - default: break; + default: + break; } } @@ -1486,6 +1510,7 @@ boolean M_Responder(event_t *ev) } return false; + break; default: CON_Responder(ev); @@ -7059,6 +7084,21 @@ static void M_DrawConnectMenu(void) M_DrawServerLines(currentMenu->x, serverlistpage); } + // copy pasted this abomination from encore toggle + if (itemOn > mp_connect_search) + { + char addontoggle[32] = {0}; + const char *item1 = gamecontrol[0][gc_lookback][0] != 0 ? G_KeynumToString(gamecontrol[0][gc_lookback][0]) : NULL; + const char *item2 = gamecontrol[0][gc_lookback][1] != 0 ? G_KeynumToString(gamecontrol[0][gc_lookback][1]) : NULL; + + if (item1 != NULL && item2 != NULL) + snprintf(addontoggle, 32, "%s/%s - Load Addons Only", item1, item2); + else + snprintf(addontoggle, 32, "%s - Load Addons Only", item1 != NULL ? item1 : item2 != NULL ? item2 : "Lookback"); + + V_DrawThinString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_TRANSLUCENT|V_ALLOWLOWERCASE, addontoggle); + } + INT32 input_y = currentMenu->menuitems[mp_connect_search].alphaKey; V_DrawFill(currentMenu->x, currentMenu->y+input_y, MAXSTRINGLENGTH*8+6, 8+6, 239); @@ -10046,7 +10086,6 @@ static void M_DrawVideoMode(void) va("Wait %d second%s", testtime, (testtime > 1) ? "s" : "")); M_CentreText(OP_VideoModeDef.y + 158, "or press ESC to return"); - } else { From f12b55f63bad96e2b288ce4dfa0170da0d17b899 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Jan 2026 18:08:12 +0100 Subject: [PATCH 128/589] rename addonsonly variable to cl_addonsonly very generic name so add the prefix for whatever cl means --- src/d_clisrv.c | 17 +++++++++-------- src/d_clisrv.h | 2 +- src/m_menu.c | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 31c309c17..3bc5428b4 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -102,7 +102,7 @@ static patch_t *map_icon; // if true, signals the game to only load addons AND gamestate // instead of fully joining a server -boolean addonsonly = false; +boolean cl_addonsonly = false; plrinfo playerinfo[MAXPLAYERS] = {}; SINT8 joinnode = 0; // used for CL_VIEWSERVER @@ -2584,7 +2584,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) return true; } - cl_mode = (cv_serverinfoscreen.value && !addonsonly) ? CL_VIEWSERVER : CL_CHECKFILES; + cl_mode = (cv_serverinfoscreen.value && !cl_addonsonly) ? CL_VIEWSERVER : CL_CHECKFILES; } else { @@ -2640,7 +2640,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic case CL_ASKFULLFILELIST: if (cl_lastcheckedfilecount == UINT16_MAX) // All files retrieved - cl_mode = (cv_serverinfoscreen.value && !addonsonly) ? CL_VIEWSERVER : CL_CHECKFILES; + cl_mode = (cv_serverinfoscreen.value && !cl_addonsonly) ? CL_VIEWSERVER : CL_CHECKFILES; else if (fileneedednum != cl_lastcheckedfilecount || I_GetTime() >= *asksent) { if (CL_AskFileList(fileneedednum)) @@ -2774,7 +2774,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic // Gamestate is now handled within CL_LoadReceivedSavegame() CL_LoadReceivedSavegame(false); - if (addonsonly) + if (cl_addonsonly) { // close connection after savegame load // we want the actual server state @@ -2820,18 +2820,19 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic { if (key == KEY_ENTER || key == KEY_JOY1) { - addonsonly = false; + cl_addonsonly = false; cl_mode = CL_CHECKFILES; FreeMapIcon(); } else if (key == KEY_ESCAPE || key == KEY_JOY1+1) { cl_mode = CL_ABORTED; + cl_addonsonly = false; FreeMapIcon(); } else if (key == KEY_SPACE || key == KEY_JOY1+2) { - addonsonly = true; + cl_addonsonly = true; cl_mode = CL_CHECKFILES; FreeMapIcon(); } @@ -2842,7 +2843,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic { CONS_Printf(M_GetText("Network game synchronization aborted.\n")); CL_AbortConnection(); - addonsonly = false; + cl_addonsonly = false; return false; } @@ -3341,7 +3342,7 @@ static void Command_connect(void) // idk how that shit works //if (*COM_Argv(3) && fasticmp(COM_Argv(3), "-addonsonly")) - //addonsonly = true; + //cl_addonsonly = true; CV_Set(&cv_lastserver, I_GetNodeAddress(servernode)); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 13a8470dc..a4466fbc3 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -552,7 +552,7 @@ typedef enum KR_LEAVE, //Quit the game } kickreason_t; -extern boolean addonsonly; +extern boolean cl_addonsonly; /* the max number of name changes in some time period */ #define MAXNAMECHANGES (5) diff --git a/src/m_menu.c b/src/m_menu.c index a0c501af8..378aec970 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1257,7 +1257,7 @@ boolean M_Responder(event_t *ev) (ch == gamecontrol[0][gc_lookback][0] || ch == gamecontrol[0][gc_lookback][1])) { - addonsonly = true; + cl_addonsonly = true; noFurtherInput = true; currentMenu->lastOn = itemOn; routine(itemOn); From 00bc8bc149e2523f68b3b06a1a9028a839e7cf2b Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 27 Jan 2026 18:23:44 +0100 Subject: [PATCH 129/589] limit addon only stuff to server info screen quite honestly everything else is awful and i dont want to bother with it --- src/d_clisrv.c | 10 +++------- src/d_clisrv.h | 2 -- src/m_menu.c | 29 ----------------------------- 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3bc5428b4..09a9f85c7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -102,7 +102,7 @@ static patch_t *map_icon; // if true, signals the game to only load addons AND gamestate // instead of fully joining a server -boolean cl_addonsonly = false; +static boolean cl_addonsonly = false; plrinfo playerinfo[MAXPLAYERS] = {}; SINT8 joinnode = 0; // used for CL_VIEWSERVER @@ -2584,7 +2584,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) return true; } - cl_mode = (cv_serverinfoscreen.value && !cl_addonsonly) ? CL_VIEWSERVER : CL_CHECKFILES; + cl_mode = cv_serverinfoscreen.value ? CL_VIEWSERVER : CL_CHECKFILES; } else { @@ -2640,7 +2640,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic case CL_ASKFULLFILELIST: if (cl_lastcheckedfilecount == UINT16_MAX) // All files retrieved - cl_mode = (cv_serverinfoscreen.value && !cl_addonsonly) ? CL_VIEWSERVER : CL_CHECKFILES; + cl_mode = cv_serverinfoscreen.value ? CL_VIEWSERVER : CL_CHECKFILES; else if (fileneedednum != cl_lastcheckedfilecount || I_GetTime() >= *asksent) { if (CL_AskFileList(fileneedednum)) @@ -3340,10 +3340,6 @@ static void Command_connect(void) CONS_Alert(CONS_ERROR, M_GetText("There is no network driver\n")); } - // idk how that shit works - //if (*COM_Argv(3) && fasticmp(COM_Argv(3), "-addonsonly")) - //cl_addonsonly = true; - CV_Set(&cv_lastserver, I_GetNodeAddress(servernode)); if (splitscreen != cv_splitplayers.value-1) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index a4466fbc3..430729bc2 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -552,8 +552,6 @@ typedef enum KR_LEAVE, //Quit the game } kickreason_t; -extern boolean cl_addonsonly; - /* the max number of name changes in some time period */ #define MAXNAMECHANGES (5) #define NAMECHANGERATE (60*TICRATE) diff --git a/src/m_menu.c b/src/m_menu.c index 378aec970..134c89739 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1250,20 +1250,6 @@ boolean M_Responder(event_t *ev) routine = currentMenu->menuitems[itemOn].itemaction; - // really hacky but the whole menu system sucks so - // allows to just load addons and gamestate instead of joining - if (currentMenu == &MP_ConnectDef && - (routine && routine == M_Connect) && - (ch == gamecontrol[0][gc_lookback][0] || - ch == gamecontrol[0][gc_lookback][1])) - { - cl_addonsonly = true; - noFurtherInput = true; - currentMenu->lastOn = itemOn; - routine(itemOn); - return true; - } - // Handle menuitems which need a specific key handling if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER) { @@ -7084,21 +7070,6 @@ static void M_DrawConnectMenu(void) M_DrawServerLines(currentMenu->x, serverlistpage); } - // copy pasted this abomination from encore toggle - if (itemOn > mp_connect_search) - { - char addontoggle[32] = {0}; - const char *item1 = gamecontrol[0][gc_lookback][0] != 0 ? G_KeynumToString(gamecontrol[0][gc_lookback][0]) : NULL; - const char *item2 = gamecontrol[0][gc_lookback][1] != 0 ? G_KeynumToString(gamecontrol[0][gc_lookback][1]) : NULL; - - if (item1 != NULL && item2 != NULL) - snprintf(addontoggle, 32, "%s/%s - Load Addons Only", item1, item2); - else - snprintf(addontoggle, 32, "%s - Load Addons Only", item1 != NULL ? item1 : item2 != NULL ? item2 : "Lookback"); - - V_DrawThinString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_TRANSLUCENT|V_ALLOWLOWERCASE, addontoggle); - } - INT32 input_y = currentMenu->menuitems[mp_connect_search].alphaKey; V_DrawFill(currentMenu->x, currentMenu->y+input_y, MAXSTRINGLENGTH*8+6, 8+6, 239); From 7a279a6fd9f0e3cb69c3d73bc408420c38a43301 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 28 Jan 2026 19:19:02 +0300 Subject: [PATCH 130/589] Prefix autoaccel cvars with 'kart' to avoid conflict with hostmod --- src/g_game.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 27a2922a8..94aaeb016 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -456,10 +456,10 @@ consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS] = { //static CV_PossibleValue_t autoaccelcons_t[] = {{0, "Off"}, {1, "Manual"}, {2, "Automatic"}, {0, NULL}}; consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS] = { - {"autoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"autoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"autoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"autoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} + {"kartautoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"kartautoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"kartautoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"kartautoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} }; static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}}; From 3122c080391401a301f291539c1b7c173b933b67 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 1 Feb 2026 02:48:29 +0300 Subject: [PATCH 131/589] Add focus options for gamepad led and rumble --- src/d_netcmd.c | 3 +++ src/g_input.c | 7 +++++-- src/g_input.h | 3 +++ src/m_menudefs.c | 6 ++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a92532a80..6ecc670d1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1009,6 +1009,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_gamepadled[i]); } + CV_RegisterVar(&cv_gamepadledifunfocused); + CV_RegisterVar(&cv_rumbleifunfocused); + CV_RegisterVar(&cv_usemouse); CV_RegisterVar(&cv_invertmouse); CV_RegisterVar(&cv_mousexsens); diff --git a/src/g_input.c b/src/g_input.c index 1a420c996..d44edd6dc 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -81,6 +81,9 @@ consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = { {"gamepadled4", "Skincolor", CV_SAVE|CV_CALL|CV_NOINIT, gamepadled_cons_t, led_off_handle4, 0, NULL, NULL, 0, 0, NULL} }; +consvar_t cv_gamepadledifunfocused = {"gamepadledunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_rumbleifunfocused = {"rumbleifunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + static void rumble_off_handle(void) { if (!cv_rumble[0].value) @@ -930,7 +933,7 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color) I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); - if (cv_gamepadled[playernum].value == 0 + if (cv_gamepadled[playernum].value == 0 || (window_notinfocus && cv_gamepadledifunfocused.value == 0) || color >= MAXTRANSLATIONS) { return; @@ -1009,7 +1012,7 @@ void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_stre { I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); - if (cv_rumble[playernum].value == 0) + if (cv_rumble[playernum].value == 0 || (window_notinfocus && cv_rumbleifunfocused.value == 0)) { return; } diff --git a/src/g_input.h b/src/g_input.h index 9831e6d8f..154f0805d 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -116,6 +116,9 @@ extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_gamepadledifunfocused; +extern consvar_t cv_rumbleifunfocused; + extern INT32 mousex, mousey; extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET]; diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 0c4aef0d4..1a21ec455 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1205,6 +1205,10 @@ static menuitem_t OP_FocusOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 100}, {IT_STRING|IT_CVAR, NULL, "Visible Mouse", &cv_mousevisible, 120}, + + {IT_STRING|IT_CVAR, NULL, "Gamepad LED Color While Unfocused ", &cv_gamepadledifunfocused, 140}, + {IT_STRING|IT_CVAR, NULL, "Gamepad Rumble While Unfocused", &cv_rumbleifunfocused, 150}, + }; static const char* OP_FocusOptionsTooltips[] = @@ -1216,6 +1220,8 @@ static const char* OP_FocusOptionsTooltips[] = "Set manual framerate cap while the game is unfocused.", "Should the FOCUS LOST window appear\n while the game is unfocused?", "Displays the mouse cursor while the game is in focus.", + "Should gamepad LED indicator change color when unfocused?", + "Should gamepad rumble apply when unfocused?", }; static menuitem_t OP_DataOptionsMenu[] = From 0ca6947f99070b66b3a10cf5b3c1bf25dcae3a31 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Feb 2026 16:27:16 +0100 Subject: [PATCH 132/589] fix a few type issues --- src/hardware/hw_md2.c | 2 +- src/r_plane.cpp | 2 +- src/r_segs.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 0a79ba6ec..56082e0fc 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -579,7 +579,7 @@ md2found: fclose(f); } -void HWR_AddPlayerMD2(int skin, boolean local) // For MD2's that were added after startup +void HWR_AddPlayerMD2(INT32 skin, boolean local) // For MD2's that were added after startup { FILE *f; char name[20], filename[32]; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index c4ba7b8f1..78375b8b6 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -136,7 +136,7 @@ void R_AllocPlaneMemory(void) } yslopetab = static_cast(Z_Realloc(yslopetab, sizeof(*yslopetab) * (viewheight * 16), PU_STATIC, NULL)); - spanstart = static_cast(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL)); + spanstart = static_cast(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL)); } // diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 6751befc9..660b91494 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -2880,7 +2880,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (markceiling) { if (ceilingplane) //SoM: 3/29/2000: Check for null ceiling planes - ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1); + ceilingplane = R_CheckPlane(ceilingplane, rw_x, rw_stopx-1); else markceiling = false; @@ -2894,7 +2894,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (markfloor) { if (floorplane) //SoM: 3/29/2000: Check for null planes - floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1); + floorplane = R_CheckPlane(floorplane, rw_x, rw_stopx-1); else markfloor = false; From 544e1d3b21cad200aee1b03f636ec17cb744437c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Feb 2026 17:07:10 +0100 Subject: [PATCH 133/589] "fix" overflow in R_InitViewMapping with high resolutions --- src/r_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index e3bfb83fa..5fb224167 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1018,8 +1018,8 @@ static void R_InitViewMapping(void) for (INT32 i = 0; i < j; i++) { - fixed_t dy = (i - viewheight*8)< Date: Sun, 1 Feb 2026 18:25:03 +0100 Subject: [PATCH 134/589] r_plane: fix visplane hashing overflowing shift into "int" to prevent super large values during multiply --- src/r_plane.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 78375b8b6..05c4d943a 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -57,8 +57,11 @@ visffloor_t visffloor[MAXFFLOORS] = {}; INT32 numffloors = 0; //SoM: 3/23/2000: Boom visplane hashing routine. -#define visplane_hash(picnum,lightlevel,height) \ - ((unsigned)((picnum)*3+(lightlevel)+(height)*7) & VISPLANEHASHMASK) +constexpr unsigned int visplane_hash(const unsigned int picnum, const unsigned int lightlevel, + const unsigned int height) +{ + return ((picnum * 3) + lightlevel + (height * 7)) & VISPLANEHASHMASK; +} // // Clip values are the solid pixel bounding the range. @@ -451,7 +454,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, } } - hash = visplane_hash(picnum, lightlevel, height); + hash = visplane_hash(picnum, lightlevel, height >> FRACBITS); for (check = visplanes[hash]; check; check = check->next) { @@ -562,7 +565,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop) } else { - unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height); + unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height >> FRACBITS); new_pl = new_visplane(hash); } From b23154fd938d7ace4a6c6c48da319b8be9d8542c Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 2 Feb 2026 02:28:27 +0300 Subject: [PATCH 135/589] Prevent replays menu scoll bar from disappearing --- 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 a98a230d5..cfbfea7c5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4719,7 +4719,7 @@ static void M_DrawReplayHut(void) if (y > scaledviewheight-80) { V_DrawFill(BASEVIDWIDTH-4, 75, 4, scaledviewheight-80, V_SNAPTOTOP|V_SNAPTORIGHT|239); - V_DrawFill(BASEVIDWIDTH-3, 76 + (scaledviewheight-80) * replayhutmenuy / y, 2, (((scaledviewheight-80) * (scaledviewheight-80))-1) / y - 1, V_SNAPTOTOP|V_SNAPTORIGHT|229); + V_DrawFill(BASEVIDWIDTH-3, 76 + (scaledviewheight-80) * replayhutmenuy / y, 2, max((((scaledviewheight-80) * (scaledviewheight-80))-1) / y - 1, 1), V_SNAPTOTOP|V_SNAPTORIGHT|229); } // Draw the cursor From 10b9d96259a4283b55ac4def4fdb44ed62ca2d82 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Feb 2026 16:10:15 +0100 Subject: [PATCH 136/589] hw_clip: replace "RoundToInt" with lrint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit prefer to use standard lib functions if possible lrint does the same thing (well ofc as long as no one touches the rounding direction löl) and is even quite a lot faster (though this is negligible in this case) --- src/hardware/hw_clip.c | 2 +- src/m_fixed.h | 29 ----------------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 3f9536436..6790823f2 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -335,7 +335,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle) floatangle = 2.0 + (45.0 + ((double)tilt / 1.9)) * clipfov / 90.0; if (floatangle >= 180.0) return 0xffffffff; - a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle); + a1 = (angle_t)lrint(ANG1 * floatangle); return a1; } diff --git a/src/m_fixed.h b/src/m_fixed.h index c0afae941..894e2b1cc 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -265,35 +265,6 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x) return INT32_MAX; } -/** \brief The xs_CRoundToInt function - - \param val double number - - \return Round toward nearest, but ties round toward even -*/ -#if defined(SRB2_BIG_ENDIAN) - #define _xs_iexp_ 0 - #define _xs_iman_ 1 -#else - #define _xs_iexp_ 1 //intel is little endian - #define _xs_iman_ 0 -#endif //BigEndian_ - -typedef double real64; - -typedef union _xs_doubleints -{ - real64 val; - unsigned ival[2]; -} _xs_doubleints; - -FUNCMATH FUNCINLINE static ATTRINLINE int xs_CRoundToInt(real64 val) -{ - _xs_doubleints uval; - uval.val = val + 6755399441055744.0; - return uval.ival[_xs_iman_]; -} - typedef struct { fixed_t x; From e4dbf1ce114334ad998fb3d4c95ca51a12e79c54 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Feb 2026 16:11:41 +0100 Subject: [PATCH 137/589] plug a potential memory leak in M_SaveConfig --- src/hu_stuff.c | 15 +++++++++++---- src/m_misc.c | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 6cca391e9..21143ed76 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1484,6 +1484,7 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string) x = 0; } } + return newstring; } @@ -1522,7 +1523,7 @@ static void HU_drawMiniChat(void) emote_t *emote = NULL; int emotelen = 0; - while(msg[j]) // iterate through msg + while (msg[j]) // iterate through msg { if (msg[j] < HU_FONTSTART) // don't draw { @@ -1554,14 +1555,17 @@ static void HU_drawMiniChat(void) { j++; } + prev_linereturn = false; dx += charwidth; + if (dx >= boxw) { dx = 0; linescount += 1; } } + dy = 0; dx = 0; msglines += linescount+1; @@ -1598,7 +1602,7 @@ static void HU_drawMiniChat(void) emote_t *emote = NULL; int emotelen = 0; - while(msg[j]) // iterate through msg + while (msg[j]) // iterate through msg { if (msg[j] < HU_FONTSTART) // don't draw { @@ -1643,12 +1647,14 @@ static void HU_drawMiniChat(void) dx += charwidth; prev_linereturn = false; + if (dx >= boxw) { dx = 0; dy += charheight; } } + dy += charheight; dx = 0; if (msg) @@ -1704,7 +1710,7 @@ static void HU_drawChatLog(INT32 offset) V_DrawFillConsoleMap(chatx, chat_topy, boxw, boxh*charheight +2, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); // log box - for (i=0; i Date: Sun, 1 Feb 2026 21:49:49 +0100 Subject: [PATCH 138/589] delet all the Z_Free checks Z_Free already checks its input internally! --- src/f_finale.c | 4 +--- src/filesrch.c | 14 ++++++-------- src/g_game.c | 7 ++----- src/hu_stuff.c | 12 ++++-------- src/i_tcp.c | 14 ++++---------- src/k_stats.c | 3 +-- src/lua_hudlib_drawlist.c | 15 +++------------ src/m_anigif.c | 9 +++------ src/m_cond.c | 9 +++------ src/m_menu.c | 13 +++++++++---- src/p_setup.c | 4 +--- src/p_spec.c | 3 +-- src/r_data.c | 3 +-- src/r_main.cpp | 16 ++++++---------- src/r_patch.cpp | 6 ++---- src/r_things.cpp | 2 +- src/v_video.c | 4 +--- src/w_wad.c | 7 +++---- src/z_zone.h | 2 +- 19 files changed, 53 insertions(+), 94 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 32ed8c3ec..f7efbbced 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1172,9 +1172,7 @@ void F_StartWaitingPlayers(void) randskin = M_RandomKey(numskins); boolean waithires = skins[randskin].flags && SF_HIRES; - if (waitcolormap) - Z_Free(waitcolormap); - + Z_Free(waitcolormap); waitcolormap = R_GetTranslationColormap(randskin, skins[randskin].prefcolor, 0); if (waithires) diff --git a/src/filesrch.c b/src/filesrch.c index e34b51c47..0ba117a1e 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -317,8 +317,7 @@ void closefilemenu(boolean validsize) coredirmenu = NULL; } - if (refreshdirname) - Z_Free(refreshdirname); + Z_Free(refreshdirname); refreshdirname = NULL; } @@ -346,8 +345,7 @@ void searchfilemenu(char *tempname) if (!menusearch.length) { - if (dirmenu) - Z_Free(dirmenu); + Z_Free(dirmenu); dirmenu = coredirmenu; sizedirmenu = sizecoredirmenu; @@ -389,8 +387,8 @@ void searchfilemenu(char *tempname) I_Error("searchfilemenu(): could not create \"No results...\"."); sizedirmenu = 1; dir_on[menudepthleft] = 0; - if (tempname) - Z_Free(tempname); + Z_Free(tempname); + return; } @@ -505,8 +503,8 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut) { closedir(dirhandle); closefilemenu(false); - if (tempname) - Z_Free(tempname); + Z_Free(tempname); + return false; } diff --git a/src/g_game.c b/src/g_game.c index 94aaeb016..a79a957ef 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -523,11 +523,8 @@ void G_ClearRecords(void) INT16 i; for (i = 0; i < NUMMAPS; ++i) { - if (mainrecords[i]) - { - Z_Free(mainrecords[i]); - mainrecords[i] = NULL; - } + Z_Free(mainrecords[i]); + mainrecords[i] = NULL; } } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 21143ed76..653529bf4 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1072,8 +1072,7 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum) HU_AddChatText(va(fmt2, prefix, cstart, dispname, textcolor, msg), cv_chatnotifications.value); // add to chat - if (tempchar) - Z_Free(tempchar); + Z_Free(tempchar); } #ifdef _DEBUG // I just want to point out while I'm here that because the data is still @@ -1569,8 +1568,7 @@ static void HU_drawMiniChat(void) dy = 0; dx = 0; msglines += linescount+1; - if (msg) - Z_Free(msg); + Z_Free(msg); } y = chaty - charheight*(msglines+1); @@ -1657,8 +1655,7 @@ static void HU_drawMiniChat(void) dy += charheight; dx = 0; - if (msg) - Z_Free(msg); + Z_Free(msg); } // decrement addy and make that shit smooth: @@ -1767,8 +1764,7 @@ static void HU_drawChatLog(INT32 offset) dy += charheight; dx = 0; - if (msg) - Z_Free(msg); + Z_Free(msg); } if (((chat_scroll >= chat_maxscroll) || (chat_scrollmedown)) && !(justscrolleddown || justscrolledup || chat_scrolltime)) // was already at the bottom of the page before new maxscroll calculation and was NOT scrolling. diff --git a/src/i_tcp.c b/src/i_tcp.c index 982b327d0..5b9b0237d 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1510,11 +1510,8 @@ static boolean SOCK_SetBanUsername(const char *username) username = "Direct IP ban"; } - if (banned[numbans - 1].username) - { - Z_Free(banned[numbans - 1].username); - banned[numbans - 1].username = NULL; - } + Z_Free(banned[numbans - 1].username); + banned[numbans - 1].username = NULL; banned[numbans - 1].username = Z_StrDup(username); @@ -1528,11 +1525,8 @@ static boolean SOCK_SetBanReason(const char *reason) reason = "No reason given"; } - if (banned[numbans - 1].reason) - { - Z_Free(banned[numbans - 1].reason); - banned[numbans - 1].reason = NULL; - } + Z_Free(banned[numbans - 1].reason); + banned[numbans - 1].reason = NULL; banned[numbans - 1].reason = Z_StrDup(reason); diff --git a/src/k_stats.c b/src/k_stats.c index f4fac90d3..5675462fd 100644 --- a/src/k_stats.c +++ b/src/k_stats.c @@ -99,8 +99,7 @@ void K_EraseStats(void) // The only field we want to remember boolean vanilla = kartstats.vanilla; - if (kartstats.copy) - Z_Free(kartstats.copy); + Z_Free(kartstats.copy); memset(&kartstats, 0, sizeof(kartstats_t)); diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index f267c5fe3..6d3542c48 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -136,18 +136,9 @@ void LUA_HUD_DestroyDrawList(huddrawlist_h list) { if (list == NULL) return; - if (list->items) - { - Z_Free(list->items); - } - if (list->olditems) - { - Z_Free(list->olditems); - } - if (list->strbuf) - { - Z_Free(list->strbuf); - } + Z_Free(list->items); + Z_Free(list->olditems); + Z_Free(list->strbuf); Z_Free(list); } diff --git a/src/m_anigif.c b/src/m_anigif.c index a8cc21bcf..cd37b08d6 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -695,16 +695,13 @@ INT32 GIF_close(void) fclose(gif_out); gif_out = NULL; - if (gifbwr_buf) - Z_Free(gifbwr_buf); + Z_Free(gifbwr_buf); gifbwr_buf = gifbwr_cur = NULL; - if (gifframe_data) - Z_Free(gifframe_data); + Z_Free(gifframe_data); gifframe_data = NULL; - if (giflzw_hashTable) - Z_Free(giflzw_hashTable); + Z_Free(giflzw_hashTable); giflzw_hashTable = NULL; Z_Free(scrbuf_screens); diff --git a/src/m_cond.c b/src/m_cond.c index 126d5a49a..c22c966f3 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -248,12 +248,9 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1 void M_ClearConditionSet(UINT8 set) { - if (conditionSets[set - 1].numconditions) - { - Z_Free(conditionSets[set - 1].condition); - conditionSets[set - 1].condition = NULL; - conditionSets[set - 1].numconditions = 0; - } + Z_Free(conditionSets[set - 1].condition); + conditionSets[set - 1].condition = NULL; + conditionSets[set - 1].numconditions = 0; conditionSets[set - 1].achieved = false; } diff --git a/src/m_menu.c b/src/m_menu.c index cfbfea7c5..f4271de1a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6560,17 +6560,22 @@ static void M_EraseGuest(INT32 choice) static void M_OverwriteGuest(const char *which) { - char *rguest = Z_StrDup(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value))); + char *rguest; UINT8 *buf; size_t len; len = FIL_ReadFile(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), cv_chooseskin.string, which), &buf); - if (!len) { + + if (!len) return; - } - if (FIL_FileExists(rguest)) { + + rguest = Z_StrDup(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value))); + + if (FIL_FileExists(rguest)) + { M_StopMessage(0); remove(rguest); } + FIL_WriteFile(rguest, buf, len); Z_Free(rguest); diff --git a/src/p_setup.c b/src/p_setup.c index 612530882..c9aba324a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -320,9 +320,7 @@ void P_AddGradesForMare(INT16 i, UINT8 mare, char *gtext) */ void P_DeleteGrades(INT16 i) { - if (mapheaderinfo[i]->grades) - Z_Free(mapheaderinfo[i]->grades); - + Z_Free(mapheaderinfo[i]->grades); mapheaderinfo[i]->grades = NULL; mapheaderinfo[i]->numGradedMares = 0; } diff --git a/src/p_spec.c b/src/p_spec.c index 5045a8287..b313f77a1 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6221,8 +6221,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) // Allocate each list for (i = 0; i < numsectors; i++) - if(secthinkers[i].thinkers) - Z_Free(secthinkers[i].thinkers); + Z_Free(secthinkers[i].thinkers); Z_Free(secthinkers); diff --git a/src/r_data.c b/src/r_data.c index 386f0e700..911413bb4 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1720,8 +1720,7 @@ void R_InitData(void) void R_ClearTextureNumCache(boolean btell) { - if (tidcache) - Z_Free(tidcache); + Z_Free(tidcache); tidcache = NULL; if (btell) CONS_Debug(DBG_SETUP, "Fun Fact: There are %d textures used in this map.\n", tidcachelen); diff --git a/src/r_main.cpp b/src/r_main.cpp index 5fb224167..430a7cd32 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -925,11 +925,11 @@ void R_ExecuteSetViewSize(void) viewheight = vid.height; if (splitscreen) + { viewheight >>= 1; - if (splitscreen > 1) - { - viewwidth >>= 1; + if (splitscreen > 1) + viewwidth >>= 1; } centerx = viewwidth/2; @@ -956,13 +956,9 @@ void R_ExecuteSetViewSize(void) screenheightarray[i] = (INT16)viewheight; } - if (ds_su) - Z_Free(ds_su); - if (ds_sv) - Z_Free(ds_sv); - if (ds_sz) - Z_Free(ds_sz); - + Z_Free(ds_su); + Z_Free(ds_sv); + Z_Free(ds_sz); ds_su = ds_sv = ds_sz = NULL; memset(scalelight, 0xFF, sizeof(scalelight)); diff --git a/src/r_patch.cpp b/src/r_patch.cpp index 60d4acb98..bca733c8b 100644 --- a/src/r_patch.cpp +++ b/src/r_patch.cpp @@ -405,10 +405,8 @@ static void Patch_FreeData(patch_t *patch) }*/ #endif - if (patch->columnofs) - Z_Free(patch->columnofs); - if (patch->columns) - Z_Free(patch->columns); + Z_Free(patch->columnofs); + Z_Free(patch->columns); } void Patch_Free(patch_t *patch) diff --git a/src/r_things.cpp b/src/r_things.cpp index 2ced7cde2..58a838eea 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -391,7 +391,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 // allocate space for the frames present and copy sprtemp to it if (spritedef->numframes && // has been allocated - spritedef->numframes < maxframe) // more frames are defined ? + spritedef->numframes < maxframe) // more frames are defined ? { Z_Free(spritedef->spriteframes); diff --git a/src/v_video.c b/src/v_video.c index a92575c96..fde09cc0b 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3716,9 +3716,7 @@ void V_DoPostProcessor(INT32 view, INT32 param) // Make sure table is built if (heatshifter == NULL || lastheight != viewheight) { - if (heatshifter) - Z_Free(heatshifter); - + Z_Free(heatshifter); heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL); for (y = 0; y < viewheight; y++) diff --git a/src/w_wad.c b/src/w_wad.c index 432f1421f..20a2ccc87 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -122,7 +122,9 @@ void W_Shutdown(void) if (wad->handle) fclose(wad->handle); + Z_Free(wad->filename); + while (wad->numlumps--) { Z_Free(wad->lumpinfo[wad->numlumps].longname); @@ -2730,10 +2732,7 @@ void vres_Free(virtres_t* vres) while (vres->numlumps--) { - if (vres->vlumps[vres->numlumps].data) - { - Z_Free(vres->vlumps[vres->numlumps].data); - } + Z_Free(vres->vlumps[vres->numlumps].data); } Z_Free(vres->vlumps); diff --git a/src/z_zone.h b/src/z_zone.h index 90a55b465..38f00c48c 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -91,7 +91,7 @@ void Z_Init(void); // Z_Free and alloc with alignment #ifdef ZDEBUG -#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__) +#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__) #define Z_Malloc(s,t,u) Z_Malloc2(s, t, u, __FILE__, __LINE__) #define Z_Calloc(s,t,u) Z_Calloc2(s, t, u, __FILE__, __LINE__) #define Z_Realloc(p,s,t,u) Z_Realloc2(p,s, t, u, __FILE__, __LINE__) From 55c8546d68638703040342401217852cd2863034 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Feb 2026 17:21:36 +0100 Subject: [PATCH 139/589] do not use Zone Memory for masterserver rules this gets called from within non main threads! zone memory is not thread safe! --- src/m_menu.c | 3 +-- src/mserv.c | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index f4271de1a..83c2dce77 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5356,7 +5356,7 @@ void M_PopupMasterServerRules(void) { firstDismissedRulesThisBoot = false; M_StartMessage(va("%s\n(press any key)", rules), NULL, MM_NOTHING); - Z_Free(rules); + free(rules); } } #endif @@ -7592,7 +7592,6 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade) static void M_DrawServerMenu(void) { - M_DrawLevelSelectOnly(false, false); #ifdef MASTERSERVER if (currentMenu == &MP_ServerDef && cv_advertise.value) // Remind players where they're hosting. diff --git a/src/mserv.c b/src/mserv.c index f830cd6e2..01af521e6 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -219,8 +219,9 @@ static void Get_masterserver_rules(boolean checkfirst) if (HMS_fetch_rules(rules, sizeof rules)) { Lock_state(); - Z_Free(MSRules); - MSRules = Z_StrDup(rules); + if (MSRules) + free(MSRules); + MSRules = strdup(rules); if (MSRegistered == true) { @@ -507,7 +508,7 @@ char *GetMasterServerRules(void) char *rules; Lock_state(); - rules = MSRules ? Z_StrDup(MSRules) : NULL; + rules = MSRules ? strdup(MSRules) : NULL; Unlock_state(); return rules; From 8cab07a4b21c3fa148cbd143f5ca3e2271beae5c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 3 Feb 2026 15:39:58 +0100 Subject: [PATCH 140/589] add missing "ifdef LOGMESSAGES" --- src/http-mserv.c | 3 ++- src/sdl/i_system.cpp | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/http-mserv.c b/src/http-mserv.c index fd63c5f69..9e4374353 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -225,9 +225,10 @@ HMS_connect (const char *format, ...) { cc = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf); - +#ifdef LOGMESSAGES cc = curl_easy_setopt(curl, CURLOPT_STDERR, logstream); if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf); +#endif } if (M_CheckParm("-bindaddr") && M_IsNextParm()) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 4dd32161e..b90fbf898 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1841,18 +1841,15 @@ static void I_Fork(void) I_RegisterChildSignals(); break; default: +#ifdef LOGMESSAGES if (logstream) fclose(logstream);/* the child has this */ - +#endif c = wait(&status); - #ifdef LOGMESSAGES /* By the way, exit closes files. */ logstream = fopen(logfilename, "at"); -#else - logstream = 0; #endif - if (c == -1) { kill(child, SIGKILL); From 16e0c6f0f6b348bfa83cc2b2795cec9e2071fbf8 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Feb 2026 18:25:13 +0100 Subject: [PATCH 141/589] dont constantly fetch lookback joyaxis in p_ticker if replay recording is enabled minuscule optimization lul --- src/p_tick.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 88e8fb2fd..9365f5669 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -728,11 +728,12 @@ void P_Ticker(boolean run) if (cv_recordmultiplayerdemos.value) { - const INT32 axis = JoyAxis(AXISLOOKBACK, 1); - if (demo.savemode == DSM_NOTSAVING || demo.savemode == DSM_WILLAUTOSAVE) - if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && (InputDown(gc_lookback, 1) || (cv_usejoystick[0].value && axis > 0))) + { + const INT32 axis = cv_usejoystick[0].value ? JoyAxis(AXISLOOKBACK, 1) : -1; + if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && (InputDown(gc_lookback, 1) || (axis > 0))) demo.savemode = DSM_TITLEENTRY; + } // if there are no players left at all, stop demo recording // Demos that that dont have any players crash during playback, which can happen with dedicated servers From 0fbde146a973bdf696c9ab1a48959fd47c6fb99f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Feb 2026 20:07:28 +0100 Subject: [PATCH 142/589] remove some unused fields from precipmobj_t we do not have animating precip nor do we cast it to mobj_t anymore, so we can just get rid of this stuff reducing the struct size by 16bytes wowie --- src/p_mobj.c | 8 ++++---- src/p_mobj.h | 7 ++----- src/p_spec.c | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index d1b8b850a..11f12b5c5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -335,7 +335,7 @@ static boolean P_SetPrecipMobjState(precipmobj_t *mobj, statenum_t state) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + //mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set return true; } @@ -3620,7 +3620,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj) mobj->lastThink = leveltime; R_ResetPrecipitationMobjInterpolationState(mobj); - P_CycleStateAnimation((mobj_t *)mobj); + //P_CycleStateAnimation((mobj_t *)mobj); // if we ever want animated precip, readd a specific function which does not need casting if (mobj->state == &states[S_RAINRETURN]) { @@ -10034,7 +10034,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->x = x; mobj->y = y; - mobj->flags = info->flags; + //mobj->flags = info->flags; // do not set the state with P_SetMobjState, // because action routines can not be called yet @@ -10044,7 +10044,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + //mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set // set subsector and/or block links P_SetPrecipitationThingPosition(mobj); diff --git a/src/p_mobj.h b/src/p_mobj.h index 38bbe2e37..278c40d18 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -444,12 +444,10 @@ typedef struct precipmobj_s // More drawing info: to determine current sprite. spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h - UINT16 anim_duration; // for FF_ANIMATE states + //UINT16 anim_duration; // for FF_ANIMATE states INT16 lightlevel; // Add to sector lightlevel, -255 - 255 - struct mprecipsecnode_s *touching_sectorlist; // a linked list of sectors where this object appears - struct subsector_s *subsector; // Subsector the mobj resides in. // The closest interval over all contacted sectors (or things). @@ -458,11 +456,10 @@ typedef struct precipmobj_s // Momentums, used to update position. fixed_t momx, momy, momz; - fixed_t precipflags; // fixed_t so it uses the same spot as "pmomz" even as we use precipflags_t for it + precipflag_t precipflags; state_t *state; INT32 tics; // state tic counter - UINT32 flags; // flags from mobjinfo tables tic_t lastThink; } precipmobj_t; diff --git a/src/p_spec.c b/src/p_spec.c index b313f77a1..9c3c0c0c3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1702,7 +1702,7 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->type = type; // proper set the type precipmobj->info = &mobjinfo[type]; - precipmobj->flags = mobjinfo[type].flags; + //precipmobj->flags = mobjinfo[type].flags; st = &states[mobjinfo[type].spawnstate+z]; From 6ba97bc43cd4c2f7d8f5fbd73606f368eff7bd1d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Feb 2026 21:00:54 +0100 Subject: [PATCH 143/589] only do the anim texture maths if we need it idk why but this showed up during profiling best would be just to redo the whole system since it sucks lol --- src/p_spec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 9c3c0c0c3..99584bb3d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4532,9 +4532,12 @@ void P_UpdateSpecials(void) { for (i = 0; i < anim->numpics; i++) { - pic = anim->basepic + ((leveltime/anim->speed + i) % anim->numpics); if (anim->istexture) + { + pic = anim->basepic + ((leveltime/anim->speed + i) % anim->numpics); texturetranslation[anim->basepic+i] = pic; + } + } } From 277b202020cfd02eb721a5927fc1890143fe4c5c Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Feb 2026 23:31:04 +0100 Subject: [PATCH 144/589] hooklib: init all the hook states idk i aint trusting any of this lul --- src/lua_hooklib.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index e571f7649..59d1bc1f8 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -615,7 +615,7 @@ FUNCINLINE static ATTRINLINE void res_hud(Hook_State *hook) int LUA_HookMobj(mobj_t *mobj, int hook_type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_mobj_hook(&hook, false, hook_type, mobj)) { LUA_PushUserdata(gL, mobj, META_MOBJ); @@ -626,7 +626,7 @@ int LUA_HookMobj(mobj_t *mobj, int hook_type) int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_mobj_hook(&hook, 0, hook_type, t1)) { LUA_PushUserdata(gL, t1, META_MOBJ); @@ -638,14 +638,14 @@ int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type) void LUA_HookVoid(int type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, type)) call_hooks(&hook, 0, res_none); } void LUA_HookInt(INT32 number, int hook_type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, hook_type)) { lua_pushinteger(gL, number); @@ -655,7 +655,7 @@ void LUA_HookInt(INT32 number, int hook_type) /*void LUA_HookBool(boolean value, int hook_type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, hook_type)) { //lua_pushboolean(gL, value); @@ -665,7 +665,7 @@ void LUA_HookInt(INT32 number, int hook_type) int LUA_HookPlayer(player_t *player, int hook_type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, false, hook_type)) { LUA_PushUserdata(gL, player, META_PLAYER); @@ -676,7 +676,7 @@ int LUA_HookPlayer(player_t *player, int hook_type) int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, false, hook_type)) { LUA_PushUserdata(gL, player, META_PLAYER); @@ -695,7 +695,7 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type) void LUA_HookHUD(int hook_type, huddrawlist_h list) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hud_hook(&hook, hook_type)) { LUA_SetHudHook(hook_type, list); @@ -723,7 +723,7 @@ static void hook_think_frame(int type) int hook_index = 0; precise_t time_taken = 0; - Hook_State hook; + Hook_State hook = {}; const hook_t * map = &hookIds[type]; int k; @@ -783,7 +783,7 @@ void LUA_HookPostThinkFrame(void) int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher) { - Hook_State hook; + Hook_State hook = {}; if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(TouchSpecial), special)) { LUA_PushUserdata(gL, special, META_MOBJ); @@ -802,7 +802,7 @@ static int damage_hook int hook_type, Hook_Callback results_handler ){ - Hook_State hook; + Hook_State hook = {}; if (prepare_mobj_hook(&hook, 0, hook_type, target)) { LUA_PushUserdata(gL, target, META_MOBJ); @@ -890,8 +890,8 @@ int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) { const char *skin = ((skin_t *)tails->skin)->name; - Hook_State hook; - BotAI_State botai; + Hook_State hook = {}; + BotAI_State botai = {}; if (prepare_string_hook(&hook, false, STRING_HOOK(BotAI), skin)) { @@ -911,7 +911,7 @@ int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) { - Hook_State hook; + Hook_State hook = {}; if (prepare_string_hook (&hook, 0, STRING_HOOK(LinedefExecute), line->text)) { @@ -924,7 +924,7 @@ void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, false, HOOK(PlayerMsg))) { LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player @@ -953,7 +953,7 @@ int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute) int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source) { - Hook_State hook; + Hook_State hook = {}; if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(HurtMsg), inflictor)) { LUA_PushUserdata(gL, player, META_PLAYER); @@ -967,7 +967,7 @@ int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source) void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save) { const hook_t * map = &hookIds[HOOK(NetVars)]; - Hook_State hook; + Hook_State hook = {}; /* this is a remarkable case where the stack isn't reset */ if (map->numHooks > 0) { @@ -997,7 +997,7 @@ void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save) void LUA_HookPlayerQuit(player_t *plr, int reason) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, HOOK(PlayerQuit))) { LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit @@ -1060,7 +1060,7 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param) const int type = HOOK(MusicChange); const hook_t * map = &hookIds[type]; - Hook_State hook; + Hook_State hook = {}; int k; @@ -1096,7 +1096,7 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param) int LUA_HookMusicCredit(musicdef_t *musicdef) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, HOOK(MusicCredit))) { LUA_PushUserdata(gL, musicdef, META_MUSICDEF); @@ -1114,7 +1114,7 @@ static int kartdamage_hook int hook_type, Hook_Callback results_handler ){ - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, hook_type)) { LUA_PushUserdata(gL, player, META_PLAYER); @@ -1163,7 +1163,7 @@ boolean LUA_HookPlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *sourc void LUA_HookSetupVote(INT16 result[], INT16 maxresults, UINT8 gt, UINT8 secondgt) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, HOOK(SetupVote))) { // { 0, 0, 0, 0, } From ecef8913b1220dcd577d60563baa324073ed9d8e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Feb 2026 17:06:33 +0100 Subject: [PATCH 145/589] remove some more dead code as reported by clang-tidy --- src/k_hud.c | 2 -- src/k_kart.c | 1 - src/m_anigif.c | 2 +- src/m_menu.c | 9 --------- src/p_inter.c | 1 - src/p_mobj.c | 2 +- src/p_spec.c | 32 +++++++++++++------------------- src/p_user.c | 10 ---------- src/sdl/i_video.c | 4 ++-- src/w_wad.c | 2 +- 10 files changed, 18 insertions(+), 47 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index d0146a38e..4f10bf749 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1415,8 +1415,6 @@ static void K_drawKartStats(void) break; } } - else - spdoffset = 0; if (G_BattleGametype() && ((speedostyle != SPEEDO_DIAL) || splitscreen)) spdoffset += ((stplyr->kartstuff[k_bumper] ? -5 : -8)); diff --git a/src/k_kart.c b/src/k_kart.c index 6496f3e8e..747a032b2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1480,7 +1480,6 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) fixed_t nx = FixedDiv(distx, dist); fixed_t ny = FixedDiv(disty, dist); - dist = dist ? dist : 1; distx = FixedMul(mobj1->radius+mobj2->radius, nx); disty = FixedMul(mobj1->radius+mobj2->radius, ny); diff --git a/src/m_anigif.c b/src/m_anigif.c index cd37b08d6..c9cda476e 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -556,7 +556,7 @@ static void GIF_framewrite(void) } else if (gif_dynamicdelay ==(UINT8) 1) { - float delayf = ceil(100.0f/NEWTICRATE); + float delayf = ceilf(100.0f/NEWTICRATE); delay = (UINT16)((I_GetPreciseTime() - gif_prevframetime)) / (I_GetPrecisePrecision() / 1000000) /10/1000; diff --git a/src/m_menu.c b/src/m_menu.c index 83c2dce77..5a2b92d92 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5522,7 +5522,6 @@ static void M_DrawChecklist(void) if (conditionSets[unlockables[i].conditionset - 1].numconditions) { - c = 0; lastid = -1; for (c = 0; c < conditionSets[unlockables[i].conditionset - 1].numconditions; c++) @@ -5682,9 +5681,6 @@ static void M_DrawMusicTest(void) { INT32 x, y, i; - x = 90<kartstuff[k_sneakertimer] = 0; K_SpinPlayer(player, source, 1, inflictor, false); - damage = player->mo->health - 1; P_RingDamage(player, inflictor, source); P_PlayerRingBurst(player, 5); diff --git a/src/p_mobj.c b/src/p_mobj.c index 11f12b5c5..acc09ab58 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6986,7 +6986,7 @@ static boolean P_MobjDeadThink(mobj_t *mobj) fixed_t ns; mobj_t *mo2; - i = P_RandomByte(); + i = P_RandomByte(); // grrrrrr z = mobj->subsector->sector->floorheight + ((P_RandomByte()&63)*FRACUNIT); for (j = 0; j < 2; j++) diff --git a/src/p_spec.c b/src/p_spec.c index 99584bb3d..e537e17e6 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3161,11 +3161,6 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers INT32 section1, section2, section3, section4; INT32 special; - section1 = GETSECSPECIAL(sector->special, 1); - section2 = GETSECSPECIAL(sector->special, 2); - section3 = GETSECSPECIAL(sector->special, 3); - section4 = GETSECSPECIAL(sector->special, 4); - // Ignore spectators if (player->spectator) return; @@ -3176,6 +3171,11 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers if (player->playerstate == PST_DEAD) return; + section1 = GETSECSPECIAL(sector->special, 1); + section2 = GETSECSPECIAL(sector->special, 2); + section3 = GETSECSPECIAL(sector->special, 3); + section4 = GETSECSPECIAL(sector->special, 4); + // Conveyor stuff if (section3 == 2 || section3 == 4) player->onconveyor = section3; @@ -4381,8 +4381,6 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector) } } -#define VDOORSPEED (FRACUNIT*2) - // // P_RunSpecialSectorCheck // @@ -4512,9 +4510,7 @@ void P_UpdateSpecials(void) { anim_t *anim; INT32 i; - INT32 pic; size_t j; - levelflat_t *foundflats; // for flat animation // LEVEL TIMER @@ -4534,10 +4530,9 @@ void P_UpdateSpecials(void) { if (anim->istexture) { - pic = anim->basepic + ((leveltime/anim->speed + i) % anim->numpics); - texturetranslation[anim->basepic+i] = pic; + texturetranslation[anim->basepic+i] = anim->basepic + + ((leveltime/anim->speed + i) % anim->numpics); } - } } @@ -4632,8 +4627,8 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if (sec2->numattached == 0) { - sec2->attached = Z_Malloc(sizeof (*sec2->attached) * sec2->maxattached, PU_STATIC, NULL); - sec2->attachedsolid = Z_Malloc(sizeof (*sec2->attachedsolid) * sec2->maxattached, PU_STATIC, NULL); + sec2->attached = Z_Malloc(sizeof(*sec2->attached) * sec2->maxattached, PU_STATIC, NULL); + sec2->attachedsolid = Z_Malloc(sizeof(*sec2->attachedsolid) * sec2->maxattached, PU_STATIC, NULL); sec2->attached[0] = sec - sectors; sec2->numattached = 1; sec2->attachedsolid[0] = (flags & FF_SOLID); @@ -4647,8 +4642,8 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if (sec2->numattached >= sec2->maxattached) { sec2->maxattached *= 2; - sec2->attached = Z_Realloc(sec2->attached, sizeof (*sec2->attached) * sec2->maxattached, PU_STATIC, NULL); - sec2->attachedsolid = Z_Realloc(sec2->attachedsolid, sizeof (*sec2->attachedsolid) * sec2->maxattached, PU_STATIC, NULL); + sec2->attached = Z_Realloc(sec2->attached, sizeof(*sec2->attached) * sec2->maxattached, PU_STATIC, NULL); + sec2->attachedsolid = Z_Realloc(sec2->attachedsolid, sizeof(*sec2->attachedsolid) * sec2->maxattached, PU_STATIC, NULL); } sec2->attached[sec2->numattached] = sec - sectors; sec2->attachedsolid[sec2->numattached] = (flags & FF_SOLID); @@ -4656,7 +4651,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f } // Add the floor - ffloor = Z_Calloc(sizeof (*ffloor), PU_LEVEL, NULL); + ffloor = Z_Calloc(sizeof(*ffloor), PU_LEVEL, NULL); ffloor->secnum = sec2 - sectors; ffloor->target = sec; ffloor->bottomheight = &sec2->floorheight; @@ -5471,7 +5466,6 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) break; case 10: // Vertical culling plane for sprites and FOFs - sec = sides[*lines[i].sidenum].sector - sectors; for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) sectors[s].cullheight = &lines[i]; // This allows it to change in realtime! break; @@ -5992,7 +5986,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) if (!virt) virt = vres_GetMap(lastloadedmaplumpnum); - data = (UINT8*) vres_Find(virt, "SIDEDEFS")->data; + data = (UINT8*)vres_Find(virt, "SIDEDEFS")->data; for (b = 0; b < (INT16)numsides; b++) { diff --git a/src/p_user.c b/src/p_user.c index 2a3ccc300..a930ec6a1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1894,7 +1894,6 @@ static void P_3dMovement(player_t *player) ticcmd_t *cmd; angle_t movepushangle, movepushsideangle; // Analog fixed_t movepushforward = 0, movepushside = 0; - angle_t dangle; // replaces old quadrants bits boolean analogmove = false; fixed_t oldMagnitude, newMagnitude; vector3_t totalthrust; @@ -1952,15 +1951,6 @@ static void P_3dMovement(player_t *player) // Calculates player's speed based on distance-of-a-line formula player->speed = R_PointToDist2(0, 0, player->rmomx, player->rmomy); - // Monster Iestyn - 04-11-13 - // Quadrants are stupid, excessive and broken, let's do this a much simpler way! - // Get delta angle from rmom angle and player angle first - dangle = R_PointToAngle2(0,0, player->rmomx, player->rmomy) - player->mo->angle; - if (dangle > ANGLE_180) //flip to keep to one side - { - dangle = InvAngle(dangle); - } - // When sliding, don't allow forward/back if (player->pflags & PF_SLIDING) cmd->forwardmove = 0; diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 8b2adfa7b..e367b612f 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1164,8 +1164,8 @@ void I_GetEvent(void) SDL_GetWindowSize(window, &wwidth, &wheight); event.type = ev_mouse; event.data1 = 0; - event.data2 = (INT32)lround(mousemovex * ((float)wwidth / (float)realwidth)); - event.data3 = (INT32)lround(mousemovey * ((float)wheight / (float)realheight)); + event.data2 = (INT32)lroundf(mousemovex * ((float)wwidth / (float)realwidth)); + event.data3 = (INT32)lroundf(mousemovey * ((float)wheight / (float)realheight)); D_PostEvent(&event); } diff --git a/src/w_wad.c b/src/w_wad.c index 20a2ccc87..3009d503f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -455,7 +455,7 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena header.infotableofs = LONG(header.infotableofs); // read wad file directory - i = header.numlumps * sizeof (*fileinfo); + i = header.numlumps * sizeof(*fileinfo); fileinfov = fileinfo = malloc(i); if (fseek(handle, header.infotableofs, SEEK_SET) == -1 From 86b286fb0bd6284c2ed41bfa375effe3ca29778b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Feb 2026 20:03:54 +0100 Subject: [PATCH 146/589] fix few more cases of using potentially uninitialized garbage --- src/command.c | 2 +- src/g_demo.c | 2 +- src/hardware/hw_main.cpp | 3 +-- src/hu_stuff.c | 3 +++ src/m_menu.c | 2 +- src/s_sound.c | 3 +-- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/command.c b/src/command.c index 6b71dce73..0b1578381 100644 --- a/src/command.c +++ b/src/command.c @@ -1793,7 +1793,7 @@ void CV_AddValue(consvar_t *var, INT32 increment) if (newvalue == oldvalue) break; // don't loop forever if there's none of a certain gametype - if (newvalue >= 0 && !mapheaderinfo[newvalue]) + if (newvalue >= 0 && newvalue < NUMMAPS && !mapheaderinfo[newvalue]) continue; // Don't allocate the header. That just makes memory usage skyrocket. } while (!M_CanShowLevelInList(newvalue, gt)); diff --git a/src/g_demo.c b/src/g_demo.c index ede5adf18..9662ce517 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2605,7 +2605,7 @@ void G_DoPlayDemo(char *defdemoname) boolean skiperrors = false; #endif boolean spectator; - UINT8 slots[MAXPLAYERS], kartspeed[MAXPLAYERS], kartweight[MAXPLAYERS], numslots = 0; + UINT8 slots[MAXPLAYERS] = {}, kartspeed[MAXPLAYERS] = {}, kartweight[MAXPLAYERS] = {}, numslots = 0; G_InitDemoRewind(); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 5cc8eacf7..e9aa0532d 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1378,8 +1378,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom FSurfaceInfo Surf; - if (gl_frontsector) - Surf.PolyColor.s.alpha = 255; + Surf.PolyColor.s.alpha = 255; const INT32 gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture); GLMapTexture_t *glTex = NULL; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 653529bf4..6ede89fc6 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -497,7 +497,9 @@ static void HU_removeChatText_Log(void) { chat_log[i] = chat_log[i+1]; } + chat_nummsg_log--; // lost 1 msg. + chat_log[chat_nummsg_log] = NULL; } static void Chatlogsize_OnChange(void) @@ -516,6 +518,7 @@ static void Chatlogsize_OnChange(void) if (new_chat_log == NULL) { free(chat_log); + chat_log = NULL; return; } chat_log = new_chat_log; diff --git a/src/m_menu.c b/src/m_menu.c index 5a2b92d92..0e753f621 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2936,7 +2936,7 @@ static void M_PrepareLevelSelect(void) boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt) { // invalid mapnum - if (mapnum < -1) + if (mapnum < -1 || mapnum >= NUMMAPS) return false; // Random map! diff --git a/src/s_sound.c b/src/s_sound.c index 7f931671d..f2ee1dc03 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -473,13 +473,12 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) return; memset(listener, 0, sizeof(listener)); + memset(listenmobj, 0, sizeof(listenmobj)); for (i = 0; i <= splitscreen; i++) { player_t *player = &players[displayplayers[i]]; - listenmobj[i] = NULL; - if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; From c84724da37c5700c8d83c46304e0bc22ce316f1c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 8 Feb 2026 20:29:01 +0100 Subject: [PATCH 147/589] make lumpnumcache case sensitive + optimize + replace quickncase hash with FNV1a lumpnumcache can be case sensitive W_CheckNumForName should also look for uppercase stuff and W_LumpExists is case sensitive anyways this avoids having to always account for case (toupper/tolower) during hash and string comparisons and even allows us to even directly compare our strings instead of using fastcmp (std::strings allow this!) from some benchmarking externally this makes this faster quite a bit --- src/doomdef.h | 16 ---------------- src/m_misc.c | 16 ++++++++++++++++ src/m_misc.h | 1 + src/r_data.c | 6 +++--- src/s_sound.c | 4 ++-- src/w_wad.cpp | 31 ++++++++++--------------------- src/w_wad.h | 2 -- 7 files changed, 32 insertions(+), 44 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 23768d0f4..445b6951f 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -516,22 +516,6 @@ extern boolean capslock; // i_system.c, replace getchar() once the keyboard has been appropriated INT32 I_GetKey(void); -/* http://www.cse.yorku.ca/~oz/hash.html */ -static inline -UINT32 quickncasehash (const char *p, size_t n) -{ - size_t i = 0; - UINT32 x = 5381; - - while (i < n && p[i]) - { - x = (x * 33) ^ tolower(p[i]); - i++; - } - - return x; -} - #ifndef __cplusplus #ifndef min // Double-Check with WATTCP-32's cdefs.h #define min(x, y) (((x) < (y)) ? (x) : (y)) diff --git a/src/m_misc.c b/src/m_misc.c index 8c7b34163..bd038a488 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1956,6 +1956,22 @@ UINT32 FNV1a_Hash(const char *message, size_t size) return hash; } +// Behaves like the old quickncasehash +// Stops either if it encounters null terminator +// or reaches size +UINT32 FNV1a_QuickCaseHash(const char *message, size_t size) +{ + UINT32 hash = FNV1A_OFFSET_BASIS; + + for (size_t i = 0; i < size && message[i]; i++) + { + hash ^= tolower(message[i]); + hash *= FNV1A_PRIME; + } + + return hash; +} + UINT32 FNV1a_HashString(const char *message) { UINT32 hash = FNV1A_OFFSET_BASIS; diff --git a/src/m_misc.h b/src/m_misc.h index ab7c8986f..813e8abf1 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -123,6 +123,7 @@ FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size); // Hashes some message using FNV-1a UINT32 FNV1a_Hash(const char *message, size_t size); +UINT32 FNV1a_QuickCaseHash(const char *message, size_t size); UINT32 FNV1a_HashString(const char *message); UINT32 FNV1a_HashLowercaseString(const char *message); diff --git a/src/r_data.c b/src/r_data.c index 386f0e700..a99218765 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -622,7 +622,7 @@ Rloadtextures (INT32 i, INT32 w) // Set texture properties. memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); - texture->hash = quickncasehash(texture->name, 8); + texture->hash = FNV1a_QuickCaseHash(texture->name, 8); texture->width = SHORT(patchlump.width); texture->height = SHORT(patchlump.height); @@ -1066,7 +1066,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture) // Allocate memory for a zero-patch texture. Obviously, we'll be adding patches momentarily. resultTexture = (texture_t *)Z_Calloc(sizeof(texture_t), PU_STATIC, NULL); memcpy(resultTexture->name, newTextureName, 8); - resultTexture->hash = quickncasehash(newTextureName, 8); + resultTexture->hash = FNV1a_QuickCaseHash(newTextureName, 8); resultTexture->width = newTextureWidth; resultTexture->height = newTextureHeight; resultTexture->type = TEXTURETYPE_COMPOSITE; @@ -1756,7 +1756,7 @@ INT32 R_CheckTextureNumForName(const char *name) if (name[0] == '-') return 0; - hash = quickncasehash(name, 8); + hash = FNV1a_QuickCaseHash(name, 8); for (i = 0; i < tidcachelen; i++) if (tidcache[i].hash == hash && !strncasecmp(tidcache[i].name, name, 8)) diff --git a/src/s_sound.c b/src/s_sound.c index 7f931671d..206b5c37c 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1302,7 +1302,7 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde STRBUFCPY(def->name, value); strlwr(def->name); - def->hash = quickncasehash (def->name, 6); + def->hash = FNV1a_QuickCaseHash(def->name, 6); } (*defp) = def; @@ -1484,7 +1484,7 @@ void S_InitMusicDefs(void) // musicdef_t *S_FindMusicCredit(const char *musname) { - UINT32 hash = quickncasehash(musname, 6); + UINT32 hash = FNV1a_QuickCaseHash(musname, 6); musicdef_t *def; for (INT32 i = 0; i < nummusicdefs; ++i) diff --git a/src/w_wad.cpp b/src/w_wad.cpp index bbf543f1d..44fece4a7 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -99,7 +99,7 @@ struct LumpnumNameHash std::size_t operator()(const std::string& str) const { // hopefully this is fast enough but should be - return static_cast(quickncasehash(str.c_str(), str.length())); + return static_cast(FNV1a_Hash(str.c_str(), str.length())); } }; @@ -107,8 +107,8 @@ struct LumpnumStringEquals { bool operator()(const std::string& str1, const std::string& str2) const { - // fasticmp should be plenty fast and ignores case - return fasticmp(str1.c_str(), str2.c_str()); + //return fastcmp(str1.c_str(), str2.c_str()); + return str1 == str2; } }; @@ -377,12 +377,12 @@ static inline INT32 W_MakeFileMD5(const char *filename, void *resblock) } // Invalidates the cache of lump numbers. Call this whenever a wad is added. -static void W_InvalidateLumpnumCache(void) +FUNCINLINE static ATTRINLINE void W_InvalidateLumpnumCache(void) { lumpnumcache.clear(); } -UINT32 W_HashLumpName(const char *name) +FUNCINLINE static ATTRINLINE UINT32 W_HashLumpName(const char *name) { return FNV1a_HashLowercaseString(name); } @@ -1246,7 +1246,7 @@ UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump) return INT16_MAX; } -static lumpnum_t CheckLumpInCache(const char *name) +FUNCINLINE static ATTRINLINE lumpnum_t CheckLumpInCache(const char *name) { auto it = lumpnumcache.find(name); if (it != lumpnumcache.end()) @@ -1255,9 +1255,9 @@ static lumpnum_t CheckLumpInCache(const char *name) return LUMPERROR; } -static void AddLumpToCache(lumpnum_t lumpnum, const char *name) +FUNCINLINE static ATTRINLINE void AddLumpToCache(lumpnum_t lumpnum, const char *name) { - lumpnumcache.insert({name, lumpnum}); + lumpnumcache.emplace(name, lumpnum); } // @@ -1415,21 +1415,10 @@ UINT8 W_LumpExists(const char *name) UINT32 hash; size_t namelen; + // Check the lumpnumcache first. lumpnum_t cachenum = CheckLumpInCache(name); if (cachenum != LUMPERROR) - { - // ok ok, we did find a lump in our lumpcache BUTT - // the lumpcache map is case insensitive - // extract the lumpinfo out of the lumpnum - // so we can do one more extra case ~sensitive~ name compare - // otherwise we gotta fall through to our manual lump search below - // lumpnum == (wadnum << 16) | lumpinfo id - UINT16 wadnum = (cachenum >> 16) & 0xFFFF; - UINT16 lumpid = cachenum & 0xFFFF; - lumpinfo_t *lump_p = &wadfiles[wadnum]->lumpinfo[lumpid]; - if (fastcmp(lump_p->name, name)) - return true; - } + return cachenum; namelen = strlen(name); hash = W_HashLumpName(name); diff --git a/src/w_wad.h b/src/w_wad.h index 75c7e9c04..d21afb982 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -174,8 +174,6 @@ INT32 W_AddAutoloadedLocalFiles(char **filenames); #define W_FileHasFolders(wadfile) ((wadfile)->type == RET_PK3) -UINT32 W_HashLumpName(const char *name); - const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump); const char *W_CheckNameForNum(lumpnum_t lumpnum); From 02f2464a00987624babbf527d378383eda36ddc7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 8 Feb 2026 23:13:16 +0100 Subject: [PATCH 148/589] HWR_CreateBlendedTexture: init a bunch of stuff --- src/hardware/hw_md2.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 56082e0fc..2fd33f65b 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -693,17 +693,15 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi GLPatch_t *hwrBlendPatch = blendgpatch->hardware; UINT16 w = gpatch->width, h = gpatch->height; UINT32 size = w*h; - RGBA_t *image, *blendimage, *cur, blendcolor; + RGBA_t *image, *blendimage, *cur; + RGBA_t blendcolor = {}; RGBA_t *palette = HWR_GetTexturePalette(); - UINT8 translation[17]; // First the color index - UINT8 cutoff[17]; // Brightness cutoff before using the next color + UINT8 translation[17] = {}; // First the color index + UINT8 cutoff[17] = {}; // Brightness cutoff before using the next color UINT8 translen = 0; UINT8 i; - UINT8 colorbrightnesses[17]; - UINT8 color_match_lookup[256]; // optimization attempt - - memset(translation, 0, sizeof(translation)); - memset(cutoff, 0, sizeof(cutoff)); + UINT8 colorbrightnesses[17] = {}; + UINT8 color_match_lookup[256] = {}; // optimization attempt if (glMipmap->width == 0) { @@ -716,14 +714,10 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi glMipmap->format = GL_TEXFMT_RGBA; } - if (glMipmap->data) - { - Z_Free(glMipmap->data); - glMipmap->data = NULL; - } + Z_Free(glMipmap->data); + glMipmap->data = NULL; - cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &glMipmap->data); - memset(cur, 0x00, size*4); + cur = Z_Calloc(size*4, PU_HWRMODELTEXTURE, &glMipmap->data); image = hwrPatch->mipmap->data; blendimage = hwrBlendPatch->mipmap->data; @@ -1037,7 +1031,6 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk GLPatch_t *glPatch = patch->hardware; GLMipmap_t *glMipmap, *newMipmap; - if (blendgpatch == NULL || colormap == colormaps || colormap == NULL) { // Don't do any blending From 38fc6d6ba173478f7bd5ae88946df9f5ffd7a8c5 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Feb 2026 16:09:26 +0100 Subject: [PATCH 149/589] remove screen texture toggle from accessability menu + new tooltip --- src/m_menudefs.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 1a21ec455..00b927efd 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -986,7 +986,7 @@ static const char* OP_ExpTooltips[] = "Skips rendering frames if game logic takes too long\npreventing gameplay issues during performance drops.", // idk im shit as describing things "Different methods of scaling the votescreen backgrounds.", #ifdef HWRENDER - "Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.", + "Disabling Screen Textures may result in a performance boost\nbut will break certain effects.\nScreen textures are required at resolutions lower than your desktop resolution!" #ifdef USE_FBO_OGL "Allows the game to downsample from a higher resolution\nthan your display in OpenGL renderer mode.\nRequires a GPU with atleast OpenGL 2.1 support.", #endif @@ -1644,29 +1644,25 @@ static menuitem_t OP_AccessibilityMenu[] = {IT_STRING|IT_CVAR, NULL, "Minimum Sector Brightness", &cv_secbright, 45}, -#ifdef HWRENDER - {IT_STRING|IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 50}, -#endif + {IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 50}, - {IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 55}, + {IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 55}, - {IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 60}, + {IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 60}, - {IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 65}, + {IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 65}, - {IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 70}, + {IT_HEADER, NULL, "Audio", NULL, 75}, - {IT_HEADER, NULL, "Audio", NULL, 80}, + {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 85}, + {IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 90}, - {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 90}, - {IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 95}, + {IT_HEADER, NULL, "Controls", NULL, 100}, - {IT_HEADER, NULL, "Controls", NULL, 105}, - - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 115}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 120}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 125}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 130}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 110}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 115}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 120}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 125}, }; static const char* OP_AccessibilityTooltips[] = @@ -1679,9 +1675,6 @@ static const char* OP_AccessibilityTooltips[] = "Reduces or disables certain effects players might be sensitive to\nSuch as flashing, flickering, certain screen effects and more.", "Disables the flicker effect on Midnight Channel.", "Sets minimum sector brightness, useful for dark areas", -#ifdef HWRENDER - "Disabling Screen Textures will disable the Underwater and Heat screen effects.", -#endif "Toggles the ripple effect on water surfaces", "Fades other Players that are close to the camera in and out", "Toggles the screen shake effect during Earthquakes", From 6f75fab7ffbda9050e3102d5fc2d77583e59c3d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Feb 2026 19:39:29 +0100 Subject: [PATCH 150/589] move gamepad led ticker after render logic this does not really matter but save a tiny little amount of time before rendering a frame --- src/d_main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 90ff81cc9..b0a269ae9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -783,11 +783,6 @@ void D_SRB2Loop(void) doDisplay = true; } - - if (!dedicated) - { - G_DeviceLEDTick(); - } } if (interp) @@ -829,6 +824,13 @@ void D_SRB2Loop(void) if (takescreenshot) M_DoScreenShot(); +#ifndef DEDICATED + if (!dedicated && renderisnewtic) + { + G_DeviceLEDTick(); + } +#endif + // consoleplayer -> displayplayers (hear sounds from viewpoint) S_UpdateSounds(); // move positional sounds From 513e5a7e3f46460a31811bc4ae3b021fbb1692eb Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 10 Feb 2026 16:38:11 +0100 Subject: [PATCH 151/589] remove even more dead code lol --- src/d_main.c | 43 +++++++++++++++---------------------------- src/p_user.c | 3 +-- src/r_things.cpp | 3 --- src/st_stuff.c | 2 -- src/st_stuff.h | 2 -- 5 files changed, 16 insertions(+), 37 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index b0a269ae9..9d5b23f59 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -274,21 +274,17 @@ static void D_Renderview(void) R_ApplyLevelInterpolators(R_GetTimeFrac(RTF_LEVEL)); - if (rendermode == render_soft) + if (rendermode == render_soft && cv_homremoval.value) { - // if this is display player 1 - if (cv_homremoval.value) + if (cv_homremoval.value == 1) { - if (cv_homremoval.value == 1) - { - // Clear the software screen buffer to remove HOM - memset(vid.screens[0], 31, vid.width * vid.height); - } - else if (cv_homremoval.value == 2) - { - //'development' HOM removal -- makes it blindingly obvious if HOM is spotted. - memset(vid.screens[0], 32+(timeinmap&15), vid.width * vid.height); - } + // Clear the software screen buffer to remove HOM + memset(vid.screens[0], 31, vid.width * vid.height); + } + else if (cv_homremoval.value == 2) + { + //'development' HOM removal -- makes it blindingly obvious if HOM is spotted. + memset(vid.screens[0], 32+(timeinmap&15), vid.width * vid.height); } } @@ -322,7 +318,6 @@ static void D_Renderview(void) break; default: // Initialize for P1 viewwindowy = viewwindowx = 0; - objectsdrawn = 0; break; } @@ -333,19 +328,17 @@ static void D_Renderview(void) } else if (rendermode == render_soft) #endif + { R_RenderPlayerView(&players[displayplayers[i]]); - } - - if (rendermode == render_soft) - { - if (i == 0) - R_ApplyViewMorph(); + if (i == 0) + R_ApplyViewMorph(); #ifdef MOTIONBLUR - V_DoPostProcessor(i, postimgparam[i]); + V_DoPostProcessor(i, postimgparam[i]); #else - V_DoPostProcessor(i, 0); + V_DoPostProcessor(i, 0); #endif + } } } @@ -1645,12 +1638,6 @@ void D_SRB2Main(void) strcpy(srb2, "SRB2Kart"); D_MakeTitleString(srb2); -#if defined (__OS2__) && !defined (HAVE_SDL) - // set PM window title - snprintf(pmData->title, sizeof (pmData->title), "SRB2Kart" VERSIONSTRING ": %s", title); - pmData->title[sizeof (pmData->title) - 1] = '\0'; -#endif - if (devparm) CONS_Printf(M_GetText("Development mode ON.\n")); diff --git a/src/p_user.c b/src/p_user.c index a930ec6a1..15a71ebc8 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1822,7 +1822,6 @@ void P_DoJumpShield(player_t *player) player->pflags &= ~PF_JUMPED; //P_DoJump(player, false); - player->pflags &= ~PF_JUMPED; player->secondjump = 0; player->jumping = 0; player->pflags |= PF_THOKKED; @@ -4454,7 +4453,7 @@ static INT32 Quaketilt(player_t *player) lowb = FixedMul(lowb, player->mo->scale); moma = FixedMul(FixedDiv(delta, ANGLE_90), tilt); - speed = abs( player->mo->momx + player->mo->momy ); + speed = abs(player->mo->momx + player->mo->momy); if (speed < lowb) { diff --git a/src/r_things.cpp b/src/r_things.cpp index 58a838eea..60b0bbd52 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1855,9 +1855,6 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->subsector->sector->numlights) R_SplitSprite(vis); - - // Debug - ++objectsdrawn; } static void R_ProjectPrecipitationSprite(precipmobj_t *thing) diff --git a/src/st_stuff.c b/src/st_stuff.c index 5ca3f9d91..6dc7111f3 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -52,8 +52,6 @@ #include "r_fps.h" -UINT16 objectsdrawn = 0; - // dumb fade thing for director toggle tic_t directortoggletimer = 0; diff --git a/src/st_stuff.h b/src/st_stuff.h index 8e7f8fa41..24202646a 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -134,8 +134,6 @@ typedef enum extern hudinfo_t hudinfo[NUMHUDITEMS]; -extern UINT16 objectsdrawn; - // variable to stop mayonaka static from flickering extern consvar_t cv_lessflicker; extern consvar_t cv_stagetitle; From d49001143f487e3b1d6e0894d82f7b346e2561c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 11 Feb 2026 17:44:31 +0100 Subject: [PATCH 152/589] fix new compiler warnings from new gcc version just throw const at everything :blobthumbsup: --- src/d_main.c | 2 +- src/doomtype.h | 2 +- src/g_game.c | 6 +++--- src/hardware/hw_shaders.c | 2 +- src/hardware/r_opengl/r_opengl.c | 6 +++--- src/m_misc.c | 2 +- src/strcasestr.c | 37 ++++++++++++++++---------------- 7 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 9d5b23f59..a04334a5f 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -2018,7 +2018,7 @@ void D_SRB2Main(void) if (M_CheckProtoParam("replay")) { const char *replayurl = M_GetProtoParam(); - char *replayname = strrchr(replayurl, '/'); + const char *replayname = strrchr(replayurl, '/'); if (!replayname || !replayurl) I_Error("REPLAY: Invalid URL."); diff --git a/src/doomtype.h b/src/doomtype.h index ed6248129..0f76500fd 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -68,7 +68,7 @@ extern "C" { #define strnicmp(x,y,n) strncasecmp(x,y,n) #endif -char *nongnu_strcasestr(const char *in, const char *what); +const char *nongnu_strcasestr(const char *in, const char *what); #ifndef _GNU_SOURCE #define strcasestr nongnu_strcasestr #endif diff --git a/src/g_game.c b/src/g_game.c index a79a957ef..a498bde0a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4152,7 +4152,7 @@ static void measurekeywords(mapsearchfreq_t *fr, const char *s, const char *q, boolean wanttable) { char *qp; - char *sp; + const char *sp; if (wanttable) (*dimp) = Z_Realloc((*dimp), 255 * sizeof (struct searchdim), PU_STATIC, NULL); @@ -4197,9 +4197,9 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, size_t mapnamelen; char *realmapname = NULL; - char *newmapname = NULL; + char *newmapname = NULL; char *apromapname = NULL; - char *aprop = NULL; + const char *aprop = NULL; mapsearchfreq_t *freq; boolean wanttable; diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 28f8e46d7..80f070099 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -109,7 +109,7 @@ boolean HWR_InitShaders(void) // returns INT32_MAX if not found static INT32 strstr_int(const char *str1, const char *str2) { - char *location = strstr(str1, str2); + const char *location = strstr(str1, str2); if (location) return location - str1; else diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index eeb40a8dc..9f5098002 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1383,19 +1383,19 @@ void GL_Flush(void) // -----------------+ INT32 GL_isExtAvailable(const char *extension, const GLubyte *start) { - GLubyte *where, *terminator; + const GLubyte *where, *terminator; if (!extension || !start) return 0; - where = (GLubyte *) strchr(extension, ' '); + where = (const GLubyte *)strchr(extension, ' '); if (where || *extension == '\0') return 0; for (;;) { - where = (GLubyte *) strstr((const char *) start, extension); + where = (const GLubyte *)strstr((const char *) start, extension); if (!where) break; diff --git a/src/m_misc.c b/src/m_misc.c index 3a456d7a7..c11514524 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1454,7 +1454,7 @@ INT32 axtoi(const char *hexStg) void CopyCaretColors(char *p, const char *s, int n) { - char *t; + const char *t; int m; int c; diff --git a/src/strcasestr.c b/src/strcasestr.c index f05449778..5859e57bd 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -28,10 +28,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include static inline int -trycmp (char **pp, char *cp, +trycmp (const char **pp, const char *cp, const char *q, size_t qn) { - char *p; + const char *p; p = (*pp); if (strncasecmp(p, q, qn) == 0) return 0; @@ -40,10 +40,10 @@ trycmp (char **pp, char *cp, } static inline void -swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) +swapp (const char ***ppap, const char ***ppbp, const char **cpap, const char **cpbp) { - char **pp; - char *p; + const char **pp; + const char *p; pp = *ppap; *ppap = *ppbp; @@ -54,28 +54,27 @@ swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) *cpbp = p; } -char * -nongnu_strcasestr (const char *s, const char *q) +const char *nongnu_strcasestr(const char *in, const char *what) { size_t qn; char uc; char lc; - char *up; - char *lp; + const char *up; + const char *lp; - char **ppa; - char **ppb; + const char **ppa; + const char **ppb; - char *cpa; - char *cpb; + const char *cpa; + const char *cpb; - uc = toupper(*q); - lc = tolower(*q); + uc = toupper(*what); + lc = tolower(*what); - up = strchr(s, uc); - lp = strchr(s, lc); + up = strchr(in, uc); + lp = strchr(in, lc); if (up == NULL && lp == NULL) return NULL; @@ -97,11 +96,11 @@ nongnu_strcasestr (const char *s, const char *q) cpb = &uc; } - qn = strlen(q); + qn = strlen(what); for (;;) { - if (trycmp(ppa, cpa, q, qn) == 0) + if (trycmp(ppa, cpa, what, qn) == 0) return (*ppa); if (up == NULL && lp == NULL) From 5c28f6afd8e237660c9f4cd927701119238277d6 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 16 Feb 2026 19:04:51 +0100 Subject: [PATCH 153/589] Revert "fix new compiler warnings from new gcc version" This reverts commit d49001143f487e3b1d6e0894d82f7b346e2561c8. --- src/d_main.c | 2 +- src/doomtype.h | 2 +- src/g_game.c | 6 +++--- src/hardware/hw_shaders.c | 2 +- src/hardware/r_opengl/r_opengl.c | 6 +++--- src/m_misc.c | 2 +- src/strcasestr.c | 37 ++++++++++++++++---------------- 7 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index a04334a5f..9d5b23f59 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -2018,7 +2018,7 @@ void D_SRB2Main(void) if (M_CheckProtoParam("replay")) { const char *replayurl = M_GetProtoParam(); - const char *replayname = strrchr(replayurl, '/'); + char *replayname = strrchr(replayurl, '/'); if (!replayname || !replayurl) I_Error("REPLAY: Invalid URL."); diff --git a/src/doomtype.h b/src/doomtype.h index 0f76500fd..ed6248129 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -68,7 +68,7 @@ extern "C" { #define strnicmp(x,y,n) strncasecmp(x,y,n) #endif -const char *nongnu_strcasestr(const char *in, const char *what); +char *nongnu_strcasestr(const char *in, const char *what); #ifndef _GNU_SOURCE #define strcasestr nongnu_strcasestr #endif diff --git a/src/g_game.c b/src/g_game.c index a498bde0a..a79a957ef 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4152,7 +4152,7 @@ static void measurekeywords(mapsearchfreq_t *fr, const char *s, const char *q, boolean wanttable) { char *qp; - const char *sp; + char *sp; if (wanttable) (*dimp) = Z_Realloc((*dimp), 255 * sizeof (struct searchdim), PU_STATIC, NULL); @@ -4197,9 +4197,9 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, size_t mapnamelen; char *realmapname = NULL; - char *newmapname = NULL; + char *newmapname = NULL; char *apromapname = NULL; - const char *aprop = NULL; + char *aprop = NULL; mapsearchfreq_t *freq; boolean wanttable; diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 80f070099..28f8e46d7 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -109,7 +109,7 @@ boolean HWR_InitShaders(void) // returns INT32_MAX if not found static INT32 strstr_int(const char *str1, const char *str2) { - const char *location = strstr(str1, str2); + char *location = strstr(str1, str2); if (location) return location - str1; else diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 9f5098002..eeb40a8dc 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1383,19 +1383,19 @@ void GL_Flush(void) // -----------------+ INT32 GL_isExtAvailable(const char *extension, const GLubyte *start) { - const GLubyte *where, *terminator; + GLubyte *where, *terminator; if (!extension || !start) return 0; - where = (const GLubyte *)strchr(extension, ' '); + where = (GLubyte *) strchr(extension, ' '); if (where || *extension == '\0') return 0; for (;;) { - where = (const GLubyte *)strstr((const char *) start, extension); + where = (GLubyte *) strstr((const char *) start, extension); if (!where) break; diff --git a/src/m_misc.c b/src/m_misc.c index c11514524..3a456d7a7 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1454,7 +1454,7 @@ INT32 axtoi(const char *hexStg) void CopyCaretColors(char *p, const char *s, int n) { - const char *t; + char *t; int m; int c; diff --git a/src/strcasestr.c b/src/strcasestr.c index 5859e57bd..f05449778 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -28,10 +28,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include static inline int -trycmp (const char **pp, const char *cp, +trycmp (char **pp, char *cp, const char *q, size_t qn) { - const char *p; + char *p; p = (*pp); if (strncasecmp(p, q, qn) == 0) return 0; @@ -40,10 +40,10 @@ trycmp (const char **pp, const char *cp, } static inline void -swapp (const char ***ppap, const char ***ppbp, const char **cpap, const char **cpbp) +swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) { - const char **pp; - const char *p; + char **pp; + char *p; pp = *ppap; *ppap = *ppbp; @@ -54,27 +54,28 @@ swapp (const char ***ppap, const char ***ppbp, const char **cpap, const char **c *cpbp = p; } -const char *nongnu_strcasestr(const char *in, const char *what) +char * +nongnu_strcasestr (const char *s, const char *q) { size_t qn; char uc; char lc; - const char *up; - const char *lp; + char *up; + char *lp; - const char **ppa; - const char **ppb; + char **ppa; + char **ppb; - const char *cpa; - const char *cpb; + char *cpa; + char *cpb; - uc = toupper(*what); - lc = tolower(*what); + uc = toupper(*q); + lc = tolower(*q); - up = strchr(in, uc); - lp = strchr(in, lc); + up = strchr(s, uc); + lp = strchr(s, lc); if (up == NULL && lp == NULL) return NULL; @@ -96,11 +97,11 @@ const char *nongnu_strcasestr(const char *in, const char *what) cpb = &uc; } - qn = strlen(what); + qn = strlen(q); for (;;) { - if (trycmp(ppa, cpa, what, qn) == 0) + if (trycmp(ppa, cpa, q, qn) == 0) return (*ppa); if (up == NULL && lp == NULL) From 53321d33d57eaae56e6af1c7fa031fb836b6cddb Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 12 Feb 2026 18:41:53 +0100 Subject: [PATCH 154/589] mark some nightsmode stuff with likely/unlikely i missed and in some cases move around the conditionals i love backwards compat Zzz.... --- src/d_clisrv.c | 4 +++- src/p_inter.c | 4 ++-- src/p_local.h | 6 ------ src/p_mobj.c | 18 +++++++++--------- src/p_spec.c | 6 +++--- src/p_user.c | 2 +- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 68ab08c5a..2f3440362 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3350,7 +3350,7 @@ void CL_ClearPlayer(INT32 playernum) if (players[playernum].mo) { // Don't leave a NiGHTS ghost! - if ((players[playernum].pflags & PF_NIGHTSMODE) && players[playernum].mo->tracer) + if (UNLIKELY((players[playernum].pflags & PF_NIGHTSMODE) && players[playernum].mo->tracer)) P_RemoveMobj(players[playernum].mo->tracer); P_RemoveMobj(players[playernum].mo); } @@ -3496,6 +3496,7 @@ static void Command_GetPlayerNum(void) INT32 i; for (i = 0; i < MAXPLAYERS; i++) + { if (playeringame[i]) { if (serverplayer == i) @@ -3503,6 +3504,7 @@ static void Command_GetPlayerNum(void) else CONS_Printf(M_GetText("\x82num:%2d node:%2d %s\n"), i, playernode[i], player_names[i]); } + } } SINT8 nametonum(const char *name) diff --git a/src/p_inter.c b/src/p_inter.c index 127f31c10..e11329b79 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -831,7 +831,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { S_StartSound(toucher, special->info->seesound); - if (player->pflags & PF_NIGHTSMODE) + if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) { player->bumpertime = TICRATE/2; if (special->threshold > 0) @@ -1131,7 +1131,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) S_StartSound(toucher, special->info->painsound); return; } - else if (((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) + else if (UNLIKELY((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? { // Shatter the shield! diff --git a/src/p_local.h b/src/p_local.h index 82e3fb673..518bc12cb 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -30,8 +30,6 @@ extern "C" { #define FLOATSPEED (FRACUNIT*4) -//#define VIEWHEIGHTS "41" - // Maximum player score. #define MAXSCORE 999999990 @@ -239,14 +237,10 @@ void P_InstaThrustEvenIn2D(mobj_t *mo, angle_t angle, fixed_t move); boolean P_LookForEnemies(player_t *player); void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius); void P_HomingAttack(mobj_t *source, mobj_t *enemy); /// \todo doesn't belong in p_user -//boolean P_SuperReady(player_t *player); boolean P_AnalogMove(player_t *player); -/*boolean P_TransferToNextMare(player_t *player); -UINT8 P_FindLowestMare(void);*/ UINT8 P_FindLowestLap(void); UINT8 P_FindHighestLap(void); void P_FindEmerald(void); -//void P_TransferToAxis(player_t *player, INT32 axisnum); boolean P_PlayerMoving(INT32 pnum); void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range); diff --git a/src/p_mobj.c b/src/p_mobj.c index acc09ab58..d44a48f1c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -919,12 +919,7 @@ static void P_PlayerFlip(mobj_t *mo) G_GhostAddFlip((INT32) (mo->player - players)); // Flip aiming to match! - if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) // NiGHTS doesn't use flipcam - { - if (mo->tracer) - mo->tracer->eflags ^= MFE_VERTICALFLIP; - } - else if (mo->player->pflags & PF_FLIPCAM) + if (mo->player->pflags & PF_FLIPCAM) { UINT8 i; @@ -946,6 +941,11 @@ static void P_PlayerFlip(mobj_t *mo) camera[i].z += FixedMul(20*FRACUNIT, mo->scale); } } + else if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) // NiGHTS doesn't use flipcam + { + if (mo->tracer) + mo->tracer->eflags ^= MFE_VERTICALFLIP; + } } // @@ -3252,7 +3252,7 @@ void P_CalcChasePostImg(player_t *player, camera_t *thiscam) player_flipcam = cv_flipcam[pnum].value; } - const boolean flipcam = (player_flipcam && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); + const boolean flipcam = (player_flipcam && player->mo->eflags & MFE_VERTICALFLIP && LIKELY(!(player->pflags & PF_NIGHTSMODE))); UINT8 postimgtype = 0; if (encoremode) @@ -8553,7 +8553,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (mobj->tracer && mobj->tracer->player) { - if (!(mobj->tracer->player->pflags & PF_NIGHTSMODE)) + if (LIKELY(!(mobj->tracer->player->pflags & PF_NIGHTSMODE))) { mobj->flags &= ~MF_NOGRAVITY; mobj->flags2 &= ~MF2_DONTDRAW; @@ -8577,7 +8577,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_SetTarget(&mobj->target, NULL); } - if (mobj->tracer->player->pflags & PF_NIGHTSMODE) + if (UNLIKELY(mobj->tracer->player->pflags & PF_NIGHTSMODE)) { if (mobj->tracer->player->bonustime) { diff --git a/src/p_spec.c b/src/p_spec.c index e537e17e6..919be8031 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4399,7 +4399,7 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) // The list of specials that activate without floor touch // Check Section 1 - switch(GETSECSPECIAL(sector->special, 1)) + switch (GETSECSPECIAL(sector->special, 1)) { //case 2: // Damage (water) case 8: // Instant kill @@ -4410,7 +4410,7 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) } // Check Section 2 - switch(GETSECSPECIAL(sector->special, 2)) + switch (GETSECSPECIAL(sector->special, 2)) { case 2: // Linedef executor (All players needed) case 4: // Linedef executor @@ -4421,7 +4421,7 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) } // Check Section 4 - switch(GETSECSPECIAL(sector->special, 4)) + switch (GETSECSPECIAL(sector->special, 4)) { case 2: // Level Exit / GOAL Sector / Flag Return case 1: // Starpost activator diff --git a/src/p_user.c b/src/p_user.c index 15a71ebc8..99566aa24 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4109,7 +4109,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall angle -= (angle - thiscam->pitch)/2; } - if (player->playerstate != PST_DEAD && !((player->pflags & PF_NIGHTSMODE) && player->exiting)) + if (player->playerstate != PST_DEAD && LIKELY(!((player->pflags & PF_NIGHTSMODE) && player->exiting))) angle += (focusaiming < ANGLE_180 ? focusaiming/2 : InvAngle(InvAngle(focusaiming)/2)); // overcomplicated version of '((signed)focusaiming)/2;' if (!camstill && !timeover) // Keep the view still... From d77508f4819b1380f829b413c5580977e5ba9b88 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 15 Feb 2026 18:07:20 +0100 Subject: [PATCH 155/589] init superactions global was missed before --- src/command.c | 2 +- src/dehacked.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/command.c b/src/command.c index 0b1578381..c37b8f1d3 100644 --- a/src/command.c +++ b/src/command.c @@ -1178,7 +1178,7 @@ consvar_t *CV_FindVar(const char *name) consvar_t *cvar; for (cvar = consvar_vars; cvar; cvar = cvar->next) - if (fasticmp(name,cvar->name)) + if (fasticmp(name, cvar->name)) return cvar; return NULL; diff --git a/src/dehacked.c b/src/dehacked.c index a3540fdff..a3513fbbe 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -173,7 +173,7 @@ FUNCPRINTF static void deh_warning(const char *first, ...) vsnprintf(buf, 1000, first, argptr); // sizeof only returned 4 here. it didn't like that pointer. va_end(argptr); - if(dbg_line == -1) // Not in a SOC, line number unknown. + if (dbg_line == -1) // Not in a SOC, line number unknown. CONS_Alert(CONS_WARNING, "%s\n", buf); else CONS_Alert(CONS_WARNING, "Line %u: %s\n", dbg_line, buf); @@ -8545,7 +8545,7 @@ static inline int lib_action(lua_State *L) // Hardcoded A_Action name to call for super() or NULL if super() would be invalid. // Set in lua_infolib. -const char *superactions[MAXRECURSION]; +const char *superactions[MAXRECURSION] = {}; UINT8 superstack = 0; static int lib_dummysuper(lua_State *L) From 22a4fe63db1bf696769b4d2efbdb1233cedbc978 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Feb 2026 13:28:00 +0100 Subject: [PATCH 156/589] Fix minimap angle display colour for skins that use non default startcolor i.e. they use a different colour than "green" to remap their skincolor on --- src/k_hud.c | 27 ++++++++++++++++++++++----- src/k_kart.c | 11 ++++++++++- src/r_draw.cpp | 3 +-- src/r_skins.h | 1 + 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 4f10bf749..3df6f7af7 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -3816,7 +3816,7 @@ static void K_drawKartMinimap(void) if (cv_showminimapangle.value && (minidoticon || minilighticon) && !playertimedout) { - UINT8 *colormap; + UINT8 *colormap = NULL; drawinfo_t dims; fixed_t interpx, interpy; fixed_t xoff = 0, yoff = 0; @@ -3827,10 +3827,27 @@ static void K_drawKartMinimap(void) if (encoremode) ang = ANGLE_180 - ang; - if (mobj->colorized) - colormap = R_GetTranslationColormap(TC_RAINBOW, mobj->color, GTC_CACHE); - else - colormap = R_GetLocalTranslationColormap(mobj->skin, mobj->localskin, mobj->color, GTC_CACHE, mobj->skinlocal); + if (mobj->color) + { + if (mobj->colorized) + { + colormap = R_GetTranslationColormap(TC_RAINBOW, mobj->color, GTC_CACHE); + } + else + { + const INT32 skinnum = K_GetMobjLocalSkinNum(mobj->skin, mobj->localskin, mobj->skinlocal); + + // special case if startcolor is not the default (160 / Green) + if (skinnum && skins[skinnum].starttranscolor != skins[0].starttranscolor) + { + colormap = R_GetTranslationColormap(TC_DEFAULT, mobj->color, GTC_CACHE); + } + else + { + colormap = R_GetLocalTranslationColormap(mobj->skin, mobj->localskin, mobj->color, GTC_CACHE, mobj->skinlocal); + } + } + } interpx = lerp(mobj->old_x, mobj->x); interpy = lerp(mobj->old_y, mobj->y); diff --git a/src/k_kart.c b/src/k_kart.c index 747a032b2..0efd3a48b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -660,13 +660,22 @@ INT32 K_GetSkinNum(player_t *player) // // returns the mobj skinnumber -// accounts for localskins +// accounts for localskins ? // INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local) { return skin - K_GetSkinArray(local); } +// +// returns the mobj skinnumber +// accounts for localskins +// +INT32 K_GetMobjLocalSkinNum(const skin_t *skin, const skin_t *localskin, boolean local) +{ + return localskin ? (localskin - K_GetSkinArray(local)) : (skin - skins); +} + // // returns the players skinnumber // accounts for localskins diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 639107daa..97872aee1 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -437,8 +437,7 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags) UINT8* R_GetLocalTranslationColormap(skin_t *skin, skin_t *localskin, skincolors_t color, UINT8 flags, boolean local) { - const INT32 skinnum = localskin ? (localskin - K_GetSkinArray(local)) : (skin - skins); - return RGetTranslationColormap(skinnum, color, flags, (localskin && local)); + return RGetTranslationColormap(K_GetMobjLocalSkinNum(skin, localskin, local), color, flags, (localskin && local)); } patch_t* R_GetSkinFaceRank(player_t* ply) diff --git a/src/r_skins.h b/src/r_skins.h index 6231e8a18..929753855 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -92,6 +92,7 @@ INT32 R_LocalSkinAvailable(const char *name, boolean local); // had to move those here Zzz... INT32 K_GetSkinNum(player_t *player); INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local); +INT32 K_GetMobjLocalSkinNum(const skin_t *skin, const skin_t *localskin, boolean local); skin_t *K_GetPlayerSkin(player_t *player); skin_t *K_GetMobjSkin(const mobj_t *mobj); patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum); From 90a88983f1265333aa7b8a62ad331966670c3b51 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Feb 2026 13:28:48 +0100 Subject: [PATCH 157/589] k_hud: make the hud offset vars static --- src/k_hud.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 3df6f7af7..3fc83c10b 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -931,21 +931,21 @@ const char *K_GetItemPatch(UINT8 item, boolean tiny) //} -INT32 ITEM_X, ITEM_Y; // Item Window -INT32 TIME_X, TIME_Y; // Time Sticker -INT32 LAPS_X, LAPS_Y; // Lap Sticker -INT32 SPDM_X, SPDM_Y; // Speedometer -INT32 POSI_X, POSI_Y; // Position Number -INT32 FACE_X, FACE_Y; // Top-four Faces -INT32 STCD_X, STCD_Y; // Starting countdown -INT32 CHEK_Y; // CHECK graphic -INT32 MINI_X, MINI_Y; // Minimap -INT32 WANT_X, WANT_Y; // Battle WANTED poster +static INT32 ITEM_X, ITEM_Y; // Item Window +static INT32 TIME_X, TIME_Y; // Time Sticker +static INT32 LAPS_X, LAPS_Y; // Lap Sticker +static INT32 SPDM_X, SPDM_Y; // Speedometer +static INT32 POSI_X, POSI_Y; // Position Number +static INT32 FACE_X, FACE_Y; // Top-four Faces +static INT32 STCD_X, STCD_Y; // Starting countdown +static INT32 CHEK_Y; // CHECK graphic +static INT32 MINI_X, MINI_Y; // Minimap +static INT32 WANT_X, WANT_Y; // Battle WANTED poster // This is for the P2 and P4 side of splitscreen. Then we'll flip P1's and P2's to the bottom with V_SPLITSCREEN. -INT32 ITEM2_X, ITEM2_Y; -INT32 LAPS2_X, LAPS2_Y; -INT32 POSI2_X, POSI2_Y; +static INT32 ITEM2_X, ITEM2_Y; +static INT32 LAPS2_X, LAPS2_Y; +static INT32 POSI2_X, POSI2_Y; static void K_initKartHUD(void) { From 7746e494cf87c8aca6444cffced42f5d9ef1de4f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Feb 2026 13:32:04 +0100 Subject: [PATCH 158/589] fix memory leak within http masterserver handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit errbuf gets malloc´d! --- src/http-mserv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/http-mserv.c b/src/http-mserv.c index 9e4374353..7b5fac188 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -318,6 +318,7 @@ static void HMS_end (struct HMS_buffer *buffer) { curl_easy_cleanup(buffer->curl); + free(buffer->errbuf); free(buffer->buffer); free(buffer); } From 009df228d62a661024ed08c61aa580e4a5992aca Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Feb 2026 13:33:10 +0100 Subject: [PATCH 159/589] fix memory leak when fetching masterserver rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit strdup returns a malloc´d string! --- src/mserv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mserv.c b/src/mserv.c index 01af521e6..c91dacfcf 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -262,6 +262,7 @@ Finish_registration (void) { CONS_Printf("\n"); CONS_Alert(CONS_NOTICE, "%s\n", rules); + free(rules); } if (registered) From 1d6c27bacacf667130116049121e8da840d2e3d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Feb 2026 14:01:27 +0100 Subject: [PATCH 160/589] lua_pushlstring: prefer luaS_newlstr over luaS_new the latter calls strlen which is not needed as the empty string has no length --- src/blua/lapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index 557896f43..6a33983fe 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -434,7 +434,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { lua_lock(L); luaC_checkGC(L); - setsvalue2s(L, L->top, (len == 0) ? luaS_new(L, "") : luaS_newlstr(L, s, len)); + setsvalue2s(L, L->top, (len == 0) ? luaS_newlstr(L, "", 0) : luaS_newlstr(L, s, len)); api_incr_top(L); lua_unlock(L); } From f4dc161831a988e725e8639b9674984ebdf5f6bb Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 15:56:42 +0100 Subject: [PATCH 161/589] dont let SIGINT/SIGTERM do work in signal handler take 2 the earlier approach still raised the default signal within this, which basically just skipped everything and ended up NOT calling I_Quit at all Basically this is to ensure we dont call I_Quit at all from a signal handler as it is NOT async safe and can cause serious issues like deadlocks and such, instead SIGINT and SIGTERM will just signal the main loop/thread to safely call I_Quit instead --- src/d_main.c | 5 +++++ src/dedicated/i_system.c | 14 ++++++++++---- src/i_system.h | 4 ++++ src/sdl/i_system.cpp | 24 ++++++++++-------------- src/sdl/i_video.c | 3 ++- src/sdl/mixer_sound.c | 3 ++- 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 9d5b23f59..8bae5ea91 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -697,6 +697,11 @@ void D_SRB2Loop(void) for (;;) { + if (I_Interrupted()) + { + I_Quit(); + } + // capbudget is the minimum precise_t duration of a single loop iteration precise_t capbudget; precise_t elapsed; diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 437439010..311e936f3 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1067,11 +1067,17 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -FUNCNORETURN static ATTRNORETURN void quit_handler(int num) +static volatile sig_atomic_t interrupted = 0; + +boolean I_Interrupted(void) { - signal(num, SIG_DFL); //default signal action - raise(num); - I_Quit(); + return interrupted; +} + +static void quit_handler(int num) +{ + (void)num; + interrupted = 1; } #ifdef HAVE_LIBBACKTRACE diff --git a/src/i_system.h b/src/i_system.h index 97dfae9a1..958703a35 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -195,6 +195,10 @@ INT32 I_StartupSystem(void); */ void I_ShutdownSystem(void); +/** \brief To check if a Interrupt or Terminate Signal was fired + */ +boolean I_Interrupted(void); + /** \brief The I_GetDiskFreeSpace function \param freespace a INT64 pointer to hold the free space amount diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index b90fbf898..063b140e1 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1741,21 +1741,17 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -FUNCNORETURN static ATTRNORETURN void quit_handler(int num) -{ -#ifdef HAVE_THREADS - if (g_main_thread_id != std::this_thread::get_id()) - { - // Do not attempt any sort of recovery if this signal triggers off the main thread - signal(num, SIG_DFL); - raise(num); - exit(-2); - } -#endif +static volatile sig_atomic_t interrupted = 0; - signal(num, SIG_DFL); //default signal action - raise(num); - I_Quit(); +boolean I_Interrupted(void) +{ + return interrupted; +} + +static void quit_handler(int num) +{ + (void)num; + interrupted = 1; } static void I_RegisterSignals(void) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index e367b612f..813b6bfa0 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -2027,7 +2027,8 @@ void I_ShutdownGraphics(void) SDL_DestroyWindow(window); window = NULL; - SDL_QuitSubSystem(SDL_INIT_VIDEO); + if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO) + SDL_QuitSubSystem(SDL_INIT_VIDEO); framebuffer = SDL_FALSE; } diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 8de4eb746..7dccd9673 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -237,7 +237,8 @@ void I_ShutdownSound(void) Mix_Quit(); #endif - SDL_QuitSubSystem(SDL_INIT_AUDIO); + if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO) + SDL_QuitSubSystem(SDL_INIT_AUDIO); #ifdef HAVE_LIBGME if (gme) From e35dc9e0974da23276d6938e82f2e1057ed4fb92 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 16:20:48 +0100 Subject: [PATCH 162/589] fix g_in_exiting_signal_handler every "flag" set by signal handlers must be of type "volatile sig_atomic_t" everything else may fail to be correctly set, read or get optimized away which rendered this basically useless --- src/console.c | 10 +++++----- src/dedicated/i_system.c | 7 ++++++- src/i_system.h | 2 +- src/m_menu.c | 10 +++++----- src/sdl/i_system.cpp | 11 ++++++++--- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/console.c b/src/console.c index 88fe25000..09ac2e36d 100644 --- a/src/console.c +++ b/src/console.c @@ -46,16 +46,16 @@ #ifdef HAVE_THREADS I_mutex con_mutex; -// g_in_exiting_signal_handler is an evil hack +// I_In_Exiting_Signal_Handler is an evil hack // to avoid infinite SIGABRT recursion in the signal handler // due to poisoned locks or mach-o kernel not supporting locks in signals // or something like that. idk -# define Lock_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&con_mutex); } -# define Unlock_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(con_mutex); } -#else/*HAVE_THREADS*/ +# define Lock_state() if (!I_In_Exiting_Signal_Handler()) { I_LockMutex(&con_mutex); } +# define Unlock_state() if (!I_In_Exiting_Signal_Handler()) { I_UnlockMutex(con_mutex); } +#else /*HAVE_THREADS*/ # define Lock_state() # define Unlock_state() -#endif/*HAVE_THREADS*/ +#endif /*HAVE_THREADS*/ static boolean con_started = false; // console has been initialised boolean con_startup = false; // true at game startup, screen need refreshing diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 311e936f3..f6450134c 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -984,7 +984,7 @@ void I_SleepDuration(precise_t duration) #endif } -boolean g_in_exiting_signal_handler = false; +static volatile sig_atomic_t g_in_exiting_signal_handler = false; static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg) { @@ -1048,6 +1048,11 @@ static void I_ReportSignal(int num, int coredumped) I_OutputMsg("\nProcess killed by signal: %s\n\n", sigmsg); } +boolean I_In_Exiting_Signal_Handler(void) +{ + return g_in_exiting_signal_handler; +} + #ifndef NEWSIGNALHANDLER FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) { diff --git a/src/i_system.h b/src/i_system.h index 958703a35..45767f1f7 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -43,7 +43,7 @@ extern UINT8 graphics_started; extern UINT8 keyboard_started; /** \brief Set to true when inside a signal handler that will exit the program. */ -extern boolean g_in_exiting_signal_handler; +boolean I_In_Exiting_Signal_Handler(void); /** \brief The I_GetFreeMem function diff --git a/src/m_menu.c b/src/m_menu.c index 0e753f621..f2b3ac1bb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4016,16 +4016,16 @@ boolean replaynamesloaded = false; #ifdef HAVE_THREADS I_mutex replayquerymutex; -// g_in_exiting_signal_handler is an evil hack +// I_In_Exiting_Signal_Handler is an evil hack // to avoid infinite SIGABRT recursion in the signal handler // due to poisoned locks or mach-o kernel not supporting locks in signals // or something like that. idk -# define Lock_search_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&replayquerymutex); } -# define Unlock_search_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(replayquerymutex); } -#else/*HAVE_THREADS*/ +# define Lock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_LockMutex(&replayquerymutex); } +# define Unlock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_UnlockMutex(replayquerymutex); } +#else /*HAVE_THREADS*/ # define Lock_search_state() # define Unlock_search_state() -#endif/*HAVE_THREADS*/ +#endif /*HAVE_THREADS*/ #define MAXREPLAYQUERY 37 diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 063b140e1..5310cc855 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1577,7 +1577,7 @@ static void write_backtrace(bt_crash_reason_t reason) static std::thread::id g_main_thread_id; #endif -boolean g_in_exiting_signal_handler = false; +static volatile sig_atomic_t g_in_exiting_signal_handler = false; static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg, char *signal_name) { @@ -1712,6 +1712,11 @@ static void I_ReportSignal(int num, int coredumped) I_ShowErrorBox(sigttl, sigmsg); } +boolean I_In_Exiting_Signal_Handler(void) +{ + return g_in_exiting_signal_handler; +} + #ifndef NEWSIGNALHANDLER FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) { @@ -1741,7 +1746,7 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -static volatile sig_atomic_t interrupted = 0; +static volatile sig_atomic_t interrupted = false; boolean I_Interrupted(void) { @@ -1751,7 +1756,7 @@ boolean I_Interrupted(void) static void quit_handler(int num) { (void)num; - interrupted = 1; + interrupted = true; } static void I_RegisterSignals(void) From cd02242a014cbb21366ab65352d01d3dedf3a012 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 17:01:14 +0100 Subject: [PATCH 163/589] fix splitscreen clients being unable to join saturn servers lmao oops idk dumb copy paste sry --- src/d_clisrv.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1ec57eaaf..27206b337 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4121,7 +4121,7 @@ static void Command_ResendGamestate(void) } playernum = nametonum(COM_Argv(1)); - if (playernum == -1 || playernum == 0) + if (playernum <= 0) return; doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); @@ -4591,7 +4591,7 @@ static boolean SV_AddWaitingPlayers(SINT8 node) for (n = 0; n < MAXNETNODES; n++) { - if (nodetoplayer[n] == newplayernum || + if (nodetoplayer[n] == newplayernum || nodetoplayer2[n] == newplayernum || nodetoplayer3[n] == newplayernum || nodetoplayer4[n] == newplayernum) @@ -4883,10 +4883,6 @@ static const char *GetRefuseMessage(SINT8 node) { return va("Maximum players reached: %d", maxplayers); } - else if (cc->localplayers != 1) - { - return "Wrong player count."; - } else if (netgame && !cc->localplayers) // Stealth join? { return "No players from\nthis node."; From fdccf868cc388614df67b4d6c9be483f768a808f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 17:09:21 +0100 Subject: [PATCH 164/589] disable player fade if viewplayer is spectator fixes some wonky stuff like players disappearing when they were close to the invisible spectator player and you werent watching someone else --- src/r_things.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 60b0bbd52..9da1f4c3e 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2960,7 +2960,7 @@ fixed_t R_DoPlayerFade(mobj_t *thing) fixed_t fadealpha = FRACUNIT; static constexpr tic_t countdownstarttime = (15 * TICRATE) / 4; // starttime - (3*TICRATE) - if (thing->player == viewplayer || viewplayer->exiting || camera[R_GetViewNumber()].freecam || leveltime < countdownstarttime) + if (thing->player == viewplayer || viewplayer->exiting || viewplayer->spectator || camera[R_GetViewNumber()].freecam || leveltime < countdownstarttime) return fadealpha; const INT32 playerdist = (FixedMul((thing->x - viewx), viewcos) + FixedMul((thing->y - viewy), viewsin)) >> FRACBITS; From 1265bbba2efd8352512d527838c6f6803edf40c5 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 23 Feb 2026 19:12:42 +0300 Subject: [PATCH 165/589] Rename I_LockMutex back into I_lock_mutex for now --- src/console.c | 4 ++-- src/m_menu.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/console.c b/src/console.c index 09ac2e36d..7276b59c8 100644 --- a/src/console.c +++ b/src/console.c @@ -50,8 +50,8 @@ I_mutex con_mutex; // to avoid infinite SIGABRT recursion in the signal handler // due to poisoned locks or mach-o kernel not supporting locks in signals // or something like that. idk -# define Lock_state() if (!I_In_Exiting_Signal_Handler()) { I_LockMutex(&con_mutex); } -# define Unlock_state() if (!I_In_Exiting_Signal_Handler()) { I_UnlockMutex(con_mutex); } +# define Lock_state() if (!I_In_Exiting_Signal_Handler()) { I_lock_mutex(&con_mutex); } +# define Unlock_state() if (!I_In_Exiting_Signal_Handler()) { I_unlock_mutex(con_mutex); } #else /*HAVE_THREADS*/ # define Lock_state() # define Unlock_state() diff --git a/src/m_menu.c b/src/m_menu.c index f2b3ac1bb..79879032e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4020,8 +4020,8 @@ I_mutex replayquerymutex; // to avoid infinite SIGABRT recursion in the signal handler // due to poisoned locks or mach-o kernel not supporting locks in signals // or something like that. idk -# define Lock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_LockMutex(&replayquerymutex); } -# define Unlock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_UnlockMutex(replayquerymutex); } +# define Lock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_lock_mutex(&replayquerymutex); } +# define Unlock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_unlock_mutex(replayquerymutex); } #else /*HAVE_THREADS*/ # define Lock_search_state() # define Unlock_search_state() From 4623f8aff2ff16edf4a112230dfed2af95c6e9d2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 17:56:41 +0100 Subject: [PATCH 166/589] explicitly set "std=gnu17" we *rely* on a bunch of gnu extensions so its better to explicitly set this yes in theory we fully comply with c23/gnu23 and saturn compiles fine under that, but since its still fairly new theres alot of maschines that still dont support it :chaosleep: --- src/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile b/src/Makefile index 0456990f3..be4f995db 100644 --- a/src/Makefile +++ b/src/Makefile @@ -295,6 +295,7 @@ opts+=$(debug_opts) opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v))) +CWFLAGS+=-std=gnu17 CXXFLAGS+=-std=c++17 # force c17 for c++ since most vpss run older ubuntu versions with old compilers opts+=$(WFLAGS) $(CFLAGS) From 355c78e07529c074620a72a1b9d1a6ab529a2418 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 17:51:06 +0100 Subject: [PATCH 167/589] check for _GNU_SOURCE for nongnu_strcasestr idk we dont need it and it throws warnings on new glibc so i dont want it tbh --- src/doomtype.h | 2 +- src/strcasestr.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index ed6248129..0e6b6ef5d 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -68,8 +68,8 @@ extern "C" { #define strnicmp(x,y,n) strncasecmp(x,y,n) #endif -char *nongnu_strcasestr(const char *in, const char *what); #ifndef _GNU_SOURCE +char *nongnu_strcasestr(const char *in, const char *what); #define strcasestr nongnu_strcasestr #endif diff --git a/src/strcasestr.c b/src/strcasestr.c index f05449778..84bc0671e 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -23,24 +23,26 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef _GNU_SOURCE + #include #include #include -static inline int -trycmp (char **pp, char *cp, - const char *q, size_t qn) +static inline int trycmp(char **pp, char *cp, const char *q, size_t qn) { char *p; p = (*pp); + if (strncasecmp(p, q, qn) == 0) return 0; + (*pp) = strchr(&p[1], (*cp)); + return 1; } -static inline void -swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) +static inline void swapp(char ***ppap, char ***ppbp, char **cpap, char **cpbp) { char **pp; char *p; @@ -54,8 +56,7 @@ swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) *cpbp = p; } -char * -nongnu_strcasestr (const char *s, const char *q) +char *nongnu_strcasestr(const char *s, const char *q) { size_t qn; @@ -113,3 +114,5 @@ nongnu_strcasestr (const char *s, const char *q) return NULL; } + +#endif From a9a0d4bed8bf92319ef34ca8e49b55157555ddd1 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 17:54:51 +0100 Subject: [PATCH 168/589] fix compiler warnings for glibc 2.43 and newer this version changed so that many standard functions now propagate the constness of its input pointers to not cause warnings for everyone on older versions this is now a really dumb macro lol --- src/d_main.c | 2 +- src/doomtype.h | 9 +++++++++ src/g_game.c | 3 +++ src/hardware/hw_shaders.c | 2 +- src/hardware/r_opengl/r_opengl.c | 6 +++--- src/m_misc.c | 6 +++--- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 8bae5ea91..2832d6c6a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -2023,7 +2023,7 @@ void D_SRB2Main(void) if (M_CheckProtoParam("replay")) { const char *replayurl = M_GetProtoParam(); - char *replayname = strrchr(replayurl, '/'); + gconst char *replayname = strrchr(replayurl, '/'); if (!replayname || !replayurl) I_Error("REPLAY: Invalid URL."); diff --git a/src/doomtype.h b/src/doomtype.h index 0e6b6ef5d..b7f8a73e5 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -68,6 +68,15 @@ extern "C" { #define strnicmp(x,y,n) strncasecmp(x,y,n) #endif +// glibc 2.43 made alot of standard lib functions propagate the constness of its input pointers +// to not cause warnings or compile issues on older glibc versions we do this silly thing +// to not have a gazillion glibc version checks +#if __GLIBC_PREREQ(2, 43) + #define gconst const +#else + #define gconst +#endif + #ifndef _GNU_SOURCE char *nongnu_strcasestr(const char *in, const char *what); #define strcasestr nongnu_strcasestr diff --git a/src/g_game.c b/src/g_game.c index a79a957ef..e4e0601f0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4153,6 +4153,7 @@ static void measurekeywords(mapsearchfreq_t *fr, { char *qp; char *sp; + if (wanttable) (*dimp) = Z_Realloc((*dimp), 255 * sizeof (struct searchdim), PU_STATIC, NULL); @@ -4167,10 +4168,12 @@ static void measurekeywords(mapsearchfreq_t *fr, (*dimp)[(*cuntp)].pos = sp - s; (*dimp)[(*cuntp)].siz = strlen(qp); } + (*cuntp)++; fr->total++; } } + if (wanttable) (*dimp) = Z_Realloc((*dimp), (*cuntp) * sizeof (struct searchdim), PU_STATIC, NULL); diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 28f8e46d7..90d019b2b 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -109,7 +109,7 @@ boolean HWR_InitShaders(void) // returns INT32_MAX if not found static INT32 strstr_int(const char *str1, const char *str2) { - char *location = strstr(str1, str2); + gconst char *location = strstr(str1, str2); if (location) return location - str1; else diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index eeb40a8dc..a759b8b2b 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1383,19 +1383,19 @@ void GL_Flush(void) // -----------------+ INT32 GL_isExtAvailable(const char *extension, const GLubyte *start) { - GLubyte *where, *terminator; + gconst GLubyte *where, *terminator; if (!extension || !start) return 0; - where = (GLubyte *) strchr(extension, ' '); + where = (gconst GLubyte *)strchr(extension, ' '); if (where || *extension == '\0') return 0; for (;;) { - where = (GLubyte *) strstr((const char *) start, extension); + where = (gconst GLubyte *)strstr((const char *)start, extension); if (!where) break; diff --git a/src/m_misc.c b/src/m_misc.c index 3a456d7a7..ee17e2098 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1454,9 +1454,9 @@ INT32 axtoi(const char *hexStg) void CopyCaretColors(char *p, const char *s, int n) { - char *t; - int m; - int c; + gconst char *t; + int m; + int c; if (!n) return; From 6f2aba7ee3c47a9cedbd45fc177300f793555961 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 18:10:05 +0100 Subject: [PATCH 169/589] Windows is such a cool Operating System idk why we just dont use int32 there aswell and rely on whatever tf windows supplies which i dont trust ffs --- src/doomtype.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index b7f8a73e5..7d6017e27 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -71,11 +71,15 @@ extern "C" { // glibc 2.43 made alot of standard lib functions propagate the constness of its input pointers // to not cause warnings or compile issues on older glibc versions we do this silly thing // to not have a gazillion glibc version checks +#if defined(__GLIBC_PREREQ) #if __GLIBC_PREREQ(2, 43) #define gconst const #else #define gconst #endif +#else + #define gconst +#endif #ifndef _GNU_SOURCE char *nongnu_strcasestr(const char *in, const char *what); @@ -136,9 +140,9 @@ size_t strlcpy(char *dst, const char *src, size_t dsize); #define STRBUFCPY(dst,src) strlcpy(dst, src, sizeof dst) /* Boolean type definition */ +#include #ifndef _WIN32 -#include // dont use stdbools _BOOL type // its smaller (1 byte) than the old interger bool (4 bytes) // which results in packed struct sizes being mismatched between vanilla and this @@ -146,9 +150,7 @@ size_t strlcpy(char *dst, const char *src, size_t dsize); // which we cant use as enumeration constants typedef int32_t boolean; #else -#define false FALSE -#define true TRUE -#define boolean BOOL +#define boolean int32_t #endif /* 7.18.2.1 Limits of exact-width integer types */ From a287a6419f6a5857ecf163ad4bc46a98eb0da8df Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 23 Feb 2026 22:42:57 +0300 Subject: [PATCH 170/589] Use strncpy for zip entry filename because it might not be null-terminated inside zip --- src/w_wad.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 3009d503f..8cc3fd214 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -696,7 +696,8 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) lump_p->size = LONG(zentry->size); fullname = (char*)(malloc(SHORT(zentry->namelen) + 1)); - strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); + strncpy(fullname, (char *)(zentry + 1), SHORT(zentry->namelen)); + fullname[zentry->namelen] = 0; // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != NULL) @@ -2237,7 +2238,8 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) if (verified == true) { fullname = (char*)(malloc(SHORT(zentry->namelen) + 1)); - strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); + strncpy(fullname, (char *)(zentry + 1), SHORT(zentry->namelen)); + fullname[zentry->namelen] = 0; // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != NULL) @@ -2482,7 +2484,8 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) } fullname = (char*)(malloc(SHORT(zentry->namelen) + 1)); - strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); + strncpy(fullname, (char *)(zentry + 1), SHORT(zentry->namelen)); + fullname[zentry->namelen] = 0; // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != NULL) From 2f684bba95a11f85961b7be842f7e0411415ac68 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 24 Feb 2026 12:34:11 +0100 Subject: [PATCH 171/589] ensure SIGINT/SIGTERM can quit out from wipes and serverconnection ticker --- src/d_clisrv.c | 5 +++++ src/f_wipe.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2f3440362..0241f06e0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2782,6 +2782,11 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic { INT32 key; + if (I_Interrupted()) + { + I_Quit(); + } + I_OsPolling(); if (cl_mode == CL_CONFIRMCONNECT) diff --git a/src/f_wipe.c b/src/f_wipe.c index 6615cb53c..18100da4c 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -361,6 +361,11 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu) // on for fade-to-black for (;;) { + if (I_Interrupted()) + { + I_Quit(); + } + // get fademask first so we can tell if it exists or not fmask = F_GetFadeMask(wipetype, wipeframe++); From 014a22e9336e4b5d34bdda2afbd61ca12de07c7a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 24 Feb 2026 16:06:27 +0100 Subject: [PATCH 172/589] w_wad: replace unordered_map with verstable hashmap for lumpnumcache + convert back to C from C++ been rethinking this and been doing some digging online the unordered_map was just a quick and simple fix for performance issues in blan, but came with caveats: - unordered_map is simple to use but not particulary great in terms of performance during lookups especially - we needed to convert w_wad to c++ just for the lumpnumcache - due to needing to preserve the key since they gotta outlive the scope of the function that inserts things into the map, we effectively did a string copy on each map insert and lookup after some research came across verstable, which is basically almost the exact same as unordered map but in C while being extremely fast (even more with its builtin string hash and comparisor) only caveat with verstable is we need to rely on a new lib, though its just a single header file, and we gotta manage ensuring the input keys outlive functionscope ourselves, which we do with strdup in this case good thing, verstable allows to call a "destructor" specified by us whenever it removes or replaces keys in the map this also means we only need to copy strings on insert and not on lookup anymore all in all this is much faster while giving us the simple usage of c++ unordered_map while staying in C due to the strdup quirk i had to slightly modify verstable to allow to take const as inputs for the getter functions even if the keys themselves are not const marked with "KEY_GET_CONST" Verstable can be found here: https://github.com/JacksonAllan/Verstable and is licensed under MIT which is perfect! --- src/Sourcefile | 2 +- src/dedicated/i_system.c | 1 + src/sdl/i_system.cpp | 3 + src/verstable.h | 2119 ++++++++++++++++++++++++++++++++++++ src/{w_wad.cpp => w_wad.c} | 236 ++-- src/w_wad.h | 2 +- 6 files changed, 2248 insertions(+), 115 deletions(-) create mode 100644 src/verstable.h rename src/{w_wad.cpp => w_wad.c} (90%) diff --git a/src/Sourcefile b/src/Sourcefile index 2c4024f5f..08c18ebf0 100644 --- a/src/Sourcefile +++ b/src/Sourcefile @@ -45,7 +45,7 @@ sounds.c st_stuff.c tables.c v_video.c -w_wad.cpp +w_wad.c y_inter.c z_zone.cpp r_bsp.cpp diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index f6450134c..ddc17d6a5 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1384,6 +1384,7 @@ static void I_Fork(void) INT32 I_StartupSystem(void) { + W_Startup(); I_StartupConsole(); #ifdef NEWSIGNALHANDLER // This is useful when debugging. It lets GDB attach to diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 5310cc855..407e5c3a0 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1886,6 +1886,9 @@ INT32 I_StartupSystem(void) SDL_version SDLlinked; SDL_VERSION(&SDLcompiled) SDL_GetVersion(&SDLlinked); + + W_Startup(); + I_StartupConsole(); #ifdef NEWSIGNALHANDLER // This is useful when debugging. It lets GDB attach to diff --git a/src/verstable.h b/src/verstable.h new file mode 100644 index 000000000..8c5a49dc3 --- /dev/null +++ b/src/verstable.h @@ -0,0 +1,2119 @@ +/*------------------------------------------------- VERSTABLE v2.2.1 --------------------------------------------------- + +Verstable is a C99-compatible, open-addressing hash table using quadratic probing and the following additions: + +* All keys that hash (i.e. "belong") to the same bucket (their "home bucket") are linked together by an 11-bit integer + specifying the quadratic displacement, relative to that bucket, of the next key in the chain. + +* If a chain of keys exists for a given bucket, then it always begins at that bucket. To maintain this policy, a 1-bit + flag is used to mark whether the key occupying a bucket belongs there. When inserting a new key, if the bucket it + belongs to is occupied by a key that does not belong there, then the occupying key is evicted and the new key takes + the bucket. + +* A 4-bit fragment of each key's hash code is also stored. + +* The aforementioned metadata associated with each bucket (the 4-bit hash fragment, the 1-bit flag, and the 11-bit link + to the next key in the chain) are stored together in a uint16_t array rather than in the bucket alongside the key and + (optionally) the value. + +One way to conceptualize this scheme is as a chained hash table in which overflowing keys are stored not in separate +memory allocations but in otherwise unused buckets. In this regard, it shares similarities with Malte Skarupke's Bytell +hash table (https://www.youtube.com/watch?v=M2fKMP47slQ) and traditional "coalesced hashing". + +Advantages of this scheme include: + +* Fast lookups impervious to load factor: If the table contains any key belonging to the lookup key's home bucket, then + that bucket contains the first in a traversable chain of all keys belonging to it. Hence, only the home bucket and + other buckets containing keys belonging to it are ever probed. Moreover, the stored hash fragments allow skipping most + non-matching keys in the chain without accessing the actual buckets array or calling the (potentially expensive) key + comparison function. + +* Fast insertions: Insertions are faster than they are in other schemes that move keys around (e.g. Robin Hood) because + they only move, at most, one existing key. + +* Fast, tombstone-free deletions: Deletions, which usually require tombstones in quadratic-probing hash tables, are + tombstone-free and only move, at most, one existing key. + +* Fast iteration: The separate metadata array allows keys in sparsely populated tables to be found without incurring the + frequent cache misses that would result from traversing the buckets array. + +Usage example: + + +---------------------------------------------------------+----------------------------------------------------------+ + | Using the generic macro API (C11 and later): | Using the prefixed functions API (C99 and later): | + +---------------------------------------------------------+----------------------------------------------------------+ + | #include | #include | + | | | + | // Instantiating a set template. | // Instantiating a set template. | + | #define NAME int_set | #define NAME int_set | + | #define KEY_TY int | #define KEY_TY int | + | #include "verstable.h" | #define HASH_FN vt_hash_integer | + | | #define CMPR_FN vt_cmpr_integer | + | // Instantiating a map template. | #include "verstable.h" | + | #define NAME int_int_map | | + | #define KEY_TY int | // Instantiating a map template. | + | #define VAL_TY int | #define NAME int_int_map | + | #include "verstable.h" | #define KEY_TY int | + | | #define VAL_TY int | + | int main( void ) | #define HASH_FN vt_hash_integer | + | { | #define CMPR_FN vt_cmpr_integer | + | // Set. | #include "verstable.h" | + | | | + | int_set our_set; | int main( void ) | + | vt_init( &our_set ); | { | + | | // Set. | + | // Inserting keys. | | + | for( int i = 0; i < 10; ++i ) | int_set our_set; | + | { | int_set_init( &our_set ); | + | int_set_itr itr = vt_insert( &our_set, i ); | | + | if( vt_is_end( itr ) ) | // Inserting keys. | + | { | for( int i = 0; i < 10; ++i ) | + | // Out of memory, so abort. | { | + | vt_cleanup( &our_set ); | int_set_itr itr = | + | return 1; | int_set_insert( &our_set, i ); | + | } | if( int_set_is_end( itr ) ) | + | } | { | + | | // Out of memory, so abort. | + | // Erasing keys. | int_set_cleanup( &our_set ); | + | for( int i = 0; i < 10; i += 3 ) | return 1; | + | vt_erase( &our_set, i ); | } | + | | } | + | // Retrieving keys. | | + | for( int i = 0; i < 10; ++i ) | // Erasing keys. | + | { | for( int i = 0; i < 10; i += 3 ) | + | int_set_itr itr = vt_get( &our_set, i ); | int_set_erase( &our_set, i ); | + | if( !vt_is_end( itr ) ) | | + | printf( "%d ", itr.data->key ); | // Retrieving keys. | + | } | for( int i = 0; i < 10; ++i ) | + | // Printed: 1 2 4 5 7 8 | { | + | | int_set_itr itr = int_set_get( &our_set, i ); | + | // Iteration. | if( !int_set_is_end( itr ) ) | + | for( | printf( "%d ", itr.data->key ); | + | int_set_itr itr = vt_first( &our_set ); | } | + | !vt_is_end( itr ); | // Printed: 1 2 4 5 7 8 | + | itr = vt_next( itr ) | | + | ) | // Iteration. | + | printf( "%d ", itr.data->key ); | for( | + | // Printed: 2 4 7 1 5 8 | int_set_itr itr = | + | | int_set_first( &our_set ); | + | vt_cleanup( &our_set ); | !int_set_is_end( itr ); | + | | itr = int_set_next( itr ) | + | // Map. | ) | + | | printf( "%d ", itr.data->key ); | + | int_int_map our_map; | // Printed: 2 4 7 1 5 8 | + | vt_init( &our_map ); | | + | | int_set_cleanup( &our_set ); | + | // Inserting keys and values. | | + | for( int i = 0; i < 10; ++i ) | // Map. | + | { | | + | int_int_map_itr itr = | int_int_map our_map; | + | vt_insert( &our_map, i, i + 1 ); | int_int_map_init( &our_map ); | + | if( vt_is_end( itr ) ) | | + | { | // Inserting keys and values. | + | // Out of memory, so abort. | for( int i = 0; i < 10; ++i ) | + | vt_cleanup( &our_map ); | { | + | return 1; | int_int_map_itr itr = | + | } | int_int_map_insert( &our_map, i, i + 1 ); | + | } | if( int_int_map_is_end( itr ) ) | + | | { | + | // Erasing keys and values. | // Out of memory, so abort. | + | for( int i = 0; i < 10; i += 3 ) | int_int_map_cleanup( &our_map ); | + | vt_erase( &our_map, i ); | return 1; | + | | } | + | // Retrieving keys and values. | } | + | for( int i = 0; i < 10; ++i ) | | + | { | // Erasing keys and values. | + | int_int_map_itr itr = vt_get( &our_map, i ); | for( int i = 0; i < 10; i += 3 ) | + | if( !vt_is_end( itr ) ) | int_int_map_erase( &our_map, i ); | + | printf( | | + | "%d:%d ", | // Retrieving keys and values. | + | itr.data->key, | for( int i = 0; i < 10; ++i ) | + | itr.data->val | { | + | ); | int_int_map_itr itr = | + | } | int_int_map_get( &our_map, i ); | + | // Printed: 1:2 2:3 4:5 5:6 7:8 8:9 | if( !int_int_map_is_end( itr ) ) | + | | printf( | + | // Iteration. | "%d:%d ", | + | for( | itr.data->key, | + | int_int_map_itr itr = vt_first( &our_map ); | itr.data->val | + | !vt_is_end( itr ); | ); | + | itr = vt_next( itr ) | } | + | ) | // Printed: 1:2 2:3 4:5 5:6 7:8 8:9 | + | printf( | | + | "%d:%d ", | // Iteration. | + | itr.data->key, | for( | + | itr.data->val | int_int_map_itr itr = | + | ); | int_int_map_first( &our_map ); | + | // Printed: 2:3 4:5 7:8 1:2 5:6 8:9 | !int_int_map_is_end( itr ); | + | | itr = int_int_map_next( itr ) | + | vt_cleanup( &our_map ); | ) | + | } | printf( | + | | "%d:%d ", | + | | itr.data->key, | + | | itr.data->val | + | | ); | + | | // Printed: 2:3 4:5 7:8 1:2 5:6 8:9 | + | | | + | | int_int_map_cleanup( &our_map ); | + | | } | + | | | + +---------------------------------------------------------+----------------------------------------------------------+ + +API: + + Instantiating a hash table template: + + Create a new hash table type in the following manner: + + #define NAME + #define KEY_TY + #include "verstable.h" + + The NAME macro specifies the name of hash table type that the library will declare, the prefix for the functions + associated with it, and the prefix for the associated iterator type. + + The KEY_TY macro specifies the key type. + + In C99, it is also always necessary to define HASH_FN and CMPR_FN (see below) before including the header. + + The following macros may also be defined before including the header: + + #define KEY_GET_CONST + + Forces the key getter to take a const pointer even if the input key is not marked const + + #define VAL_TY + + The type of the value associated with each key. + If this macro is defined, the hash table acts as a map associating keys with values. + Otherwise, it acts as a set containing only keys. + + #define HASH_FN + + The name of the existing function used to hash each key. + The function should have the signature uint64_t ( KEY_TY key ) and return a 64-bit hash code. + For best performance, the hash function should provide a high level of entropy across all bits. + There are two default hash functions: vt_hash_integer for all integer types up to 64 bits in size, and + vt_hash_string for NULL-terminated strings (i.e. char *). + When KEY_TY is one of such types and the compiler is in C11 mode or later, HASH_FN may be left undefined, in + which case the appropriate default function is inferred from KEY_TY. + Otherwise, HASH_FN must be defined. + + #define CMPR_FN + + The name of the existing function used to compare two keys. + The function should have the signature bool ( KEY_TY key_1, KEY_TY key_2 ) and return true if the two keys are + equal. + There are two default comparison functions: vt_cmpr_integer for all integer types up to 64 bits in size, and + vt_cmpr_string for NULL-terminated strings (i.e. char *). + As with the default hash functions, in C11 or later the appropriate default comparison function is inferred if + KEY_TY is one of such types and CMPR_FN is left undefined. + Otherwise, CMPR_FN must be defined. + + #define MAX_LOAD + + The floating-point load factor at which the hash table automatically doubles the size of its internal buckets + array. + The default is 0.9, i.e. 90%. + + #define KEY_DTOR_FN + + The name of the existing destructor function, with the signature void ( KEY_TY key ), called on a key when it is + erased from the table or replaced by a newly inserted key. + The API functions that may call the key destructor are NAME_insert, NAME_erase, NAME_erase_itr, NAME_clear, + and NAME_cleanup. + + #define VAL_DTOR_FN + + The name of the existing destructor function, with the signature void ( VAL_TY val ), called on a value when it + is erased from the table or replaced by a newly inserted value. + The API functions that may call the value destructor are NAME_insert, NAME_erase, NAME_erase_itr, NAME_clear, + and NAME_cleanup. + + #define CTX_TY + + The type of the hash table type's ctx (context) member. + This member only exists if CTX_TY was defined. + It is intended to be used in conjunction with MALLOC_FN and FREE_FN (see below). + + #define MALLOC_FN + + The name of the existing function used to allocate memory. + If CTX_TY was defined, the signature should be void *( size_t size, CTX_TY *ctx ), where size is the number of + bytes to allocate and ctx points to the table's ctx member. + Otherwise, the signature should be void *( size_t size ). + The default wraps stdlib.h's malloc. + + #define FREE_FN + + The name of the existing function used to free memory. + If CTX_TY was defined, the signature should be void ( void *ptr, size_t size, CTX_TY *ctx ), where ptr points to + the memory to free, size is the number of bytes that were allocated, and ctx points to the table's ctx member. + Otherwise, the signature should be void ( void *ptr, size_t size ). + The default wraps stdlib.h's free. + + #define HEADER_MODE + #define IMPLEMENTATION_MODE + + By default, all hash table functions are defined as static inline functions, the intent being that a given hash + table template should be instantiated once per translation unit; for best performance, this is the recommended + way to use the library. + However, it is also possible to separate the struct definitions and function declarations from the function + definitions such that one implementation can be shared across all translation units (as in a traditional header + and source file pair). + In that case, instantiate a template wherever it is needed by defining HEADER_MODE, along with only NAME, + KEY_TY, and (optionally) VAL_TY, CTX_TY, and header guards, and including the library, e.g.: + + #ifndef INT_INT_MAP_H + #define INT_INT_MAP_H + #define NAME int_int_map + #define KEY_TY int + #define VAL_TY int + #define HEADER_MODE + #include "verstable.h" + #endif + + In one source file, define IMPLEMENTATION_MODE, along with NAME, KEY_TY, and any of the aforementioned optional + macros, and include the library, e.g.: + + #define NAME int_int_map + #define KEY_TY int + #define VAL_TY int + #define HASH_FN vt_hash_integer // C99. + #define CMPR_FN vt_cmpr_integer // C99. + #define MAX_LOAD 0.8 + #define IMPLEMENTATION_MODE + #include "verstable.h" + + Including the library automatically undefines all the aforementioned macros after they have been used to instantiate + the template. + + Functions: + + The functions associated with a hash table type are all prefixed with the name the user supplied via the NAME macro. + In C11 and later, the generic "vt_"-prefixed macros may be used to automatically select the correct version of the + specified function based on the arguments. + + void NAME_init( NAME *table ) + void NAME_init( NAME *table, CTX_TY ctx ) + // C11 generic macro: vt_init. + + Initializes the table for use. + If CTX_TY was defined, ctx sets the table's ctx member. + + bool NAME_init_clone( NAME *table, NAME *source ) + bool NAME_init_clone( NAME *table, NAME *source, CTX_TY ctx ) + // C11 generic macro: vt_init_clone. + + Initializes the table as a shallow copy of the specified source table. + If CTX_TY was defined, ctx sets the table's ctx member. + Returns false in the case of memory allocation failure. + + size_t NAME_size( NAME *table ) // C11 generic macro: vt_size. + + Returns the number of keys currently in the table. + + size_t NAME_bucket_count( NAME *table ) // C11 generic macro: vt_bucket_count. + + Returns the table's current bucket count. + + NAME_itr NAME_insert( NAME *table, KEY_TY key ) + NAME_itr NAME_insert( NAME *table, KEY_TY key, VAL_TY val ) + // C11 generic macro: vt_insert. + + Inserts the specified key (and value, if VAL_TY was defined) into the hash table. + If the same key already exists, then the new key (and value) replaces the existing key (and value). + Returns an iterator to the new key, or an end iterator in the case of memory allocation failure. + + NAME_itr NAME_get_or_insert( NAME *table, KEY_TY key ) + NAME_itr NAME_get_or_insert( NAME *table, KEY_TY key, VAL_TY val ) + // C11 generic macro: vt_get_or_insert. + + Inserts the specified key (and value, if VAL_TY was defined) if it does not already exist in the table. + Returns an iterator to the new key if it was inserted, or an iterator to the existing key, or an end iterator if + the key did not exist but the new key could not be inserted because of memory allocation failure. + Determine whether the key was inserted by comparing the table's size before and after the call. + + NAME_itr NAME_get( NAME *table, KEY_TY key ) // C11 generic macro: vt_get. + + Returns a iterator to the specified key, or an end iterator if no such key exists. + + bool NAME_erase( NAME *table, KEY_TY key ) // C11 generic macro: vt_erase. + + Erases the specified key (and associated value, if VAL_TY was defined), if it exists. + Returns true if a key was erased. + + NAME_itr NAME_erase_itr( NAME *table, NAME_itr itr ) // C11 generic macro: vt_erase_itr. + + Erases the key (and associated value, if VAL_TY was defined) pointed to by the specified iterator. + Returns an iterator to the next key in the table, or an end iterator if the erased key was the last one. + + bool NAME_reserve( NAME *table, size_t size ) // C11 generic macro: vt_reserve. + + Ensures that the bucket count is large enough to support the specified key count (i.e. size) without rehashing. + Returns false if unsuccessful due to memory allocation failure. + + bool NAME_shrink( NAME *table ) // C11 generic macro: vt_shrink. + + Shrinks the bucket count to best accommodate the current size. + Returns false if unsuccessful due to memory allocation failure. + + NAME_itr NAME_first( NAME *table ) // C11 generic macro: vt_first. + + Returns an iterator to the first key in the table, or an end iterator if the table is empty. + + bool NAME_is_end( NAME_itr itr ) // C11 generic macro: vt_is_end. + + Returns true if the iterator is an end iterator. + + NAME_itr NAME_next( NAME_itr itr ) // C11 generic macro: vt_next. + + Returns an iterator to the key after the one pointed to by the specified iterator, or an end iterator if the + specified iterator points to the last key in the table. + + void NAME_clear( NAME *table ) // C11 generic macro: vt_clear. + + Erases all keys (and values, if VAL_TY was defined) in the table. + + void NAME_cleanup( NAME *table ) // C11 generic macro: vt_cleanup. + + Erases all keys (and values, if VAL_TY was defined) in the table, frees all memory associated with it, and + initializes it for reuse. + + Iterators: + + Access the key (and value, if VAL_TY was defined) that an iterator points to using the NAME_itr struct's data + member: + + itr.data->key + itr.data->val + + Functions that may insert new keys (NAME_insert and NAME_get_or_insert), erase keys (NAME_erase and NAME_erase_itr), + or reallocate the internal bucket array (NAME_reserve and NAME_shrink) invalidate all existing iterators. + To delete keys during iteration and resume iterating, use the return value of NAME_erase_itr. + +SRB2Kart - Saturn: + added KEY_GET_CONST to force the getters to take a const pointer even if the type of key to be inserted is not const + +Version history: + + 06/05/2025 2.2.1: Fixed incorrect signature of NAME_is_end in documentation. + 18/04/2025 2.2.0: Added const qualifier to the table parameter of NAME_size, NAME_bucket_count, NAME_get, and + NAME_first and to the source parameter of NAME_init_clone. + Added default support for const char * strings. + Added support for -Wextra. + Replaced FNV-1a with Wyhash as the default string hash function. + 18/06/2024 2.1.1: Fixed a bug affecting iteration on big-endian platforms under MSVC. + 27/05/2024 2.1.0: Replaced the Murmur3 mixer with the fast-hash mixer as the default integer hash function. + Fixed a bug that could theoretically cause a crash on rehash (triggerable in testing using + NAME_shrink with a maximum load factor significantly higher than 1.0). + 06/02/2024 2.0.0: Improved custom allocator support by introducing the CTX_TY option and allowing user-supplied free + functions to receive the allocation size. + Improved documentation. + Introduced various optimizations, including storing the buckets-array size mask instead of the + bucket count, eliminating empty-table checks, combining the buckets memory and metadata memory into + one allocation, and adding branch prediction macros. + Fixed a bug that caused a key to be used after destruction during erasure. + 12/12/2023 1.0.0: Initial release. + +License (MIT): + + Copyright (c) 2023-2025 Jackson L. Allan + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit + persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +/*--------------------------------------------------------------------------------------------------------------------*/ +/* Common header section */ +/*--------------------------------------------------------------------------------------------------------------------*/ + +#ifdef __GNUC__ + #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) // >= GCC 3.1 + #define FORCEINLINE __attribute__((always_inline)) + #else + #define FORCEINLINE + #endif +#else + #define FORCEINLINE +#endif + +#ifndef VERSTABLE_H +#define VERSTABLE_H + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waggregate-return" + +#include +#include +#include +#include +#include +#include + +// Two-way concatenation macro. +#define VT_CAT_( a, b ) a##b +#define VT_CAT( a, b ) VT_CAT_( a, b ) + +// Branch optimization macros. +#ifdef __GNUC__ +#define VT_LIKELY( expression ) __builtin_expect( (bool)( expression ), true ) +#define VT_UNLIKELY( expression ) __builtin_expect( (bool)( expression ), false ) +#else +#define VT_LIKELY( expression ) ( expression ) +#define VT_UNLIKELY( expression ) ( expression ) +#endif + +// Masks for manipulating and extracting data from a bucket's uint16_t metadatum. +#define VT_EMPTY 0x0000 +#define VT_HASH_FRAG_MASK 0xF000 // 0b1111000000000000. +#define VT_IN_HOME_BUCKET_MASK 0x0800 // 0b0000100000000000. +#define VT_DISPLACEMENT_MASK 0x07FF // 0b0000011111111111, also denotes the displacement limit. Set to VT_LOAD to 1.0 + // to test proper handling of encroachment on the displacement limit during + // inserts. + +// Extracts a hash fragment from a uint64_t hash code. +// We take the highest four bits so that keys that map (via modulo) to the same bucket have distinct hash fragments. +static inline FORCEINLINE uint16_t vt_hashfrag( uint64_t hash ) +{ + return ( hash >> 48 ) & VT_HASH_FRAG_MASK; +} + +// Standard quadratic probing formula that guarantees that all buckets are visited when the bucket count is a power of +// two (at least in theory, because the displacement limit could terminate the search early when the bucket count is +// high). +static inline FORCEINLINE size_t vt_quadratic( uint16_t displacement ) +{ + return ( (size_t)displacement * displacement + displacement ) / 2; +} + +#define VT_MIN_NONZERO_BUCKET_COUNT 8 // Must be a power of two. + +// Function to find the left-most non-zero uint16_t in a uint64_t. +// This function is used when we scan four buckets at a time while iterating and relies on compiler intrinsics wherever +// possible. + +#if defined( __GNUC__ ) && ULLONG_MAX == 0xFFFFFFFFFFFFFFFF + +static inline FORCEINLINE int vt_first_nonzero_uint16( uint64_t val ) +{ + const uint16_t endian_checker = 0x0001; + if( *(const char *)&endian_checker ) // Little-endian (the compiler will optimize away the check at -O1 and above). + return __builtin_ctzll( val ) / 16; + + return __builtin_clzll( val ) / 16; +} + +#elif defined( _MSC_VER ) && ( defined( _M_X64 ) || defined( _M_ARM64 ) ) + +#include +#pragma intrinsic(_BitScanForward64) +#pragma intrinsic(_BitScanReverse64) + +static inline FORCEINLINE int vt_first_nonzero_uint16( uint64_t val ) +{ + unsigned long result; + + const uint16_t endian_checker = 0x0001; + if( *(const char *)&endian_checker ) + _BitScanForward64( &result, val ); + else + { + _BitScanReverse64( &result, val ); + result = 63 - result; + } + + return result / 16; +} + +#else + +static inline FORCEINLINE int vt_first_nonzero_uint16( uint64_t val ) +{ + int result = 0; + + uint32_t half; + memcpy( &half, &val, sizeof( uint32_t ) ); + if( !half ) + result += 2; + + uint16_t quarter; + memcpy( &quarter, (char *)&val + result * sizeof( uint16_t ), sizeof( uint16_t ) ); + if( !quarter ) + result += 1; + + return result; +} + +#endif + +// When the bucket count is zero, setting the metadata pointer to point to a VT_EMPTY placeholder, rather than NULL, +// allows us to avoid checking for a zero bucket count during insertion and lookup. +static const uint16_t vt_empty_placeholder_metadatum = VT_EMPTY; + +// Default hash and comparison functions. + +// Fast-hash, as described by https://jonkagstrom.com/bit-mixer-construction and +// https://code.google.com/archive/p/fast-hash. +// In testing, this hash function provided slightly better performance than the Murmur3 mixer. +static inline FORCEINLINE uint64_t vt_hash_integer( uint64_t key ) +{ + key ^= key >> 23; + key *= 0x2127599bf4325c37ull; + key ^= key >> 47; + return key; +} + +// For hashing strings, we use the public-domain Wyhash +// (https://github.com/wangyi-fudan/wyhash) with the following modifications: +// * We use a fixed seed and secret (the defaults suggested in the Wyhash repository). +// * We do not handle endianness, so the result will differ depending on the platform. +// * We omit the code optimized for 32-bit platforms. + +static inline FORCEINLINE void vt_wymum( uint64_t *a, uint64_t *b ) +{ +#if defined( __SIZEOF_INT128__ ) + __uint128_t r = *a; + r *= *b; + *a = (uint64_t)r; + *b = (uint64_t)( r >> 64 ); +#elif defined( _MSC_VER ) && defined( _M_X64 ) + *a = _umul128( *a, *b, b ); +#else + uint64_t ha = *a >> 32; + uint64_t hb = *b >> 32; + uint64_t la = (uint32_t)*a; + uint64_t lb = (uint32_t)*b; + uint64_t rh = ha * hb; + uint64_t rm0 = ha * lb; + uint64_t rm1 = hb * la; + uint64_t rl = la * lb; + uint64_t t = rl + ( rm0 << 32 ); + uint64_t c = t < rl; + uint64_t lo = t + ( rm1 << 32 ); + c += lo < t; + uint64_t hi = rh + ( rm0 >> 32 ) + ( rm1 >> 32 ) + c; + *a = lo; + *b = hi; +#endif +} + +static inline FORCEINLINE uint64_t vt_wymix( uint64_t a, uint64_t b ) +{ + vt_wymum( &a, &b ); + return a ^ b; +} + +static inline FORCEINLINE uint64_t vt_wyr8( const unsigned char *p ) +{ + uint64_t v; + memcpy( &v, p, 8 ); + return v; +} + +static inline FORCEINLINE uint64_t vt_wyr4( const unsigned char *p ) +{ + uint32_t v; + memcpy( &v, p, 4 ); + return v; +} + +static inline FORCEINLINE uint64_t vt_wyr3( const unsigned char *p, size_t k ) +{ + return ( ( (uint64_t)p[ 0 ] ) << 16 ) | ( ( (uint64_t)p[ k >> 1 ] ) << 8 ) | p[ k - 1 ]; +} + +static inline FORCEINLINE size_t vt_wyhash( const void *key, size_t len ) +{ + const unsigned char *p = (const unsigned char *)key; + uint64_t seed = 0xca813bf4c7abf0a9ull; + uint64_t a; + uint64_t b; + if( VT_LIKELY( len <= 16 ) ) + { + if( VT_LIKELY( len >= 4 ) ) + { + a = ( vt_wyr4( p ) << 32 ) | vt_wyr4( p + ( ( len >> 3 ) << 2 ) ); + b = ( vt_wyr4( p + len - 4 ) << 32 ) | vt_wyr4( p + len - 4 - ( ( len >> 3 ) << 2 ) ); + } + else if( VT_LIKELY( len > 0 ) ) + { + a = vt_wyr3( p, len ); + b = 0; + } + else + { + a = 0; + b = 0; + } + } + else + { + size_t i = len; + if( VT_UNLIKELY( i >= 48 ) ) + { + uint64_t see1 = seed; + uint64_t see2 = seed; + do{ + seed = vt_wymix( vt_wyr8( p ) ^ 0x8bb84b93962eacc9ull, vt_wyr8( p + 8 ) ^ seed ); + see1 = vt_wymix( vt_wyr8( p + 16 ) ^ 0x4b33a62ed433d4a3ull, vt_wyr8( p + 24 ) ^ see1 ); + see2 = vt_wymix( vt_wyr8( p + 32 ) ^ 0x4d5a2da51de1aa47ull, vt_wyr8( p + 40 ) ^ see2 ); + p += 48; + i -= 48; + } + while( VT_LIKELY( i >= 48 ) ); + seed ^= see1 ^ see2; + } + + while( VT_UNLIKELY( i > 16 ) ) + { + seed = vt_wymix( vt_wyr8( p ) ^ 0x8bb84b93962eacc9ull, vt_wyr8( p + 8 ) ^ seed ); + i -= 16; + p += 16; + } + + a = vt_wyr8( p + i - 16 ); + b = vt_wyr8( p + i - 8 ); + } + + a ^= 0x8bb84b93962eacc9ull; + b ^= seed; + vt_wymum( &a, &b ); + return (size_t)vt_wymix( a ^ 0x2d358dccaa6c78a5ull ^ len, b ^ 0x8bb84b93962eacc9ull ); +} + +static inline FORCEINLINE uint64_t vt_hash_string( const char *key ) +{ + return vt_wyhash( key, strlen( key ) ); +} + +static inline FORCEINLINE bool vt_cmpr_integer( uint64_t key_1, uint64_t key_2 ) +{ + return key_1 == key_2; +} + +static inline FORCEINLINE bool vt_cmpr_string( const char *key_1, const char *key_2 ) +{ + return strcmp( key_1, key_2 ) == 0; +} + +// Default allocation and free functions. + +static inline FORCEINLINE void *vt_malloc( size_t size ) +{ + return malloc( size ); +} + +static inline FORCEINLINE void vt_free( void *ptr, size_t size ) +{ + (void)size; + free( ptr ); +} + +static inline FORCEINLINE void *vt_malloc_with_ctx( size_t size, void *ctx ) +{ + (void)ctx; + return malloc( size ); +} + +static inline FORCEINLINE void vt_free_with_ctx( void *ptr, size_t size, void *ctx ) +{ + (void)size; + (void)ctx; + free( ptr ); +} + +// The rest of the common header section pertains to the C11 generic macro API. +// This interface is based on the extendible-_Generic mechanism documented in detail at +// https://github.com/JacksonAllan/CC/blob/main/articles/Better_C_Generics_Part_1_The_Extendible_Generic.md. +// In summary, instantiating a template also defines wrappers for the template's types and functions with names in the +// pattern of vt_table_NNNN and vt_init_NNNN, where NNNN is an automatically generated integer unique to the template +// instance in the current translation unit. +// These wrappers plug into _Generic-based API macros, which use preprocessor magic to automatically generate _Generic +// slots for every existing template instance. +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined( VT_NO_C11_GENERIC_API ) + +// Octal counter that supports up to 511 hash table templates. +#define VT_TEMPLATE_COUNT_D1 0 // Digit 1, i.e. least significant digit. +#define VT_TEMPLATE_COUNT_D2 0 +#define VT_TEMPLATE_COUNT_D3 0 + +// Four-way concatenation macro. +#define VT_CAT_4_( a, b, c, d ) a##b##c##d +#define VT_CAT_4( a, b, c, d ) VT_CAT_4_( a, b, c, d ) + +// Provides the current value of the counter as a three-digit octal number preceded by 0. +#define VT_TEMPLATE_COUNT VT_CAT_4( 0, VT_TEMPLATE_COUNT_D3, VT_TEMPLATE_COUNT_D2, VT_TEMPLATE_COUNT_D1 ) + +// _Generic-slot generation macros. + +#define VT_GENERIC_SLOT( ty, fn, n ) , VT_CAT( ty, n ): VT_CAT( fn, n ) +#define VT_R1_0( ty, fn, d3, d2 ) +#define VT_R1_1( ty, fn, d3, d2 ) VT_GENERIC_SLOT( ty, fn, VT_CAT_4( 0, d3, d2, 0 ) ) +#define VT_R1_2( ty, fn, d3, d2 ) VT_GENERIC_SLOT( ty, fn, VT_CAT_4( 0, d3, d2, 1 ) ) VT_R1_1( ty, fn, d3, d2 ) +#define VT_R1_3( ty, fn, d3, d2 ) VT_GENERIC_SLOT( ty, fn, VT_CAT_4( 0, d3, d2, 2 ) ) VT_R1_2( ty, fn, d3, d2 ) +#define VT_R1_4( ty, fn, d3, d2 ) VT_GENERIC_SLOT( ty, fn, VT_CAT_4( 0, d3, d2, 3 ) ) VT_R1_3( ty, fn, d3, d2 ) +#define VT_R1_5( ty, fn, d3, d2 ) VT_GENERIC_SLOT( ty, fn, VT_CAT_4( 0, d3, d2, 4 ) ) VT_R1_4( ty, fn, d3, d2 ) +#define VT_R1_6( ty, fn, d3, d2 ) VT_GENERIC_SLOT( ty, fn, VT_CAT_4( 0, d3, d2, 5 ) ) VT_R1_5( ty, fn, d3, d2 ) +#define VT_R1_7( ty, fn, d3, d2 ) VT_GENERIC_SLOT( ty, fn, VT_CAT_4( 0, d3, d2, 6 ) ) VT_R1_6( ty, fn, d3, d2 ) +#define VT_R1_8( ty, fn, d3, d2 ) VT_GENERIC_SLOT( ty, fn, VT_CAT_4( 0, d3, d2, 7 ) ) VT_R1_7( ty, fn, d3, d2 ) +#define VT_R2_0( ty, fn, d3 ) +#define VT_R2_1( ty, fn, d3 ) VT_R1_8( ty, fn, d3, 0 ) +#define VT_R2_2( ty, fn, d3 ) VT_R1_8( ty, fn, d3, 1 ) VT_R2_1( ty, fn, d3 ) +#define VT_R2_3( ty, fn, d3 ) VT_R1_8( ty, fn, d3, 2 ) VT_R2_2( ty, fn, d3 ) +#define VT_R2_4( ty, fn, d3 ) VT_R1_8( ty, fn, d3, 3 ) VT_R2_3( ty, fn, d3 ) +#define VT_R2_5( ty, fn, d3 ) VT_R1_8( ty, fn, d3, 4 ) VT_R2_4( ty, fn, d3 ) +#define VT_R2_6( ty, fn, d3 ) VT_R1_8( ty, fn, d3, 5 ) VT_R2_5( ty, fn, d3 ) +#define VT_R2_7( ty, fn, d3 ) VT_R1_8( ty, fn, d3, 6 ) VT_R2_6( ty, fn, d3 ) +#define VT_R2_8( ty, fn, d3 ) VT_R1_8( ty, fn, d3, 7 ) VT_R2_7( ty, fn, d3 ) +#define VT_R3_0( ty, fn ) +#define VT_R3_1( ty, fn ) VT_R2_8( ty, fn, 0 ) +#define VT_R3_2( ty, fn ) VT_R2_8( ty, fn, 1 ) VT_R3_1( ty, fn ) +#define VT_R3_3( ty, fn ) VT_R2_8( ty, fn, 2 ) VT_R3_2( ty, fn ) +#define VT_R3_4( ty, fn ) VT_R2_8( ty, fn, 3 ) VT_R3_3( ty, fn ) +#define VT_R3_5( ty, fn ) VT_R2_8( ty, fn, 4 ) VT_R3_4( ty, fn ) +#define VT_R3_6( ty, fn ) VT_R2_8( ty, fn, 5 ) VT_R3_5( ty, fn ) +#define VT_R3_7( ty, fn ) VT_R2_8( ty, fn, 6 ) VT_R3_6( ty, fn ) + +#define VT_GENERIC_SLOTS( ty, fn ) \ +VT_CAT( VT_R1_, VT_TEMPLATE_COUNT_D1 )( ty, fn, VT_TEMPLATE_COUNT_D3, VT_TEMPLATE_COUNT_D2 ) \ +VT_CAT( VT_R2_, VT_TEMPLATE_COUNT_D2 )( ty, fn, VT_TEMPLATE_COUNT_D3 ) \ +VT_CAT( VT_R3_, VT_TEMPLATE_COUNT_D3 )( ty, fn ) \ + +// Actual generic API macros. + +// vt_init must be handled as a special case because it could take one or two arguments, depending on whether CTX_TY +// was defined. +#define VT_ARG_3( _1, _2, _3, ... ) _3 +#define vt_init( ... ) VT_ARG_3( __VA_ARGS__, vt_init_with_ctx, vt_init_without_ctx, )( __VA_ARGS__ ) +#define vt_init_without_ctx( table ) _Generic( *( table ) VT_GENERIC_SLOTS( vt_table_, vt_init_ ) )( table ) +#define vt_init_with_ctx( table, ... ) _Generic( *( table ) \ + VT_GENERIC_SLOTS( vt_table_, vt_init_ ) \ +)( table, __VA_ARGS__ ) \ + +#define vt_init_clone( table, ... ) _Generic( *( table ) \ + VT_GENERIC_SLOTS( vt_table_, vt_init_clone_ ) \ +)( table, __VA_ARGS__ ) \ + +#define vt_size( table )_Generic( *( table ) VT_GENERIC_SLOTS( vt_table_, vt_size_ ) )( table ) + +#define vt_bucket_count( table ) _Generic( *( table ) VT_GENERIC_SLOTS( vt_table_, vt_bucket_count_ ) )( table ) + +#define vt_is_end( itr ) _Generic( itr VT_GENERIC_SLOTS( vt_table_itr_, vt_is_end_ ) )( itr ) + +#define vt_insert( table, ... ) _Generic( *( table ) VT_GENERIC_SLOTS( vt_table_, vt_insert_ ) )( table, __VA_ARGS__ ) + +#define vt_get_or_insert( table, ... ) _Generic( *( table ) \ + VT_GENERIC_SLOTS( vt_table_, vt_get_or_insert_ ) \ +)( table, __VA_ARGS__ ) \ + +#define vt_get( table, ... ) _Generic( *( table ) VT_GENERIC_SLOTS( vt_table_, vt_get_ ) )( table, __VA_ARGS__ ) + +#define vt_erase( table, ... ) _Generic( *( table ) VT_GENERIC_SLOTS( vt_table_, vt_erase_ ) )( table, __VA_ARGS__ ) + +#define vt_next( itr ) _Generic( itr VT_GENERIC_SLOTS( vt_table_itr_, vt_next_ ) )( itr ) + +#define vt_erase_itr( table, ... ) _Generic( *( table ) \ + VT_GENERIC_SLOTS( vt_table_, vt_erase_itr_ ) \ +)( table, __VA_ARGS__ ) \ + +#define vt_reserve( table, ... ) _Generic( *( table ) VT_GENERIC_SLOTS( vt_table_, vt_reserve_ ) )( table, __VA_ARGS__ ) + +#define vt_shrink( table ) _Generic( *( table ) VT_GENERIC_SLOTS( vt_table_, vt_shrink_ ) )( table ) + +#define vt_first( table ) _Generic( *( table ) VT_GENERIC_SLOTS( vt_table_, vt_first_ ) )( table ) + +#define vt_clear( table ) _Generic( *( table ) VT_GENERIC_SLOTS( vt_table_, vt_clear_ ) )( table ) + +#define vt_cleanup( table ) _Generic( *( table ) VT_GENERIC_SLOTS( vt_table_, vt_cleanup_ ) )( table ) + +#endif + +#endif + +/*--------------------------------------------------------------------------------------------------------------------*/ +/* Prefixed structs */ +/*--------------------------------------------------------------------------------------------------------------------*/ + +#ifndef IMPLEMENTATION_MODE + +typedef struct +{ + KEY_TY key; + #ifdef VAL_TY + VAL_TY val; + #endif +} VT_CAT( NAME, _bucket ); + +typedef struct +{ + VT_CAT( NAME, _bucket ) *data; + uint16_t *metadatum; + uint16_t *metadata_end; // Iterators carry an internal end pointer so that NAME_is_end does not need the table to be + // passed in as an argument. + // This also allows for the zero-bucket-count check to occur once in NAME_first, rather than + // repeatedly in NAME_is_end. + size_t home_bucket; // SIZE_MAX if home bucket is unknown. +} VT_CAT( NAME, _itr ); + +typedef struct +{ + size_t key_count; + size_t buckets_mask; // Rather than storing the bucket count directly, we store the bit mask used to reduce a hash + // code or displacement-derived bucket index to the buckets array, i.e. the bucket count minus + // one. + // Consequently, a zero bucket count (i.e. when .metadata points to the placeholder) constitutes + // a special case, represented by all bits unset (i.e. zero). + VT_CAT( NAME, _bucket ) *buckets; + uint16_t *metadata; // As described above, each metadatum consists of a 4-bit hash-code fragment (X), a 1-bit flag + // indicating whether the key in this bucket begins a chain associated with the bucket (Y), and + // an 11-bit value indicating the quadratic displacement of the next key in the chain (Z): + // XXXXYZZZZZZZZZZZ. + #ifdef CTX_TY + CTX_TY ctx; + #endif +} NAME; + +#endif + +/*--------------------------------------------------------------------------------------------------------------------*/ +/* Function prototypes */ +/*--------------------------------------------------------------------------------------------------------------------*/ + +#if defined( HEADER_MODE ) || defined( IMPLEMENTATION_MODE ) +#define VT_API_FN_QUALIFIERS +#else +#define VT_API_FN_QUALIFIERS static inline FORCEINLINE +#endif + +#ifndef IMPLEMENTATION_MODE + +VT_API_FN_QUALIFIERS void VT_CAT( NAME, _init )( + NAME * + #ifdef CTX_TY + , CTX_TY + #endif +); + +VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _init_clone )( + NAME *, + const NAME * + #ifdef CTX_TY + , CTX_TY + #endif +); + +VT_API_FN_QUALIFIERS size_t VT_CAT( NAME, _size )( const NAME * ); + +VT_API_FN_QUALIFIERS size_t VT_CAT( NAME, _bucket_count )( const NAME * ); + +VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _is_end )( VT_CAT( NAME, _itr ) ); + +VT_API_FN_QUALIFIERS VT_CAT( NAME, _itr ) VT_CAT( NAME, _insert )( + NAME *, + KEY_TY + #ifdef VAL_TY + , VAL_TY + #endif +); + +VT_API_FN_QUALIFIERS VT_CAT( NAME, _itr ) VT_CAT( NAME, _get_or_insert )( + NAME *, + KEY_TY + #ifdef VAL_TY + , VAL_TY + #endif +); + +VT_API_FN_QUALIFIERS VT_CAT( NAME, _itr ) VT_CAT( NAME, _get )( + const NAME *table, +#ifdef KEY_GET_CONST + const KEY_TY key +#else + KEY_TY key +#endif +); + +VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _erase )( NAME *, KEY_TY ); + +VT_API_FN_QUALIFIERS VT_CAT( NAME, _itr ) VT_CAT( NAME, _next )( VT_CAT( NAME, _itr ) ); + +VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _reserve )( NAME *, size_t ); + +VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _shrink )( NAME * ); + +VT_API_FN_QUALIFIERS VT_CAT( NAME, _itr ) VT_CAT( NAME, _first )( const NAME * ); + +VT_API_FN_QUALIFIERS void VT_CAT( NAME, _clear )( NAME * ); + +VT_API_FN_QUALIFIERS void VT_CAT( NAME, _cleanup )( NAME * ); + +// Not an API function, but must be prototyped anyway because it is called by the inline NAME_erase_itr below. +VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _erase_itr_raw ) ( NAME *, VT_CAT( NAME, _itr ) ); + +// Erases the key pointed to by itr and returns an iterator to the next key in the table. +// This function must be inlined to ensure that the compiler optimizes away the NAME_fast_forward call if the returned +// iterator is discarded. +#ifdef __GNUC__ +static inline FORCEINLINE +#elif defined( _MSC_VER ) +static __forceinline +#else +static inline +#endif +VT_CAT( NAME, _itr ) VT_CAT( NAME, _erase_itr )( NAME *table, VT_CAT( NAME, _itr ) itr ) +{ + if( VT_CAT( NAME, _erase_itr_raw )( table, itr ) ) + return VT_CAT( NAME, _next )( itr ); + + return itr; +} + +#endif + +/*--------------------------------------------------------------------------------------------------------------------*/ +/* Function implementations */ +/*--------------------------------------------------------------------------------------------------------------------*/ + +#ifndef HEADER_MODE + +// Default settings. + +#ifndef MAX_LOAD +#define MAX_LOAD 0.9 +#endif + +#ifndef MALLOC_FN +#ifdef CTX_TY +#define MALLOC_FN vt_malloc_with_ctx +#else +#define MALLOC_FN vt_malloc +#endif +#endif + +#ifndef FREE_FN +#ifdef CTX_TY +#define FREE_FN vt_free_with_ctx +#else +#define FREE_FN vt_free +#endif +#endif + +#ifndef HASH_FN +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#ifdef _MSC_VER // In MSVC, the compound literal in the _Generic triggers a warning about unused local variables at /W4. +#define HASH_FN \ +_Pragma( "warning( push )" ) \ +_Pragma( "warning( disable: 4189 )" ) \ +_Generic( ( KEY_TY ){ 0 }, char *: vt_hash_string, const char*: vt_hash_string, default: vt_hash_integer ) \ +_Pragma( "warning( pop )" ) +#else +#define HASH_FN _Generic( ( KEY_TY ){ 0 }, \ + char *: vt_hash_string, \ + const char*: vt_hash_string, \ + default: vt_hash_integer \ +) +#endif +#else +#error Hash function inference is only available in C11 and later. In C99, you need to define HASH_FN manually to \ +vt_hash_integer, vt_hash_string, or your own custom function with the signature uint64_t ( KEY_TY ). +#endif +#endif + +#ifndef CMPR_FN +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#ifdef _MSC_VER +#define CMPR_FN \ +_Pragma( "warning( push )" ) \ +_Pragma( "warning( disable: 4189 )" ) \ +_Generic( ( KEY_TY ){ 0 }, char *: vt_cmpr_string, const char*: vt_cmpr_string, default: vt_cmpr_integer ) \ +_Pragma( "warning( pop )" ) +#else +#define CMPR_FN _Generic( ( KEY_TY ){ 0 }, \ + char *: vt_cmpr_string, \ + const char*: vt_cmpr_string, \ + default: vt_cmpr_integer \ +) +#endif +#else +#error Comparison function inference is only available in C11 and later. In C99, you need to define CMPR_FN manually \ +to vt_cmpr_integer, vt_cmpr_string, or your own custom function with the signature bool ( KEY_TY, KEY_TY ). +#endif +#endif + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-qual" + +VT_API_FN_QUALIFIERS void VT_CAT( NAME, _init )( + NAME *table + #ifdef CTX_TY + , CTX_TY ctx + #endif +) +{ + table->key_count = 0; + table->buckets_mask = 0x0000000000000000ull; + table->buckets = NULL; + table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum; + #ifdef CTX_TY + table->ctx = ctx; + #endif +} + +#pragma GCC diagnostic pop + +// For efficiency, especially in the case of a small table, the buckets array and metadata share the same dynamic memory +// allocation: +// +-----------------------------+-----+----------------+--------+ +// | Buckets | Pad | Metadata | Excess | +// +-----------------------------+-----+----------------+--------+ +// Any allocated metadata array requires four excess elements to ensure that iteration functions, which read four +// metadata at a time, never read beyond the end of it. +// This function returns the offset of the beginning of the metadata, i.e. the size of the buckets array plus the +// (usually zero) padding. +// It assumes that the bucket count is not zero. +static inline FORCEINLINE size_t VT_CAT( NAME, _metadata_offset )( NAME *table ) +{ + // Use sizeof, rather than alignof, for C99 compatibility. + return ( ( ( table->buckets_mask + 1 ) * sizeof( VT_CAT( NAME, _bucket ) ) + sizeof( uint16_t ) - 1 ) / + sizeof( uint16_t ) ) * sizeof( uint16_t ); +} + +// Returns the total allocation size, including the buckets array, padding, metadata, and excess metadata. +// As above, this function assumes that the bucket count is not zero. +static inline FORCEINLINE size_t VT_CAT( NAME, _total_alloc_size )( NAME *table ) +{ + return VT_CAT( NAME, _metadata_offset )( table ) + ( table->buckets_mask + 1 + 4 ) * sizeof( uint16_t ); +} + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-qual" + +VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _init_clone )( + NAME *table, + const NAME *source + #ifdef CTX_TY + , CTX_TY ctx + #endif +) +{ + table->key_count = source->key_count; + table->buckets_mask = source->buckets_mask; + #ifdef CTX_TY + table->ctx = ctx; + #endif + + if( !source->buckets_mask ) + { + table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum; + table->buckets = NULL; + return true; + } + + void *allocation = MALLOC_FN( + VT_CAT( NAME, _total_alloc_size )( table ) + #ifdef CTX_TY + , &table->ctx + #endif + ); + + if( VT_UNLIKELY( !allocation ) ) + return false; + + table->buckets = (VT_CAT( NAME, _bucket ) *)allocation; + table->metadata = (uint16_t *)( (unsigned char *)allocation + VT_CAT( NAME, _metadata_offset )( table ) ); + memcpy( allocation, source->buckets, VT_CAT( NAME, _total_alloc_size )( table ) ); + + return true; +} + +#pragma GCC diagnostic pop + +VT_API_FN_QUALIFIERS size_t VT_CAT( NAME, _size )( const NAME *table ) +{ + return table->key_count; +} + +VT_API_FN_QUALIFIERS size_t VT_CAT( NAME, _bucket_count )( const NAME *table ) +{ + // If the bucket count is zero, buckets_mask will be zero, not the bucket count minus one. + // We account for this special case by adding (bool)buckets_mask rather than one. + return table->buckets_mask + (bool)table->buckets_mask; +} + +VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _is_end )( VT_CAT( NAME, _itr ) itr ) +{ + return itr.metadatum == itr.metadata_end; +} + +// Finds the earliest empty bucket in which a key belonging to home_bucket can be placed, assuming that home_bucket +// is already occupied. +// The reason to begin the search at home_bucket, rather than the end of the existing chain, is that keys deleted from +// other chains might have freed up buckets that could fall in this chain before the final key. +// Returns true if an empty bucket within the range of the displacement limit was found, in which case the final two +// pointer arguments contain the index of the empty bucket and its quadratic displacement from home_bucket. +static inline FORCEINLINE bool VT_CAT( NAME, _find_first_empty )( + NAME *table, + size_t home_bucket, + size_t *empty, + uint16_t *displacement +) +{ + *displacement = 1; + size_t linear_dispacement = 1; + + while( true ) + { + *empty = ( home_bucket + linear_dispacement ) & table->buckets_mask; + if( table->metadata[ *empty ] == VT_EMPTY ) + return true; + + if( VT_UNLIKELY( ++*displacement == VT_DISPLACEMENT_MASK ) ) + return false; + + linear_dispacement += *displacement; + } +} + +// Finds the key in the chain beginning in home_bucket after which to link a new key with displacement_to_empty +// quadratic displacement and returns the index of the bucket containing that key. +// Although the new key could simply be linked to the end of the chain, keeping the chain ordered by displacement +// theoretically improves cache locality during lookups. +static inline FORCEINLINE size_t VT_CAT( NAME, _find_insert_location_in_chain )( + NAME *table, + size_t home_bucket, + uint16_t displacement_to_empty +) +{ + size_t candidate = home_bucket; + while( true ) + { + uint16_t displacement = table->metadata[ candidate ] & VT_DISPLACEMENT_MASK; + + if( displacement > displacement_to_empty ) + return candidate; + + candidate = ( home_bucket + vt_quadratic( displacement ) ) & table->buckets_mask; + } +} + +// Frees up a bucket occupied by a key not belonging there so that a new key belonging there can be placed there as the +// beginning of a new chain. +// This requires: +// * Finding the previous key in the chain to which the occupying key belongs by rehashing it and then traversing the +// chain. +// * Disconnecting the key from the chain. +// * Finding the appropriate empty bucket to which to move the key. +// * Moving the key (and value) data to the empty bucket. +// * Re-linking the key to the chain. +// Returns true if the eviction succeeded, or false if no empty bucket to which to evict the occupying key could be +// found within the displacement limit. +static inline FORCEINLINE bool VT_CAT( NAME, _evict )( NAME *table, size_t bucket ) +{ + // Find the previous key in chain. + size_t home_bucket = HASH_FN( table->buckets[ bucket ].key ) & table->buckets_mask; + size_t prev = home_bucket; + while( true ) + { + size_t next = ( home_bucket + vt_quadratic( table->metadata[ prev ] & VT_DISPLACEMENT_MASK ) ) & + table->buckets_mask; + + if( next == bucket ) + break; + + prev = next; + } + + // Disconnect the key from chain. + table->metadata[ prev ] = ( table->metadata[ prev ] & ~VT_DISPLACEMENT_MASK ) | ( table->metadata[ bucket ] & + VT_DISPLACEMENT_MASK ); + + // Find the empty bucket to which to move the key. + size_t empty; + uint16_t displacement; + if( VT_UNLIKELY( !VT_CAT( NAME, _find_first_empty )( table, home_bucket, &empty, &displacement ) ) ) + return false; + + // Find the key in the chain after which to link the moved key. + prev = VT_CAT( NAME, _find_insert_location_in_chain )( table, home_bucket, displacement ); + + // Move the key (and value) data. + table->buckets[ empty ] = table->buckets[ bucket ]; + + // Re-link the key to the chain from its new bucket. + table->metadata[ empty ] = ( table->metadata[ bucket ] & VT_HASH_FRAG_MASK ) | ( table->metadata[ prev ] & + VT_DISPLACEMENT_MASK ); + table->metadata[ prev ] = ( table->metadata[ prev ] & ~VT_DISPLACEMENT_MASK ) | displacement; + + return true; +} + +// Returns an end iterator, i.e. any iterator for which .metadatum == .metadata_end. +// This function just cleans up the library code in functions that return an end iterator as a failure indicator. +static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( NAME, _end_itr )( void ) +{ + VT_CAT( NAME, _itr ) itr = { NULL, NULL, NULL, 0 }; + return itr; +} + +// Inserts a key, optionally replacing the existing key if it already exists. +// There are two main cases that must be handled: +// * If the key's home bucket is empty or occupied by a key that does not belong there, then the key is inserted there, +// evicting the occupying key if there is one. +// * Otherwise, the chain of keys beginning at the home bucket is (if unique is false) traversed in search of a matching +// key. +// If none is found, then the new key is inserted at the earliest available bucket, per quadratic probing from the +// home bucket, and then linked to the chain in a manner that maintains its quadratic order. +// The unique argument tells the function whether to skip searching for the key before inserting it (on rehashing, this +// step is unnecessary). +// The replace argument tells the function whether to replace an existing key. +// If replace is true, the function returns an iterator to the inserted key, or an end iterator if the key was not +// inserted because of the maximum load factor or displacement limit constraints. +// If replace is false, then the return value is as described above, except that if the key already exists, the function +// returns an iterator to the existing key. +static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( NAME, _insert_raw )( + NAME *table, + KEY_TY key, + #ifdef VAL_TY + VAL_TY *val, + #endif + bool unique, + bool replace +) +{ + uint64_t hash = HASH_FN( key ); + uint16_t hashfrag = vt_hashfrag( hash ); + size_t home_bucket = hash & table->buckets_mask; + + // Case 1: The home bucket is empty or contains a key that doesn't belong there. + // This case also implicitly handles the case of a zero bucket count, since home_bucket will be zero and metadata[ 0 ] + // will be the empty placeholder. + // In that scenario, the zero buckets_mask triggers the below load-factor check. + if( !( table->metadata[ home_bucket ] & VT_IN_HOME_BUCKET_MASK ) ) + { + if( + // Load-factor check. + VT_UNLIKELY( table->key_count + 1 > VT_CAT( NAME, _bucket_count )( table ) * MAX_LOAD ) || + // Vacate the home bucket if it contains a key. + ( table->metadata[ home_bucket ] != VT_EMPTY && VT_UNLIKELY( !VT_CAT( NAME, _evict )( table, home_bucket ) ) ) + ) + return VT_CAT( NAME, _end_itr )(); + + table->buckets[ home_bucket ].key = key; + #ifdef VAL_TY + table->buckets[ home_bucket ].val = *val; + #endif + table->metadata[ home_bucket ] = hashfrag | VT_IN_HOME_BUCKET_MASK | VT_DISPLACEMENT_MASK; + + ++table->key_count; + + VT_CAT( NAME, _itr ) itr = { + table->buckets + home_bucket, + table->metadata + home_bucket, + table->metadata + table->buckets_mask + 1, // Iteration stopper (i.e. the first of the four excess metadata). + home_bucket + }; + return itr; + } + + // Case 2: The home bucket contains the beginning of a chain. + + // Optionally, check the existing chain. + if( !unique ) + { + size_t bucket = home_bucket; + while( true ) + { + if( + ( table->metadata[ bucket ] & VT_HASH_FRAG_MASK ) == hashfrag && + VT_LIKELY( CMPR_FN( table->buckets[ bucket ].key, key ) ) + ) + { + if( replace ) + { + #ifdef KEY_DTOR_FN + KEY_DTOR_FN( table->buckets[ bucket ].key ); + #endif + table->buckets[ bucket ].key = key; + + #ifdef VAL_TY + #ifdef VAL_DTOR_FN + VAL_DTOR_FN( table->buckets[ bucket ].val ); + #endif + table->buckets[ bucket ].val = *val; + #endif + } + + VT_CAT( NAME, _itr ) itr = { + table->buckets + bucket, + table->metadata + bucket, + table->metadata + table->buckets_mask + 1, + home_bucket + }; + return itr; + } + + uint16_t displacement = table->metadata[ bucket ] & VT_DISPLACEMENT_MASK; + if( displacement == VT_DISPLACEMENT_MASK ) + break; + + bucket = ( home_bucket + vt_quadratic( displacement ) ) & table->buckets_mask; + } + } + + size_t empty; + uint16_t displacement; + if( + VT_UNLIKELY( + // Load-factor check. + table->key_count + 1 > VT_CAT( NAME, _bucket_count )( table ) * MAX_LOAD || + // Find the earliest empty bucket, per quadratic probing. + !VT_CAT( NAME, _find_first_empty )( table, home_bucket, &empty, &displacement ) + ) + ) + return VT_CAT( NAME, _end_itr )(); + + // Insert the new key (and value) in the empty bucket and link it to the chain. + + size_t prev = VT_CAT( NAME, _find_insert_location_in_chain )( table, home_bucket, displacement ); + + table->buckets[ empty ].key = key; + #ifdef VAL_TY + table->buckets[ empty ].val = *val; + #endif + table->metadata[ empty ] = hashfrag | ( table->metadata[ prev ] & VT_DISPLACEMENT_MASK ); + table->metadata[ prev ] = ( table->metadata[ prev ] & ~VT_DISPLACEMENT_MASK ) | displacement; + + ++table->key_count; + + VT_CAT( NAME, _itr ) itr = { + table->buckets + empty, + table->metadata + empty, + table->metadata + table->buckets_mask + 1, + home_bucket + }; + return itr; +} + +// Resizes the bucket array. +// This function assumes that bucket_count is a power of two and large enough to accommodate all keys without violating +// the maximum load factor. +// Returns false in the case of allocation failure. +// As this function is called very rarely in _insert and _get_or_insert, ideally it should not be inlined into those +// functions. +// In testing, the no-inline approach showed a performance benefit when inserting existing keys (i.e. replacing). +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wattributes" // Silence warning about combining noinline with static inline FORCEINLINE. +__attribute__((noinline)) static inline +#elif defined( _MSC_VER ) +__declspec(noinline) static inline +#else +static inline +#endif +bool VT_CAT( NAME, _rehash )( NAME *table, size_t bucket_count ) +{ + // The attempt to resize the bucket array and rehash the keys must occur inside a loop that incrementally doubles the + // target bucket count because a failure could theoretically occur at any load factor due to the displacement limit. + while( true ) + { + NAME new_table = { + 0, + bucket_count - 1, + NULL, + NULL + #ifdef CTX_TY + , table->ctx + #endif + }; + + void *allocation = MALLOC_FN( + VT_CAT( NAME, _total_alloc_size )( &new_table ) + #ifdef CTX_TY + , &new_table.ctx + #endif + ); + + if( VT_UNLIKELY( !allocation ) ) + return false; + + new_table.buckets = (VT_CAT( NAME, _bucket ) *)allocation; + new_table.metadata = (uint16_t *)( (unsigned char *)allocation + VT_CAT( NAME, _metadata_offset )( &new_table ) ); + + memset( new_table.metadata, 0x00, ( bucket_count + 4 ) * sizeof( uint16_t ) ); + + // Iteration stopper at the end of the actual metadata array (i.e. the first of the four excess metadata). + new_table.metadata[ bucket_count ] = 0x01; + + for( size_t bucket = 0; bucket < VT_CAT( NAME, _bucket_count )( table ); ++bucket ) + if( table->metadata[ bucket ] != VT_EMPTY ) + { + VT_CAT( NAME, _itr ) itr = VT_CAT( NAME, _insert_raw )( + &new_table, + table->buckets[ bucket ].key, + #ifdef VAL_TY + &table->buckets[ bucket ].val, + #endif + true, + false + ); + + if( VT_UNLIKELY( VT_CAT( NAME, _is_end )( itr ) ) ) + break; + } + + // If a key could not be reinserted due to the displacement limit, double the bucket count and retry. + if( VT_UNLIKELY( new_table.key_count < table->key_count ) ) + { + FREE_FN( + new_table.buckets, + VT_CAT( NAME, _total_alloc_size )( &new_table ) + #ifdef CTX_TY + , &new_table.ctx + #endif + ); + + bucket_count *= 2; + continue; + } + + if( table->buckets_mask ) + FREE_FN( + table->buckets, + VT_CAT( NAME, _total_alloc_size )( table ) + #ifdef CTX_TY + , &table->ctx + #endif + ); + + *table = new_table; + return true; + } +} +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + +// Inserts a key, replacing the existing key if it already exists. +// This function wraps insert_raw in a loop that handles growing and rehashing the table if a new key cannot be inserted +// because of the maximum load factor or displacement limit constraints. +// Returns an iterator to the inserted key, or an end iterator in the case of allocation failure. +VT_API_FN_QUALIFIERS VT_CAT( NAME, _itr ) VT_CAT( NAME, _insert )( + NAME *table, + KEY_TY key + #ifdef VAL_TY + , VAL_TY val + #endif +) +{ + while( true ) + { + VT_CAT( NAME, _itr ) itr = VT_CAT( NAME, _insert_raw )( + table, + key, + #ifdef VAL_TY + &val, + #endif + false, + true + ); + + if( + // Lookup succeeded, in which case itr points to the found key. + VT_LIKELY( !VT_CAT( NAME, _is_end )( itr ) ) || + // Lookup failed and rehash also fails, in which case itr is an end iterator. + VT_UNLIKELY( + !VT_CAT( NAME, _rehash )( + table, table->buckets_mask ? VT_CAT( NAME, _bucket_count )( table ) * 2 : VT_MIN_NONZERO_BUCKET_COUNT + ) + ) + ) + return itr; + } +} + +// Same as NAME_insert, except that if the key already exists, no insertion occurs and the function returns an iterator +// to the existing key. +VT_API_FN_QUALIFIERS VT_CAT( NAME, _itr ) VT_CAT( NAME, _get_or_insert )( + NAME *table, + KEY_TY key + #ifdef VAL_TY + , VAL_TY val + #endif +) +{ + while( true ) + { + VT_CAT( NAME, _itr ) itr = VT_CAT( NAME, _insert_raw )( + table, + key, + #ifdef VAL_TY + &val, + #endif + false, + false + ); + + if( + // Lookup succeeded, in which case itr points to the found key. + VT_LIKELY( !VT_CAT( NAME, _is_end )( itr ) ) || + // Lookup failed and rehash also fails, in which case itr is an end iterator. + VT_UNLIKELY( + !VT_CAT( NAME, _rehash )( + table, table->buckets_mask ? VT_CAT( NAME, _bucket_count )( table ) * 2 : VT_MIN_NONZERO_BUCKET_COUNT + ) + ) + ) + return itr; + } +} + +// Returns an iterator pointing to the specified key, or an end iterator if the key does not exist. +VT_API_FN_QUALIFIERS VT_CAT( NAME, _itr ) VT_CAT( NAME, _get )( const NAME *table, +#ifdef KEY_GET_CONST + const KEY_TY key +#else + KEY_TY key +#endif + ) +{ + uint64_t hash = HASH_FN( key ); + size_t home_bucket = hash & table->buckets_mask; + + // If the home bucket is empty or contains a key that does not belong there, then our key does not exist. + // This check also implicitly handles the case of a zero bucket count, since home_bucket will be zero and + // metadata[ 0 ] will be the empty placeholder. + if( !( table->metadata[ home_bucket ] & VT_IN_HOME_BUCKET_MASK ) ) + return VT_CAT( NAME, _end_itr )(); + + // Traverse the chain of keys belonging to the home bucket. + uint16_t hashfrag = vt_hashfrag( hash ); + size_t bucket = home_bucket; + while( true ) + { + if( + ( table->metadata[ bucket ] & VT_HASH_FRAG_MASK ) == hashfrag && + VT_LIKELY( CMPR_FN( table->buckets[ bucket ].key, key ) ) + ) + { + VT_CAT( NAME, _itr ) itr = { + table->buckets + bucket, + table->metadata + bucket, + table->metadata + table->buckets_mask + 1, + home_bucket + }; + return itr; + } + + uint16_t displacement = table->metadata[ bucket ] & VT_DISPLACEMENT_MASK; + if( displacement == VT_DISPLACEMENT_MASK ) + return VT_CAT( NAME, _end_itr )(); + + bucket = ( home_bucket + vt_quadratic( displacement ) ) & table->buckets_mask; + } +} + +// Erases the key pointed to by the specified iterator. +// The erasure always occurs at the end of the chain to which the key belongs. +// If the key to be erased is not the last in the chain, it is swapped with the last so that erasure occurs at the end. +// This helps keep a chain's keys close to their home bucket for the sake of cache locality. +// Returns true if, in the case of iteration from first to end, NAME_next should now be called on the iterator to find +// the next key. +// This return value is necessary because at the iterator location, the erasure could result in an empty bucket, a +// bucket containing a moved key already visited during the iteration, or a bucket containing a moved key not yet +// visited. +VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _erase_itr_raw )( NAME *table, VT_CAT( NAME, _itr ) itr ) +{ + --table->key_count; + size_t itr_bucket = itr.metadatum - table->metadata; + + // For now, we only call the value's destructor because the key may need to be hashed below to determine the home + // bucket. + #ifdef VAL_DTOR_FN + VAL_DTOR_FN( table->buckets[ itr_bucket ].val ); + #endif + + // Case 1: The key is the only one in its chain, so just remove it. + if( + table->metadata[ itr_bucket ] & VT_IN_HOME_BUCKET_MASK && + ( table->metadata[ itr_bucket ] & VT_DISPLACEMENT_MASK ) == VT_DISPLACEMENT_MASK + ) + { + #ifdef KEY_DTOR_FN + KEY_DTOR_FN( table->buckets[ itr_bucket ].key ); + #endif + table->metadata[ itr_bucket ] = VT_EMPTY; + return true; + } + + // Case 2 and 3 require that we know the key's home bucket, which the iterator may not have recorded. + if( itr.home_bucket == SIZE_MAX ) + { + if( table->metadata[ itr_bucket ] & VT_IN_HOME_BUCKET_MASK ) + itr.home_bucket = itr_bucket; + else + itr.home_bucket = HASH_FN( table->buckets[ itr_bucket ].key ) & table->buckets_mask; + } + + // The key can now be safely destructed for cases 2 and 3. + #ifdef KEY_DTOR_FN + KEY_DTOR_FN( table->buckets[ itr_bucket ].key ); + #endif + + // Case 2: The key is the last in a multi-key chain. + // Traverse the chain from the beginning and find the penultimate key. + // Then disconnect the key and erase. + if( ( table->metadata[ itr_bucket ] & VT_DISPLACEMENT_MASK ) == VT_DISPLACEMENT_MASK ) + { + size_t bucket = itr.home_bucket; + while( true ) + { + uint16_t displacement = table->metadata[ bucket ] & VT_DISPLACEMENT_MASK; + size_t next = ( itr.home_bucket + vt_quadratic( displacement ) ) & table->buckets_mask; + if( next == itr_bucket ) + { + table->metadata[ bucket ] |= VT_DISPLACEMENT_MASK; + table->metadata[ itr_bucket ] = VT_EMPTY; + return true; + } + + bucket = next; + } + } + + // Case 3: The chain has multiple keys, and the key is not the last one. + // Traverse the chain from the key to be erased and find the last and penultimate keys. + // Disconnect the last key from the chain, and swap it with the key to erase. + size_t bucket = itr_bucket; + while( true ) + { + size_t prev = bucket; + bucket = ( itr.home_bucket + vt_quadratic( table->metadata[ bucket ] & VT_DISPLACEMENT_MASK ) ) & + table->buckets_mask; + + if( ( table->metadata[ bucket ] & VT_DISPLACEMENT_MASK ) == VT_DISPLACEMENT_MASK ) + { + table->buckets[ itr_bucket ] = table->buckets[ bucket ]; + + table->metadata[ itr_bucket ] = ( table->metadata[ itr_bucket ] & ~VT_HASH_FRAG_MASK ) | ( + table->metadata[ bucket ] & VT_HASH_FRAG_MASK ); + + table->metadata[ prev ] |= VT_DISPLACEMENT_MASK; + table->metadata[ bucket ] = VT_EMPTY; + + // Whether the iterator should be advanced depends on whether the key moved to the iterator bucket came from + // before or after that bucket. + // In the former case, the iteration would already have hit the moved key, so the iterator should still be + // advanced. + if( bucket > itr_bucket ) + return false; + + return true; + } + } +} + +// Erases the specified key, if it exists. +// Returns true if a key was erased. +VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _erase )( NAME *table, KEY_TY key ) +{ + VT_CAT( NAME, _itr ) itr = VT_CAT( NAME, _get)( table, key ); + if( VT_CAT( NAME, _is_end )( itr ) ) + return false; + + VT_CAT( NAME, _erase_itr_raw )( table, itr ); + return true; +} + +// Finds the first occupied bucket at or after the bucket pointed to by itr. +// This function scans four buckets at a time, ideally using intrinsics. +static inline FORCEINLINE void VT_CAT( NAME, _fast_forward )( VT_CAT( NAME, _itr ) *itr ) +{ + while( true ) + { + uint64_t metadata; + memcpy( &metadata, itr->metadatum, sizeof( uint64_t ) ); + if( metadata ) + { + int offset = vt_first_nonzero_uint16( metadata ); + itr->data += offset; + itr->metadatum += offset; + itr->home_bucket = SIZE_MAX; + return; + } + + itr->data += 4; + itr->metadatum += 4; + } +} + +VT_API_FN_QUALIFIERS VT_CAT( NAME, _itr ) VT_CAT( NAME, _next )( VT_CAT( NAME, _itr ) itr ) +{ + ++itr.data; + ++itr.metadatum; + VT_CAT( NAME, _fast_forward )( &itr ); + return itr; +} + +// Returns the minimum bucket count required to accommodate a certain number of keys, which is governed by the maximum +// load factor. +static inline FORCEINLINE size_t VT_CAT( NAME, _min_bucket_count_for_size )( size_t size ) +{ + if( size == 0 ) + return 0; + + // Round up to a power of two. + size_t bucket_count = VT_MIN_NONZERO_BUCKET_COUNT; + while( size > bucket_count * MAX_LOAD ) + bucket_count *= 2; + + return bucket_count; +} + +VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _reserve )( NAME *table, size_t size ) +{ + size_t bucket_count = VT_CAT( NAME, _min_bucket_count_for_size )( size ); + + if( bucket_count <= VT_CAT( NAME, _bucket_count )( table ) ) + return true; + + return VT_CAT( NAME, _rehash )( table, bucket_count ); +} + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-qual" + +VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _shrink )( NAME *table ) +{ + size_t bucket_count = VT_CAT( NAME, _min_bucket_count_for_size )( table->key_count ); + + if( bucket_count == VT_CAT( NAME, _bucket_count )( table ) ) // Shrink unnecessary. + return true; + + if( bucket_count == 0 ) + { + FREE_FN( + table->buckets, + VT_CAT( NAME, _total_alloc_size )( table ) + #ifdef CTX_TY + , &table->ctx + #endif + ); + + table->buckets_mask = 0x0000000000000000ull; + table->metadata = (uint16_t *)&vt_empty_placeholder_metadatum; + return true; + } + + return VT_CAT( NAME, _rehash )( table, bucket_count ); +} + +#pragma GCC diagnostic pop + +VT_API_FN_QUALIFIERS VT_CAT( NAME, _itr ) VT_CAT( NAME, _first )( const NAME *table ) +{ + if( !table->key_count ) + return VT_CAT( NAME, _end_itr )(); + + VT_CAT( NAME, _itr ) itr = { table->buckets, table->metadata, table->metadata + table->buckets_mask + 1, SIZE_MAX }; + VT_CAT( NAME, _fast_forward )( &itr ); + return itr; +} + +VT_API_FN_QUALIFIERS void VT_CAT( NAME, _clear )( NAME *table ) +{ + if( !table->key_count ) + return; + + for( size_t i = 0; i < VT_CAT( NAME, _bucket_count )( table ); ++i ) + { + if( table->metadata[ i ] != VT_EMPTY ) + { + #ifdef KEY_DTOR_FN + KEY_DTOR_FN( table->buckets[ i ].key ); + #endif + #ifdef VAL_DTOR_FN + VAL_DTOR_FN( table->buckets[ i ].val ); + #endif + } + + table->metadata[ i ] = VT_EMPTY; + } + + table->key_count = 0; +} + +VT_API_FN_QUALIFIERS void VT_CAT( NAME, _cleanup )( NAME *table ) +{ + if( !table->buckets_mask ) + return; + + #if defined( KEY_DTOR_FN ) || defined( VAL_DTOR_FN ) + VT_CAT( NAME, _clear )( table ); + #endif + + FREE_FN( + table->buckets, + VT_CAT( NAME, _total_alloc_size )( table ) + #ifdef CTX_TY + , &table->ctx + #endif + ); + + VT_CAT( NAME, _init )( + table + #ifdef CTX_TY + , table->ctx + #endif + ); +} + +#endif + +/*--------------------------------------------------------------------------------------------------------------------*/ +/* Wrapper types and functions for the C11 generic API */ +/*--------------------------------------------------------------------------------------------------------------------*/ + +#if defined(__STDC_VERSION__) && \ + __STDC_VERSION__ >= 201112L && \ + !defined( IMPLEMENTATION_MODE ) && \ + !defined( VT_NO_C11_GENERIC_API ) \ + +typedef NAME VT_CAT( vt_table_, VT_TEMPLATE_COUNT ); +typedef VT_CAT( NAME, _itr ) VT_CAT( vt_table_itr_, VT_TEMPLATE_COUNT ); + +static inline FORCEINLINE void VT_CAT( vt_init_, VT_TEMPLATE_COUNT )( + NAME *table + #ifdef CTX_TY + , CTX_TY ctx + #endif +) +{ + VT_CAT( NAME, _init )( + table + #ifdef CTX_TY + , ctx + #endif + ); +} + +static inline FORCEINLINE bool VT_CAT( vt_init_clone_, VT_TEMPLATE_COUNT )( + NAME *table, + const NAME* source + #ifdef CTX_TY + , CTX_TY ctx + #endif +) +{ + return VT_CAT( NAME, _init_clone )( + table, + source + #ifdef CTX_TY + , ctx + #endif + ); +} + +static inline FORCEINLINE size_t VT_CAT( vt_size_, VT_TEMPLATE_COUNT )( const NAME *table ) +{ + return VT_CAT( NAME, _size )( table ); +} + +static inline FORCEINLINE size_t VT_CAT( vt_bucket_count_, VT_TEMPLATE_COUNT )( const NAME *table ) +{ + return VT_CAT( NAME, _bucket_count )( table ); +} + +static inline FORCEINLINE bool VT_CAT( vt_is_end_, VT_TEMPLATE_COUNT )( VT_CAT( NAME, _itr ) itr ) +{ + return VT_CAT( NAME, _is_end )( itr ); +} + +static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_insert_, VT_TEMPLATE_COUNT )( + NAME *table, + KEY_TY key + #ifdef VAL_TY + , VAL_TY val + #endif +) +{ + return VT_CAT( NAME, _insert )( + table, + key + #ifdef VAL_TY + , val + #endif + ); +} + +static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_get_or_insert_, VT_TEMPLATE_COUNT )( + NAME *table, + KEY_TY key + #ifdef VAL_TY + , VAL_TY val + #endif +) +{ + return VT_CAT( NAME, _get_or_insert )( + table, + key + #ifdef VAL_TY + , val + #endif + ); +} + +static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( const NAME *table, KEY_TY key ) +{ + return VT_CAT( NAME, _get )( table, key ); +} + +static inline FORCEINLINE bool VT_CAT( vt_erase_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key ) +{ + return VT_CAT( NAME, _erase )( table, key ); +} + +static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_next_, VT_TEMPLATE_COUNT )( VT_CAT( NAME, _itr ) itr ) +{ + return VT_CAT( NAME, _next )( itr ); +} + +static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_erase_itr_, VT_TEMPLATE_COUNT )( NAME *table, VT_CAT( NAME, _itr ) itr ) +{ + return VT_CAT( NAME, _erase_itr )( table, itr ); +} + +static inline FORCEINLINE bool VT_CAT( vt_reserve_, VT_TEMPLATE_COUNT )( NAME *table, size_t bucket_count ) +{ + return VT_CAT( NAME, _reserve )( table, bucket_count ); +} + +static inline FORCEINLINE bool VT_CAT( vt_shrink_, VT_TEMPLATE_COUNT )( NAME *table ) +{ + return VT_CAT( NAME, _shrink )( table ); +} + +static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_first_, VT_TEMPLATE_COUNT )( const NAME *table ) +{ + return VT_CAT( NAME, _first )( table ); +} + +static inline FORCEINLINE void VT_CAT( vt_clear_, VT_TEMPLATE_COUNT )( NAME *table ) +{ + VT_CAT( NAME, _clear )( table ); +} + +static inline FORCEINLINE void VT_CAT( vt_cleanup_, VT_TEMPLATE_COUNT )( NAME *table ) +{ + VT_CAT( NAME, _cleanup )( table ); +} + +// Increment the template counter. +#if VT_TEMPLATE_COUNT_D1 == 0 +#undef VT_TEMPLATE_COUNT_D1 +#define VT_TEMPLATE_COUNT_D1 1 +#elif VT_TEMPLATE_COUNT_D1 == 1 +#undef VT_TEMPLATE_COUNT_D1 +#define VT_TEMPLATE_COUNT_D1 2 +#elif VT_TEMPLATE_COUNT_D1 == 2 +#undef VT_TEMPLATE_COUNT_D1 +#define VT_TEMPLATE_COUNT_D1 3 +#elif VT_TEMPLATE_COUNT_D1 == 3 +#undef VT_TEMPLATE_COUNT_D1 +#define VT_TEMPLATE_COUNT_D1 4 +#elif VT_TEMPLATE_COUNT_D1 == 4 +#undef VT_TEMPLATE_COUNT_D1 +#define VT_TEMPLATE_COUNT_D1 5 +#elif VT_TEMPLATE_COUNT_D1 == 5 +#undef VT_TEMPLATE_COUNT_D1 +#define VT_TEMPLATE_COUNT_D1 6 +#elif VT_TEMPLATE_COUNT_D1 == 6 +#undef VT_TEMPLATE_COUNT_D1 +#define VT_TEMPLATE_COUNT_D1 7 +#elif VT_TEMPLATE_COUNT_D1 == 7 +#undef VT_TEMPLATE_COUNT_D1 +#define VT_TEMPLATE_COUNT_D1 0 +#if VT_TEMPLATE_COUNT_D2 == 0 +#undef VT_TEMPLATE_COUNT_D2 +#define VT_TEMPLATE_COUNT_D2 1 +#elif VT_TEMPLATE_COUNT_D2 == 1 +#undef VT_TEMPLATE_COUNT_D2 +#define VT_TEMPLATE_COUNT_D2 2 +#elif VT_TEMPLATE_COUNT_D2 == 2 +#undef VT_TEMPLATE_COUNT_D2 +#define VT_TEMPLATE_COUNT_D2 3 +#elif VT_TEMPLATE_COUNT_D2 == 3 +#undef VT_TEMPLATE_COUNT_D2 +#define VT_TEMPLATE_COUNT_D2 4 +#elif VT_TEMPLATE_COUNT_D2 == 4 +#undef VT_TEMPLATE_COUNT_D2 +#define VT_TEMPLATE_COUNT_D2 5 +#elif VT_TEMPLATE_COUNT_D2 == 5 +#undef VT_TEMPLATE_COUNT_D2 +#define VT_TEMPLATE_COUNT_D2 6 +#elif VT_TEMPLATE_COUNT_D2 == 6 +#undef VT_TEMPLATE_COUNT_D2 +#define VT_TEMPLATE_COUNT_D2 7 +#elif VT_TEMPLATE_COUNT_D2 == 7 +#undef VT_TEMPLATE_COUNT_D2 +#define VT_TEMPLATE_COUNT_D2 0 +#if VT_TEMPLATE_COUNT_D3 == 0 +#undef VT_TEMPLATE_COUNT_D3 +#define VT_TEMPLATE_COUNT_D3 1 +#elif VT_TEMPLATE_COUNT_D3 == 1 +#undef VT_TEMPLATE_COUNT_D3 +#define VT_TEMPLATE_COUNT_D3 2 +#elif VT_TEMPLATE_COUNT_D3 == 2 +#undef VT_TEMPLATE_COUNT_D3 +#define VT_TEMPLATE_COUNT_D3 3 +#elif VT_TEMPLATE_COUNT_D3 == 3 +#undef VT_TEMPLATE_COUNT_D3 +#define VT_TEMPLATE_COUNT_D3 4 +#elif VT_TEMPLATE_COUNT_D3 == 4 +#undef VT_TEMPLATE_COUNT_D3 +#define VT_TEMPLATE_COUNT_D3 5 +#elif VT_TEMPLATE_COUNT_D3 == 5 +#undef VT_TEMPLATE_COUNT_D3 +#define VT_TEMPLATE_COUNT_D3 6 +#elif VT_TEMPLATE_COUNT_D3 == 6 +#undef VT_TEMPLATE_COUNT_D3 +#define VT_TEMPLATE_COUNT_D3 7 +#elif VT_TEMPLATE_COUNT_D3 == 7 +#error Sorry, the number of template instances is limited to 511. Define VT_NO_C11_GENERIC_API globally and use the \ +C99 prefixed function API to circumvent this restriction. +#endif +#endif +#endif + +#pragma GCC diagnostic pop + +#endif + +#undef NAME +#undef KEY_TY +#undef KEY_GET_CONST +#undef VAL_TY +#undef HASH_FN +#undef CMPR_FN +#undef MAX_LOAD +#undef KEY_DTOR_FN +#undef VAL_DTOR_FN +#undef CTX_TY +#undef MALLOC_FN +#undef FREE_FN +#undef HEADER_MODE +#undef IMPLEMENTATION_MODE +#undef VT_API_FN_QUALIFIERS + +#undef FORCEINLINE diff --git a/src/w_wad.cpp b/src/w_wad.c similarity index 90% rename from src/w_wad.cpp rename to src/w_wad.c index 9e2475095..cfc25bbaa 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.c @@ -90,34 +90,29 @@ typedef struct #define LUMPNUMCACHESIZE 2048 // should be reasonable ig #define LUMPNUMCACHENAME 32 -#include -#include -#include +#define NAME lumpnum_map +#define KEY_TY char * +#define KEY_GET_CONST +#define VAL_TY lumpnum_t +#define HASH_FN vt_hash_string +#define CMPR_FN vt_cmpr_string +#define KEY_DTOR_FN free +#include "verstable.h" -struct LumpnumNameHash -{ - std::size_t operator()(const std::string& str) const - { - // hopefully this is fast enough but should be - return static_cast(FNV1a_Hash(str.c_str(), str.length())); - } -}; +#define NAME folder_map +#define KEY_TY char * +#define KEY_GET_CONST +#define VAL_TY UINT16 +#define HASH_FN vt_hash_string +#define CMPR_FN vt_cmpr_string +#define KEY_DTOR_FN free +#include "verstable.h" -struct LumpnumStringEquals -{ - bool operator()(const std::string& str1, const std::string& str2) const - { - //return fastcmp(str1.c_str(), str2.c_str()); - return str1 == str2; - } -}; +static lumpnum_map lumpnumcache; -static std::unordered_map lumpnumcache(LUMPNUMCACHESIZE); - -// gotta wrap this in a struct due to external C linkage -struct FolderCache { - std::unordered_map map; -}; +typedef struct FolderCache { + folder_map map; +} FolderCache; static const char pat_central[] = {0x50, 0x4b, 0x01, 0x02, 0x00}; static const char pat_end[] = {0x50, 0x4b, 0x05, 0x06, 0x00}; @@ -135,6 +130,8 @@ wadfile_t *wadfiles[MAX_WADFILES] = {}; // 0 to numwadfiles-1 are valid // being ejected void W_Shutdown(void) { + lumpnum_map_cleanup(&lumpnumcache); + while (numwadfiles--) { wadfile_t *wad = wadfiles[numwadfiles]; @@ -150,14 +147,24 @@ void W_Shutdown(void) Z_Free(wad->lumpinfo[wad->numlumps].fullname); } - delete wad->startfolders; - delete wad->endfolders; + folder_map_cleanup(&wad->startfolders->map); + free(wad->startfolders); + folder_map_cleanup(&wad->endfolders->map); + free(wad->endfolders); Z_Free(wad->lumpinfo); Z_Free(wad); } } +// the lumpnum cache needs to be initialized before use +// call this as early as possible! +void W_Startup(void) +{ + lumpnum_map_init(&lumpnumcache); + lumpnum_map_reserve(&lumpnumcache, LUMPNUMCACHESIZE); +} + //=========================================================================== // LUMP BASED ROUTINES //=========================================================================== @@ -278,7 +285,7 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) lumpinfo_t *lump_p = &wadfiles[wadnum]->lumpinfo[posStart]; size_t length = len + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name - char *name = static_cast(malloc(length + 1)); + char *name = (char *)(malloc(length + 1)); if (!name) I_Error("W_LoadDehackedLumpsPK3: Out of memory!\n"); @@ -314,7 +321,7 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) if (memcmp(lump_p->name, "SOC_", 4) == 0) // Check for generic SOC lump { // shameless copy+paste of code from LUA_LoadLump size_t length = len + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name - char *name = static_cast(malloc(length + 1)); + char *name = (char *)(malloc(length + 1)); if (!name) I_Error("W_LoadDehackedLumps: Out of memory!\n"); @@ -381,7 +388,7 @@ static inline INT32 W_MakeFileMD5(const char *filename, void *resblock) // Invalidates the cache of lump numbers. Call this whenever a wad is added. FUNCINLINE static ATTRINLINE void W_InvalidateLumpnumCache(void) { - lumpnumcache.clear(); + lumpnum_map_clear(&lumpnumcache); } FUNCINLINE static ATTRINLINE UINT32 W_HashLumpName(const char *name) @@ -410,24 +417,24 @@ static restype_t ResourceFileDetect(const char* filename) */ static lumpinfo_t* ResGetLumpsStandalone(FILE* handle, UINT16* numlumps, const char* lumpname) { - lumpinfo_t* lumpinfo = static_cast(Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL)); + lumpinfo_t* lumpinfo = (lumpinfo_t *)(Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL)); lumpinfo->position = 0; fseek(handle, 0, SEEK_END); - lumpinfo->size = static_cast(ftell(handle)); + lumpinfo->size = (size_t)(ftell(handle)); fseek(handle, 0, SEEK_SET); strlcpy(lumpinfo->name, lumpname, sizeof(lumpinfo->name)); lumpinfo->namelength = strlen(lumpinfo->name); lumpinfo->hash.name = W_HashLumpName(lumpname); // Allocate the lump's long name. - /*lumpinfo->longname = static_cast(Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL)); + /*lumpinfo->longname = (char *)(Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL)); strcpy(lumpinfo->longname, lumpname); lumpinfo->longname[lumpinfo->namelength] = '\0'; lumpinfo->longnamelength = lumpinfo->namelength; lumpinfo->hash.longname = lumpinfo->hash.name;*/ // Allocate the lump's full name. - lumpinfo->fullname = static_cast(Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL)); + lumpinfo->fullname = (char *)(Z_Malloc((lumpinfo->namelength + 1) * sizeof(char), PU_STATIC, NULL)); strcpy(lumpinfo->fullname, lumpname); lumpinfo->fullname[lumpinfo->namelength] = '\0'; lumpinfo->fullnamelength = lumpinfo->namelength; @@ -474,8 +481,8 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena header.infotableofs = LONG(header.infotableofs); // read wad file directory - i = header.numlumps * sizeof (*fileinfo); - fileinfov = fileinfo = static_cast(malloc(i)); + i = header.numlumps * sizeof(*fileinfo); + fileinfov = fileinfo = (filelump_t *)(malloc(i)); if (fseek(handle, header.infotableofs, SEEK_SET) == -1 || fread(fileinfo, 1, i, handle) < i) @@ -487,7 +494,7 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena numlumps = header.numlumps; // fill in lumpinfo for this wad - lump_p = lumpinfo = static_cast(Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL)); + lump_p = lumpinfo = (lumpinfo_t *)(Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL)); for (i = 0; i < numlumps; i++, lump_p++, fileinfo++) { @@ -531,14 +538,14 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena lump_p->hash.name = W_HashLumpName(lump_p->name); // Allocate the lump's long name. - /*lump_p->longname = static_cast(Z_Malloc(9 * sizeof(char), PU_STATIC, NULL)); + /*lump_p->longname = (char *)(Z_Malloc(9 * sizeof(char), PU_STATIC, NULL)); strncpy(lump_p->longname, fileinfo->name, 8); lump_p->longname[8] = '\0'; lump_p->longnamelength = lump_p->namelength; lump_p->hash.longname = lump_p->hash.name;*/ // Allocate the lump's full name. - lump_p->fullname = static_cast(Z_Malloc(9 * sizeof(char), PU_STATIC, NULL)); + lump_p->fullname = (char *)(Z_Malloc(9 * sizeof(char), PU_STATIC, NULL)); strncpy(lump_p->fullname, fileinfo->name, 8); lump_p->fullname[8] = '\0'; lump_p->fullnamelength = lump_p->namelength; @@ -559,24 +566,24 @@ static boolean ResFindSignature(FILE* handle, const char endPat[], UINT32 startp int c; fseek(handle, 0, SEEK_END); - size_t len = static_cast(ftell(handle)); + size_t len = (size_t)(ftell(handle)); fseek(handle, startpos, SEEK_SET); - size_t remaining = static_cast(len - startpos); - size_t chunkpos = static_cast(startpos); + size_t remaining = (size_t)(len - startpos); + size_t chunkpos = (size_t)(startpos); s = endPat; //128k buffers - size_t buffer_size = std::min(128 * 1024 * sizeof(char), remaining); - CLEANUP(pfree) char* buffer = static_cast(malloc(buffer_size)); + size_t buffer_size = min(128 * 1024 * sizeof(char), remaining); + CLEANUP(pfree) char* buffer = (char *)(malloc(buffer_size)); size_t bytes_read = 0; while ((bytes_read = fread(buffer, 1, buffer_size, handle)) > 0) { for (size_t i = 0; i < bytes_read; i++) { - c = static_cast(buffer[i]); + c = (int)(buffer[i]); if (*s != c && s > endPat) // No match? s = endPat; // We "reset" the counter by sending the s pointer back to the start of the array. @@ -588,7 +595,7 @@ static boolean ResFindSignature(FILE* handle, const char endPat[], UINT32 startp if (*s == 0x00) // The array pointer has reached the key char which marks the end. It means we have matched the signature. { //the original function would leave the FILE* seeked to the end of the match - size_t foundpos = static_cast(chunkpos + i + 1); + size_t foundpos = (size_t)(chunkpos + i + 1); fseek(handle, foundpos, SEEK_SET); return true; } @@ -666,7 +673,7 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) fseek(handle, 0, SEEK_END); const long startpos = ftell(handle) - (22 + 65536); - if (!ResFindSignature(handle, pat_end, std::max(0l, startpos))) + if (!ResFindSignature(handle, pat_end, max(0l, startpos))) { CONS_Alert(CONS_ERROR, "Missing central directory\n"); return NULL; @@ -681,11 +688,11 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) numlumps = SHORT(zend.entries); - lump_p = lumpinfo = static_cast(Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL)); + lump_p = lumpinfo = (lumpinfo_t *)(Z_Malloc(numlumps * sizeof (*lumpinfo), PU_STATIC, NULL)); fseek(handle, LONG(zend.cdiroffset), SEEK_SET); - CLEANUP(Z_Pfree) char *cdir = static_cast(Z_Malloc(LONG(zend.cdirsize), PU_STATIC, &cdir)); + CLEANUP(Z_Pfree) char *cdir = (char *)(Z_Malloc(LONG(zend.cdirsize), PU_STATIC, &cdir)); if (fread(cdir, 1, LONG(zend.cdirsize), handle) < (UINT32)(LONG(zend.cdirsize))) { @@ -698,7 +705,7 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) for (i = 0; i < numlumps; i++, lump_p++) { - zentry_t *zentry = reinterpret_cast(cdir + offset); + zentry_t *zentry = (zentry_t *)(cdir + offset); char* fullname; char* trimname; char* dotpos; @@ -714,7 +721,7 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) lump_p->disksize = LONG(zentry->compsize); lump_p->size = LONG(zentry->size); - fullname = static_cast(malloc(SHORT(zentry->namelen) + 1)); + fullname = (char *)(malloc(SHORT(zentry->namelen) + 1)); strncpy(fullname, (char *)(zentry + 1), SHORT(zentry->namelen)); fullname[zentry->namelen] = 0; @@ -728,16 +735,16 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lump_p->name, '\0', 9); // Making sure they're initialized to 0. Is it necessary? - strncpy(lump_p->name, trimname, std::min(8, dotpos - trimname)); + strncpy(lump_p->name, trimname, min(8, dotpos - trimname)); lump_p->namelength = strlen(lump_p->name); lump_p->hash.name = W_HashLumpName(lump_p->name); - /*lump_p->longname = static_cast(Z_Calloc(dotpos - trimname + 1, PU_STATIC, NULL)); + /*lump_p->longname = (char *)(Z_Calloc(dotpos - trimname + 1, PU_STATIC, NULL)); strlcpy(lump_p->longname, trimname, dotpos - trimname + 1); lump_p->longnamelength = strlen(lump_p->longname); lump_p->hash.longname = W_HashLumpName(lump_p->longname);*/ - lump_p->fullname = static_cast(Z_Calloc(SHORT(zentry->namelen) + 1, PU_STATIC, NULL)); + lump_p->fullname = (char *)(Z_Calloc(SHORT(zentry->namelen) + 1, PU_STATIC, NULL)); strncpy(lump_p->fullname, fullname, SHORT(zentry->namelen)); lump_p->fullnamelength = zentry->namelen; //lump_p->hash.fullname = W_HashLumpName(lump_p->fullname); @@ -915,17 +922,19 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup) // // link wad file to search files // - wadfile = static_cast(Z_Calloc(sizeof (*wadfile), PU_STATIC, NULL)); + wadfile = (wadfile_t *)(Z_Calloc(sizeof (*wadfile), PU_STATIC, NULL)); wadfile->filename = Z_StrDup(filename); wadfile->handle = handle; - wadfile->numlumps = static_cast(numlumps); + wadfile->numlumps = (UINT16)(numlumps); wadfile->lumpinfo = lumpinfo; wadfile->important = important; fseek(handle, 0, SEEK_END); - wadfile->filesize = static_cast(ftell(handle)); + wadfile->filesize = (unsigned)(ftell(handle)); wadfile->type = type; - wadfile->startfolders = new FolderCache(); - wadfile->endfolders = new FolderCache(); + wadfile->startfolders = (FolderCache *)malloc(sizeof(FolderCache)); + folder_map_init(&wadfile->startfolders->map); + wadfile->endfolders = (FolderCache *)malloc(sizeof(FolderCache)); + folder_map_init(&wadfile->endfolders->map); // already generated, just copy it over memcpy(&wadfile->md5sum, &md5sum, 16); @@ -950,7 +959,7 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup) #ifdef HWRENDER // Read shaders from file if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) - HWR_LoadCustomShadersFromFile(numwadfiles - 1, static_cast(type == RET_PK3)); + HWR_LoadCustomShadersFromFile(numwadfiles - 1, (boolean)(type == RET_PK3)); #endif // TODO: HACK ALERT - Load Lua & SOC stuff right here. I feel like this should be out of this place, but... Let's stick with this for now. @@ -1179,9 +1188,9 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum size_t namelen; lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; - auto it = wadfiles[wad]->startfolders->map.find(name); - if (it != wadfiles[wad]->startfolders->map.end()) - return it->second; + folder_map_itr it = folder_map_get(&wadfiles[wad]->startfolders->map, name); + if (!folder_map_is_end(it)) + return it.data->val; namelen = strlen(name); @@ -1193,12 +1202,12 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum if (lump_p->fullnamelength == namelen) i++; - wadfiles[wad]->startfolders->map[name] = i; + folder_map_insert(&wadfiles[wad]->startfolders->map, strdup(name), i); return i; } } - wadfiles[wad]->startfolders->map[name] = INT16_MAX; + folder_map_insert(&wadfiles[wad]->startfolders->map, strdup(name), INT16_MAX); return INT16_MAX; } @@ -1211,9 +1220,9 @@ UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump) size_t namelen; lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; - auto it = wadfiles[wad]->endfolders->map.find(name); - if (it != wadfiles[wad]->endfolders->map.end()) - return it->second; + folder_map_itr it = folder_map_get(&wadfiles[wad]->endfolders->map, name); + if (!folder_map_is_end(it)) + return it.data->val; namelen = strlen(name); @@ -1223,7 +1232,7 @@ UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump) break; } - wadfiles[wad]->endfolders->map[name] = i; + folder_map_insert(&wadfiles[wad]->endfolders->map, strdup(name), i); return i; } @@ -1251,16 +1260,17 @@ UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump) FUNCINLINE static ATTRINLINE lumpnum_t CheckLumpInCache(const char *name) { - auto it = lumpnumcache.find(name); - if (it != lumpnumcache.end()) - return it->second; + lumpnum_map_itr it = lumpnum_map_get(&lumpnumcache, name); + if (!lumpnum_map_is_end(it)) + return it.data->val; return LUMPERROR; } FUNCINLINE static ATTRINLINE void AddLumpToCache(lumpnum_t lumpnum, const char *name) { - lumpnumcache.emplace(name, lumpnum); + I_Assert(strlen(name) <= 8); // we dont have longnames, so assume this is a non terminated string + lumpnum_map_insert(&lumpnumcache, strdup(name), lumpnum); } // @@ -1283,7 +1293,7 @@ lumpnum_t W_CheckNumForName(const char *name) // scan wad files backwards so patch lump files take precedence for (i = numwadfiles - 1; i >= 0; i--) { - check = W_CheckNumForNamePwad(name, static_cast(i), 0); + check = W_CheckNumForNamePwad(name, (UINT16)(i), 0); if (check != INT16_MAX) break; //found it @@ -1325,7 +1335,7 @@ lumpnum_t W_CheckNumForName(const char *name) // scan wad files backwards so patch lump files take precedence for (i = numwadfiles - 1; i >= 0; i--) { - check = W_CheckNumForLongNamePwad(name, static_cast(i), 0); + check = W_CheckNumForLongNamePwad(name, (UINT16)(i), 0); if (check != INT16_MAX) break; //found it @@ -1395,14 +1405,14 @@ lumpnum_t W_CheckNumForNameInBlock(const char *name, const char *blockstart, con { if (wadfiles[i]->type == RET_WAD) { - bsid = W_CheckNumForNamePwad(blockstart, static_cast(i), 0); + bsid = W_CheckNumForNamePwad(blockstart, (UINT16)(i), 0); if (bsid == INT16_MAX) continue; // Start block doesn't exist? - beid = W_CheckNumForNamePwad(blockend, static_cast(i), 0); + beid = W_CheckNumForNamePwad(blockend, (UINT16)(i), 0); if (beid == INT16_MAX) continue; // End block doesn't exist? - check = W_CheckNumForNamePwad(name, static_cast(i), bsid); + check = W_CheckNumForNamePwad(name, (UINT16)(i), bsid); if (check < beid) return (i << 16)+check; // found it, in our constraints } @@ -1603,7 +1613,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si #ifdef NO_PNG_LUMPS { size_t bytesread = fread(dest, 1, size, handle); - ErrorIfPNG(static_cast(dest), bytesread, wadfiles[wad]->filename, l->fullname); + ErrorIfPNG((UINT8 *)(dest), bytesread, wadfiles[wad]->filename, l->fullname); return bytesread; } #else @@ -1616,8 +1626,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si char *decData; // Lump's decompressed real data. size_t retval; // Helper var, lzf_decompress returns 0 when an error occurs. - rawData = static_cast(Z_Malloc(l->disksize, PU_STATIC, NULL)); - decData = static_cast(Z_Malloc(l->size, PU_STATIC, NULL)); + rawData = (char *)(Z_Malloc(l->disksize, PU_STATIC, NULL)); + decData = (char *)(Z_Malloc(l->size, PU_STATIC, NULL)); if (fread(rawData, 1, l->disksize, handle) < l->disksize) I_Error("wad %d, lump %d: cannot read compressed data", wad, lump); @@ -1644,7 +1654,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si Z_Free(rawData); Z_Free(decData); #ifdef NO_PNG_LUMPS - ErrorIfPNG(static_cast(dest), size, wadfiles[wad]->filename, l->fullname); + ErrorIfPNG((UINT8 *)(dest), size, wadfiles[wad]->filename, l->fullname); #endif return size; #else @@ -1664,8 +1674,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si unsigned long rawSize = l->disksize; unsigned long decSize = size; - rawData = static_cast(Z_Malloc(rawSize, PU_STATIC, NULL)); - decData = static_cast(dest); + rawData = (UINT8 *)(Z_Malloc(rawSize, PU_STATIC, NULL)); + decData = (UINT8 *)(dest); if (fread(rawData, 1, rawSize, handle) < rawSize) I_Error("wad %d, lump %d: cannot read compressed data", wad, lump); @@ -1701,7 +1711,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si Z_Free(rawData); #ifdef NO_PNG_LUMPS - ErrorIfPNG(static_cast(dest), size, wadfiles[wad]->filename, l->fullname); + ErrorIfPNG((UINT8 *)(dest), size, wadfiles[wad]->filename, l->fullname); #endif return size; } @@ -1889,7 +1899,7 @@ void *W_CacheSoftwarePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) W_ReadLumpHeaderPwad(wad, lump, lumpdata, 0, 0); dest = Z_Calloc(sizeof(patch_t), tag, &lumpcache[lump]); - Patch_Create(static_cast(lumpdata), len, dest); + Patch_Create((softwarepatch_t *)(lumpdata), len, dest); Z_Free(lumpdata); } @@ -1911,7 +1921,7 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) if (!TestValidLump(wad, lump)) return NULL; - patch = static_cast(W_CacheSoftwarePatchNumPwad(wad, lump, tag)); + patch = (patch_t *)(W_CacheSoftwarePatchNumPwad(wad, lump, tag)); if (patch == NULL) return NULL; @@ -1922,7 +1932,7 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) Patch_CreateGL(patch); #endif - return static_cast(patch); + return (void*)(patch); } void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag) @@ -1950,10 +1960,10 @@ void *W_GetCachedRotPatchPwad(UINT16 wad, UINT16 lump) if (!rotcache[lump]) { rotsprite_t *rspr = RotatedPatch_Create(ROTANGLES); - Z_SetUser(rspr, static_cast(&rotcache[lump])); + Z_SetUser(rspr, (void**)(&rotcache[lump])); } - return static_cast(rotcache[lump]); + return (void*)(rotcache[lump]); } #endif // ROTSPRITE @@ -1966,7 +1976,7 @@ void W_UnlockCachedPatch(void *patch) // have different lifetimes from software's. #ifdef HWRENDER if (rendermode == render_opengl) - HWR_UnlockCachedPatch(static_cast((static_cast(patch))->hardware)); + HWR_UnlockCachedPatch((GLPatch_t *)(((patch_t *)(patch))->hardware)); else #endif Z_ChangeTag(patch, PU_PATCH); @@ -2001,7 +2011,7 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag) if (rotationangle < 1 || rotationangle >= ROTANGLES) return W_CachePatchNum(num, tag); - rspr = static_cast(W_GetCachedRotPatchPwad(WADFILENUM(num), LUMPNUM(num))); + rspr = (rotsprite_t *)(W_GetCachedRotPatchPwad(WADFILENUM(num), LUMPNUM(num))); if (rspr == NULL) return W_CachePatchNum(W_GetNumForName("MISSING"), tag); @@ -2010,7 +2020,7 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag) { INT32 xpivot = 0, ypivot = 0; - ptr = static_cast(W_CachePatchNum(num, PU_PATCH)); + ptr = (patch_t *)(W_CachePatchNum(num, PU_PATCH)); if (ptr == NULL) return W_CachePatchNum(W_GetNumForName("MISSING"), tag); @@ -2204,7 +2214,7 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) file_size = ftell(fp); const long startpos = file_size - (22 + 65536); - if (!ResFindSignature(fp, pat_end, std::max(0l, startpos))) + if (!ResFindSignature(fp, pat_end, max(0l, startpos))) return true; fseek(fp, -4, SEEK_CUR); @@ -2217,7 +2227,7 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) fseek(fp, LONG(zend.cdiroffset), SEEK_SET); - CLEANUP(pfree) char *cdir = static_cast(malloc(LONG(zend.cdirsize))); + CLEANUP(pfree) char *cdir = (char *)(malloc(LONG(zend.cdirsize))); if (fread(cdir, 1, LONG(zend.cdirsize), fp) < (UINT32)(LONG(zend.cdirsize))) { @@ -2228,7 +2238,7 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) for (i = 0; i < numlumps; i++) { - zentry_t *zentry = reinterpret_cast(cdir + offset); + zentry_t *zentry = (zentry_t *)(cdir + offset); char* fullname; char* trimname; char* dotpos; @@ -2240,7 +2250,7 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) if (verified == true) { - fullname = static_cast(malloc(SHORT(zentry->namelen) + 1)); + fullname = (char *)(malloc(SHORT(zentry->namelen) + 1)); strncpy(fullname, (char *)(zentry + 1), SHORT(zentry->namelen)); fullname[zentry->namelen] = 0; @@ -2256,7 +2266,7 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? - strncpy(lumpname, trimname, std::min(8, dotpos - trimname)); + strncpy(lumpname, trimname, min(8, dotpos - trimname)); if (!W_VerifyName(lumpname, checklist, status)) verified = false; @@ -2452,7 +2462,7 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) file_size = ftell(fp); const long startpos = file_size - (22 + 65536); - if (!ResFindSignature(fp, pat_end, std::max(0l, startpos))) + if (!ResFindSignature(fp, pat_end, max(0l, startpos))) return true; fseek(fp, -4, SEEK_CUR); @@ -2465,7 +2475,7 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) fseek(fp, LONG(zend.cdiroffset), SEEK_SET); - CLEANUP(pfree) char *cdir = static_cast(malloc(LONG(zend.cdirsize))); + CLEANUP(pfree) char *cdir = (char *)(malloc(LONG(zend.cdirsize))); if (fread(cdir, 1, LONG(zend.cdirsize), fp) < (UINT32)(LONG(zend.cdirsize))) { @@ -2476,7 +2486,7 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) for (i = 0; i < numlumps; i++) { - zentry_t *zentry = reinterpret_cast(cdir + offset); + zentry_t *zentry = (zentry_t *)(cdir + offset); CLEANUP(pfree) char* fullname = NULL; char* trimname; char* dotpos; @@ -2486,7 +2496,7 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) return false; } - fullname = static_cast(malloc(SHORT(zentry->namelen) + 1)); + fullname = (char *)(malloc(SHORT(zentry->namelen) + 1)); strncpy(fullname, (char *)(zentry + 1), SHORT(zentry->namelen)); fullname[zentry->namelen] = 0; @@ -2502,7 +2512,7 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) dotpos = fullname + strlen(fullname); // Watch for files without extension. memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? - strncpy(lumpname, trimname, std::min(8, dotpos - trimname)); + strncpy(lumpname, trimname, min(8, dotpos - trimname)); if (W_NameStartsWith(lumpname, checklist)) { @@ -2624,18 +2634,18 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) size_t *vsizecache; // Remember that we're assuming that the WAD will have a specific set of lumps in a specific order. - UINT8 *wadData = static_cast(W_CacheLumpNum(lumpnum, PU_LEVEL)); + UINT8 *wadData = (UINT8 *)(W_CacheLumpNum(lumpnum, PU_LEVEL)); if (wadData == NULL) I_Error("vres_GetMap: Invalid WadData!\n"); - filelump_t *fileinfo = reinterpret_cast(wadData + LONG((reinterpret_cast(wadData))->infotableofs)); + filelump_t *fileinfo = (filelump_t *)(wadData + LONG(((wadinfo_t *)(wadData))->infotableofs)); - i = LONG((reinterpret_cast(wadData))->numlumps); - vsizecache = static_cast(Z_Malloc(sizeof(size_t)*i, PU_LEVEL, NULL)); + i = LONG(((wadinfo_t *)(wadData))->numlumps); + vsizecache = (size_t *)(Z_Malloc(sizeof(size_t)*i, PU_LEVEL, NULL)); for (realentry = 0; realentry < i; realentry++) { - vsizecache[realentry] = static_cast(LONG((reinterpret_cast(fileinfo + realentry))->size)); + vsizecache[realentry] = (size_t)(LONG(((filelump_t *)(fileinfo + realentry))->size)); if (!vsizecache[realentry]) continue; @@ -2643,7 +2653,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) numlumps++; } - vlumps = static_cast(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL)); + vlumps = (virtlump_t *)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL)); if (vlumps == NULL) I_Error("vres_GetMap: Out of memory!\n"); @@ -2665,7 +2675,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) // Play it safe with the name in this case. memcpy(vlumps[i].name, name, 8); vlumps[i].name[8] = '\0'; - vlumps[i].data = static_cast( + vlumps[i].data = (UINT8 *)( Z_Malloc(vlumps[i].size, PU_LEVEL, NULL) // This is memory inefficient, sorry about that. ); memcpy(vlumps[i].data, wadData + LONG((fileinfo + realentry)->filepos), vlumps[i].size); @@ -2692,7 +2702,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) } numlumps++; - vlumps = static_cast(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL)); + vlumps = (virtlump_t *)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL)); if (vlumps == NULL) I_Error("vres_GetMap: Out of memory!\n"); @@ -2713,11 +2723,11 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) vlumps[i].size = W_LumpLength(lumpnum); memcpy(vlumps[i].name, name, 8); vlumps[i].name[8] = '\0'; - vlumps[i].data = static_cast(W_CacheLumpNum(lumpnum, PU_LEVEL)); + vlumps[i].data = (UINT8 *)(W_CacheLumpNum(lumpnum, PU_LEVEL)); } } - vres = static_cast(Z_Malloc(sizeof(virtres_t), PU_LEVEL, NULL)); + vres = (virtres_t *)(Z_Malloc(sizeof(virtres_t), PU_LEVEL, NULL)); vres->vlumps = vlumps; vres->numlumps = numlumps; diff --git a/src/w_wad.h b/src/w_wad.h index d21afb982..fc7f25fec 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -126,7 +126,6 @@ typedef enum restype RET_UNKNOWN, } restype_t; - typedef struct wadfile_s { char *filename; @@ -155,6 +154,7 @@ extern wadfile_t *wadfiles[MAX_WADFILES]; // ========================================================================= +void W_Startup(void); void W_Shutdown(void); // Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened From ba808307e95434707a8fdb0b345229f8e87cbbbc Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 24 Feb 2026 16:10:54 +0100 Subject: [PATCH 173/589] FORCEINLINE is apparently used by windows already lmao --- src/verstable.h | 102 ++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/src/verstable.h b/src/verstable.h index 8c5a49dc3..b3fe13f91 100644 --- a/src/verstable.h +++ b/src/verstable.h @@ -441,12 +441,12 @@ License (MIT): #ifdef __GNUC__ #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) // >= GCC 3.1 - #define FORCEINLINE __attribute__((always_inline)) + #define FORCE_INLINE __attribute__((always_inline)) #else - #define FORCEINLINE + #define FORCE_INLINE #endif #else - #define FORCEINLINE + #define FORCE_INLINE #endif #ifndef VERSTABLE_H @@ -485,7 +485,7 @@ License (MIT): // Extracts a hash fragment from a uint64_t hash code. // We take the highest four bits so that keys that map (via modulo) to the same bucket have distinct hash fragments. -static inline FORCEINLINE uint16_t vt_hashfrag( uint64_t hash ) +static inline FORCE_INLINE uint16_t vt_hashfrag( uint64_t hash ) { return ( hash >> 48 ) & VT_HASH_FRAG_MASK; } @@ -493,7 +493,7 @@ static inline FORCEINLINE uint16_t vt_hashfrag( uint64_t hash ) // Standard quadratic probing formula that guarantees that all buckets are visited when the bucket count is a power of // two (at least in theory, because the displacement limit could terminate the search early when the bucket count is // high). -static inline FORCEINLINE size_t vt_quadratic( uint16_t displacement ) +static inline FORCE_INLINE size_t vt_quadratic( uint16_t displacement ) { return ( (size_t)displacement * displacement + displacement ) / 2; } @@ -506,7 +506,7 @@ static inline FORCEINLINE size_t vt_quadratic( uint16_t displacement ) #if defined( __GNUC__ ) && ULLONG_MAX == 0xFFFFFFFFFFFFFFFF -static inline FORCEINLINE int vt_first_nonzero_uint16( uint64_t val ) +static inline FORCE_INLINE int vt_first_nonzero_uint16( uint64_t val ) { const uint16_t endian_checker = 0x0001; if( *(const char *)&endian_checker ) // Little-endian (the compiler will optimize away the check at -O1 and above). @@ -521,7 +521,7 @@ static inline FORCEINLINE int vt_first_nonzero_uint16( uint64_t val ) #pragma intrinsic(_BitScanForward64) #pragma intrinsic(_BitScanReverse64) -static inline FORCEINLINE int vt_first_nonzero_uint16( uint64_t val ) +static inline FORCE_INLINE int vt_first_nonzero_uint16( uint64_t val ) { unsigned long result; @@ -539,7 +539,7 @@ static inline FORCEINLINE int vt_first_nonzero_uint16( uint64_t val ) #else -static inline FORCEINLINE int vt_first_nonzero_uint16( uint64_t val ) +static inline FORCE_INLINE int vt_first_nonzero_uint16( uint64_t val ) { int result = 0; @@ -567,7 +567,7 @@ static const uint16_t vt_empty_placeholder_metadatum = VT_EMPTY; // Fast-hash, as described by https://jonkagstrom.com/bit-mixer-construction and // https://code.google.com/archive/p/fast-hash. // In testing, this hash function provided slightly better performance than the Murmur3 mixer. -static inline FORCEINLINE uint64_t vt_hash_integer( uint64_t key ) +static inline FORCE_INLINE uint64_t vt_hash_integer( uint64_t key ) { key ^= key >> 23; key *= 0x2127599bf4325c37ull; @@ -581,7 +581,7 @@ static inline FORCEINLINE uint64_t vt_hash_integer( uint64_t key ) // * We do not handle endianness, so the result will differ depending on the platform. // * We omit the code optimized for 32-bit platforms. -static inline FORCEINLINE void vt_wymum( uint64_t *a, uint64_t *b ) +static inline FORCE_INLINE void vt_wymum( uint64_t *a, uint64_t *b ) { #if defined( __SIZEOF_INT128__ ) __uint128_t r = *a; @@ -609,32 +609,32 @@ static inline FORCEINLINE void vt_wymum( uint64_t *a, uint64_t *b ) #endif } -static inline FORCEINLINE uint64_t vt_wymix( uint64_t a, uint64_t b ) +static inline FORCE_INLINE uint64_t vt_wymix( uint64_t a, uint64_t b ) { vt_wymum( &a, &b ); return a ^ b; } -static inline FORCEINLINE uint64_t vt_wyr8( const unsigned char *p ) +static inline FORCE_INLINE uint64_t vt_wyr8( const unsigned char *p ) { uint64_t v; memcpy( &v, p, 8 ); return v; } -static inline FORCEINLINE uint64_t vt_wyr4( const unsigned char *p ) +static inline FORCE_INLINE uint64_t vt_wyr4( const unsigned char *p ) { uint32_t v; memcpy( &v, p, 4 ); return v; } -static inline FORCEINLINE uint64_t vt_wyr3( const unsigned char *p, size_t k ) +static inline FORCE_INLINE uint64_t vt_wyr3( const unsigned char *p, size_t k ) { return ( ( (uint64_t)p[ 0 ] ) << 16 ) | ( ( (uint64_t)p[ k >> 1 ] ) << 8 ) | p[ k - 1 ]; } -static inline FORCEINLINE size_t vt_wyhash( const void *key, size_t len ) +static inline FORCE_INLINE size_t vt_wyhash( const void *key, size_t len ) { const unsigned char *p = (const unsigned char *)key; uint64_t seed = 0xca813bf4c7abf0a9ull; @@ -693,41 +693,41 @@ static inline FORCEINLINE size_t vt_wyhash( const void *key, size_t len ) return (size_t)vt_wymix( a ^ 0x2d358dccaa6c78a5ull ^ len, b ^ 0x8bb84b93962eacc9ull ); } -static inline FORCEINLINE uint64_t vt_hash_string( const char *key ) +static inline FORCE_INLINE uint64_t vt_hash_string( const char *key ) { return vt_wyhash( key, strlen( key ) ); } -static inline FORCEINLINE bool vt_cmpr_integer( uint64_t key_1, uint64_t key_2 ) +static inline FORCE_INLINE bool vt_cmpr_integer( uint64_t key_1, uint64_t key_2 ) { return key_1 == key_2; } -static inline FORCEINLINE bool vt_cmpr_string( const char *key_1, const char *key_2 ) +static inline FORCE_INLINE bool vt_cmpr_string( const char *key_1, const char *key_2 ) { return strcmp( key_1, key_2 ) == 0; } // Default allocation and free functions. -static inline FORCEINLINE void *vt_malloc( size_t size ) +static inline FORCE_INLINE void *vt_malloc( size_t size ) { return malloc( size ); } -static inline FORCEINLINE void vt_free( void *ptr, size_t size ) +static inline FORCE_INLINE void vt_free( void *ptr, size_t size ) { (void)size; free( ptr ); } -static inline FORCEINLINE void *vt_malloc_with_ctx( size_t size, void *ctx ) +static inline FORCE_INLINE void *vt_malloc_with_ctx( size_t size, void *ctx ) { (void)ctx; return malloc( size ); } -static inline FORCEINLINE void vt_free_with_ctx( void *ptr, size_t size, void *ctx ) +static inline FORCE_INLINE void vt_free_with_ctx( void *ptr, size_t size, void *ctx ) { (void)size; (void)ctx; @@ -894,7 +894,7 @@ typedef struct #if defined( HEADER_MODE ) || defined( IMPLEMENTATION_MODE ) #define VT_API_FN_QUALIFIERS #else -#define VT_API_FN_QUALIFIERS static inline FORCEINLINE +#define VT_API_FN_QUALIFIERS static inline FORCE_INLINE #endif #ifndef IMPLEMENTATION_MODE @@ -966,7 +966,7 @@ VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _erase_itr_raw ) ( NAME *, VT_CAT( NAME, // This function must be inlined to ensure that the compiler optimizes away the NAME_fast_forward call if the returned // iterator is discarded. #ifdef __GNUC__ -static inline FORCEINLINE +static inline FORCE_INLINE #elif defined( _MSC_VER ) static __forceinline #else @@ -1083,7 +1083,7 @@ VT_API_FN_QUALIFIERS void VT_CAT( NAME, _init )( // This function returns the offset of the beginning of the metadata, i.e. the size of the buckets array plus the // (usually zero) padding. // It assumes that the bucket count is not zero. -static inline FORCEINLINE size_t VT_CAT( NAME, _metadata_offset )( NAME *table ) +static inline FORCE_INLINE size_t VT_CAT( NAME, _metadata_offset )( NAME *table ) { // Use sizeof, rather than alignof, for C99 compatibility. return ( ( ( table->buckets_mask + 1 ) * sizeof( VT_CAT( NAME, _bucket ) ) + sizeof( uint16_t ) - 1 ) / @@ -1092,7 +1092,7 @@ static inline FORCEINLINE size_t VT_CAT( NAME, _metadata_offset )( NAME *table ) // Returns the total allocation size, including the buckets array, padding, metadata, and excess metadata. // As above, this function assumes that the bucket count is not zero. -static inline FORCEINLINE size_t VT_CAT( NAME, _total_alloc_size )( NAME *table ) +static inline FORCE_INLINE size_t VT_CAT( NAME, _total_alloc_size )( NAME *table ) { return VT_CAT( NAME, _metadata_offset )( table ) + ( table->buckets_mask + 1 + 4 ) * sizeof( uint16_t ); } @@ -1163,7 +1163,7 @@ VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _is_end )( VT_CAT( NAME, _itr ) itr ) // other chains might have freed up buckets that could fall in this chain before the final key. // Returns true if an empty bucket within the range of the displacement limit was found, in which case the final two // pointer arguments contain the index of the empty bucket and its quadratic displacement from home_bucket. -static inline FORCEINLINE bool VT_CAT( NAME, _find_first_empty )( +static inline FORCE_INLINE bool VT_CAT( NAME, _find_first_empty )( NAME *table, size_t home_bucket, size_t *empty, @@ -1190,7 +1190,7 @@ static inline FORCEINLINE bool VT_CAT( NAME, _find_first_empty )( // quadratic displacement and returns the index of the bucket containing that key. // Although the new key could simply be linked to the end of the chain, keeping the chain ordered by displacement // theoretically improves cache locality during lookups. -static inline FORCEINLINE size_t VT_CAT( NAME, _find_insert_location_in_chain )( +static inline FORCE_INLINE size_t VT_CAT( NAME, _find_insert_location_in_chain )( NAME *table, size_t home_bucket, uint16_t displacement_to_empty @@ -1219,7 +1219,7 @@ static inline FORCEINLINE size_t VT_CAT( NAME, _find_insert_location_in_chain )( // * Re-linking the key to the chain. // Returns true if the eviction succeeded, or false if no empty bucket to which to evict the occupying key could be // found within the displacement limit. -static inline FORCEINLINE bool VT_CAT( NAME, _evict )( NAME *table, size_t bucket ) +static inline FORCE_INLINE bool VT_CAT( NAME, _evict )( NAME *table, size_t bucket ) { // Find the previous key in chain. size_t home_bucket = HASH_FN( table->buckets[ bucket ].key ) & table->buckets_mask; @@ -1261,7 +1261,7 @@ static inline FORCEINLINE bool VT_CAT( NAME, _evict )( NAME *table, size_t bucke // Returns an end iterator, i.e. any iterator for which .metadatum == .metadata_end. // This function just cleans up the library code in functions that return an end iterator as a failure indicator. -static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( NAME, _end_itr )( void ) +static inline FORCE_INLINE VT_CAT( NAME, _itr ) VT_CAT( NAME, _end_itr )( void ) { VT_CAT( NAME, _itr ) itr = { NULL, NULL, NULL, 0 }; return itr; @@ -1282,7 +1282,7 @@ static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( NAME, _end_itr )( void ) // inserted because of the maximum load factor or displacement limit constraints. // If replace is false, then the return value is as described above, except that if the key already exists, the function // returns an iterator to the existing key. -static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( NAME, _insert_raw )( +static inline FORCE_INLINE VT_CAT( NAME, _itr ) VT_CAT( NAME, _insert_raw )( NAME *table, KEY_TY key, #ifdef VAL_TY @@ -1415,7 +1415,7 @@ static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( NAME, _insert_raw )( // In testing, the no-inline approach showed a performance benefit when inserting existing keys (i.e. replacing). #ifdef __GNUC__ #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wattributes" // Silence warning about combining noinline with static inline FORCEINLINE. +#pragma GCC diagnostic ignored "-Wattributes" // Silence warning about combining noinline with static inline FORCE_INLINE. __attribute__((noinline)) static inline #elif defined( _MSC_VER ) __declspec(noinline) static inline @@ -1738,7 +1738,7 @@ VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _erase )( NAME *table, KEY_TY key ) // Finds the first occupied bucket at or after the bucket pointed to by itr. // This function scans four buckets at a time, ideally using intrinsics. -static inline FORCEINLINE void VT_CAT( NAME, _fast_forward )( VT_CAT( NAME, _itr ) *itr ) +static inline FORCE_INLINE void VT_CAT( NAME, _fast_forward )( VT_CAT( NAME, _itr ) *itr ) { while( true ) { @@ -1768,7 +1768,7 @@ VT_API_FN_QUALIFIERS VT_CAT( NAME, _itr ) VT_CAT( NAME, _next )( VT_CAT( NAME, _ // Returns the minimum bucket count required to accommodate a certain number of keys, which is governed by the maximum // load factor. -static inline FORCEINLINE size_t VT_CAT( NAME, _min_bucket_count_for_size )( size_t size ) +static inline FORCE_INLINE size_t VT_CAT( NAME, _min_bucket_count_for_size )( size_t size ) { if( size == 0 ) return 0; @@ -1893,7 +1893,7 @@ VT_API_FN_QUALIFIERS void VT_CAT( NAME, _cleanup )( NAME *table ) typedef NAME VT_CAT( vt_table_, VT_TEMPLATE_COUNT ); typedef VT_CAT( NAME, _itr ) VT_CAT( vt_table_itr_, VT_TEMPLATE_COUNT ); -static inline FORCEINLINE void VT_CAT( vt_init_, VT_TEMPLATE_COUNT )( +static inline FORCE_INLINE void VT_CAT( vt_init_, VT_TEMPLATE_COUNT )( NAME *table #ifdef CTX_TY , CTX_TY ctx @@ -1908,7 +1908,7 @@ static inline FORCEINLINE void VT_CAT( vt_init_, VT_TEMPLATE_COUNT )( ); } -static inline FORCEINLINE bool VT_CAT( vt_init_clone_, VT_TEMPLATE_COUNT )( +static inline FORCE_INLINE bool VT_CAT( vt_init_clone_, VT_TEMPLATE_COUNT )( NAME *table, const NAME* source #ifdef CTX_TY @@ -1925,22 +1925,22 @@ static inline FORCEINLINE bool VT_CAT( vt_init_clone_, VT_TEMPLATE_COUNT )( ); } -static inline FORCEINLINE size_t VT_CAT( vt_size_, VT_TEMPLATE_COUNT )( const NAME *table ) +static inline FORCE_INLINE size_t VT_CAT( vt_size_, VT_TEMPLATE_COUNT )( const NAME *table ) { return VT_CAT( NAME, _size )( table ); } -static inline FORCEINLINE size_t VT_CAT( vt_bucket_count_, VT_TEMPLATE_COUNT )( const NAME *table ) +static inline FORCE_INLINE size_t VT_CAT( vt_bucket_count_, VT_TEMPLATE_COUNT )( const NAME *table ) { return VT_CAT( NAME, _bucket_count )( table ); } -static inline FORCEINLINE bool VT_CAT( vt_is_end_, VT_TEMPLATE_COUNT )( VT_CAT( NAME, _itr ) itr ) +static inline FORCE_INLINE bool VT_CAT( vt_is_end_, VT_TEMPLATE_COUNT )( VT_CAT( NAME, _itr ) itr ) { return VT_CAT( NAME, _is_end )( itr ); } -static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_insert_, VT_TEMPLATE_COUNT )( +static inline FORCE_INLINE VT_CAT( NAME, _itr ) VT_CAT( vt_insert_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key #ifdef VAL_TY @@ -1957,7 +1957,7 @@ static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_insert_, VT_TEMPLATE_C ); } -static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_get_or_insert_, VT_TEMPLATE_COUNT )( +static inline FORCE_INLINE VT_CAT( NAME, _itr ) VT_CAT( vt_get_or_insert_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key #ifdef VAL_TY @@ -1974,47 +1974,47 @@ static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_get_or_insert_, VT_TEM ); } -static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( const NAME *table, KEY_TY key ) +static inline FORCE_INLINE VT_CAT( NAME, _itr ) VT_CAT( vt_get_, VT_TEMPLATE_COUNT )( const NAME *table, KEY_TY key ) { return VT_CAT( NAME, _get )( table, key ); } -static inline FORCEINLINE bool VT_CAT( vt_erase_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key ) +static inline FORCE_INLINE bool VT_CAT( vt_erase_, VT_TEMPLATE_COUNT )( NAME *table, KEY_TY key ) { return VT_CAT( NAME, _erase )( table, key ); } -static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_next_, VT_TEMPLATE_COUNT )( VT_CAT( NAME, _itr ) itr ) +static inline FORCE_INLINE VT_CAT( NAME, _itr ) VT_CAT( vt_next_, VT_TEMPLATE_COUNT )( VT_CAT( NAME, _itr ) itr ) { return VT_CAT( NAME, _next )( itr ); } -static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_erase_itr_, VT_TEMPLATE_COUNT )( NAME *table, VT_CAT( NAME, _itr ) itr ) +static inline FORCE_INLINE VT_CAT( NAME, _itr ) VT_CAT( vt_erase_itr_, VT_TEMPLATE_COUNT )( NAME *table, VT_CAT( NAME, _itr ) itr ) { return VT_CAT( NAME, _erase_itr )( table, itr ); } -static inline FORCEINLINE bool VT_CAT( vt_reserve_, VT_TEMPLATE_COUNT )( NAME *table, size_t bucket_count ) +static inline FORCE_INLINE bool VT_CAT( vt_reserve_, VT_TEMPLATE_COUNT )( NAME *table, size_t bucket_count ) { return VT_CAT( NAME, _reserve )( table, bucket_count ); } -static inline FORCEINLINE bool VT_CAT( vt_shrink_, VT_TEMPLATE_COUNT )( NAME *table ) +static inline FORCE_INLINE bool VT_CAT( vt_shrink_, VT_TEMPLATE_COUNT )( NAME *table ) { return VT_CAT( NAME, _shrink )( table ); } -static inline FORCEINLINE VT_CAT( NAME, _itr ) VT_CAT( vt_first_, VT_TEMPLATE_COUNT )( const NAME *table ) +static inline FORCE_INLINE VT_CAT( NAME, _itr ) VT_CAT( vt_first_, VT_TEMPLATE_COUNT )( const NAME *table ) { return VT_CAT( NAME, _first )( table ); } -static inline FORCEINLINE void VT_CAT( vt_clear_, VT_TEMPLATE_COUNT )( NAME *table ) +static inline FORCE_INLINE void VT_CAT( vt_clear_, VT_TEMPLATE_COUNT )( NAME *table ) { VT_CAT( NAME, _clear )( table ); } -static inline FORCEINLINE void VT_CAT( vt_cleanup_, VT_TEMPLATE_COUNT )( NAME *table ) +static inline FORCE_INLINE void VT_CAT( vt_cleanup_, VT_TEMPLATE_COUNT )( NAME *table ) { VT_CAT( NAME, _cleanup )( table ); } @@ -2116,4 +2116,4 @@ C99 prefixed function API to circumvent this restriction. #undef IMPLEMENTATION_MODE #undef VT_API_FN_QUALIFIERS -#undef FORCEINLINE +#undef FORCE_INLINE From 7c24d92613ef93affeb3fd5b571df14560b64d76 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 16:45:17 +0100 Subject: [PATCH 174/589] delet V_GetSkincolorChar this was unused and broken anyways think this came from snowy kart or smth --- src/v_video.c | 161 -------------------------------------------------- src/v_video.h | 2 - 2 files changed, 163 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index fde09cc0b..9898e9c29 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3309,167 +3309,6 @@ INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option) return max(i-1, 0); } -char V_GetSkincolorChar(INT32 color) -{ - char cstart = 0x80; - - switch (color) - { - case SKINCOLOR_WHITE: - case SKINCOLOR_SILVER: - case SKINCOLOR_SLATE: - cstart = 0x80; // White - break; - - case SKINCOLOR_GREY: - case SKINCOLOR_NICKEL: - case SKINCOLOR_BLACK: - case SKINCOLOR_SKUNK: - case SKINCOLOR_JET: - cstart = 0x86; // V_GRAYMAP - break; - - case SKINCOLOR_SEPIA: - case SKINCOLOR_BEIGE: - case SKINCOLOR_WALNUT: - case SKINCOLOR_BROWN: - case SKINCOLOR_LEATHER: - case SKINCOLOR_RUST: - case SKINCOLOR_WRISTWATCH: - cstart = 0x8e; // V_BROWNMAP - break; - - case SKINCOLOR_FAIRY: - case SKINCOLOR_SALMON: - case SKINCOLOR_PINK: - case SKINCOLOR_ROSE: - case SKINCOLOR_BRICK: - case SKINCOLOR_LEMONADE: - case SKINCOLOR_BUBBLEGUM: - case SKINCOLOR_LILAC: - cstart = 0x8d; // V_PINKMAP - break; - - case SKINCOLOR_CINNAMON: - case SKINCOLOR_RUBY: - case SKINCOLOR_RASPBERRY: - case SKINCOLOR_CHERRY: - case SKINCOLOR_RED: - case SKINCOLOR_CRIMSON: - case SKINCOLOR_MAROON: - case SKINCOLOR_FLAME: - case SKINCOLOR_SCARLET: - case SKINCOLOR_KETCHUP: - cstart = 0x85; // V_REDMAP - break; - - case SKINCOLOR_DAWN: - case SKINCOLOR_SUNSET: - case SKINCOLOR_CREAMSICLE: - case SKINCOLOR_ORANGE: - case SKINCOLOR_PUMPKIN: - case SKINCOLOR_ROSEWOOD: - case SKINCOLOR_BURGUNDY: - case SKINCOLOR_TANGERINE: - cstart = 0x87; // V_ORANGEMAP - break; - - case SKINCOLOR_PEACH: - case SKINCOLOR_CARAMEL: - case SKINCOLOR_CREAM: - cstart = 0x8f; // V_PEACHMAP - break; - - case SKINCOLOR_GOLD: - case SKINCOLOR_ROYAL: - case SKINCOLOR_BRONZE: - case SKINCOLOR_COPPER: - case SKINCOLOR_THUNDER: - cstart = 0x8a; // V_GOLDMAP - break; - - case SKINCOLOR_POPCORN: - case SKINCOLOR_QUARRY: - case SKINCOLOR_YELLOW: - case SKINCOLOR_MUSTARD: - case SKINCOLOR_CROCODILE: - case SKINCOLOR_OLIVE: - cstart = 0x82; // V_YELLOWMAP - break; - - case SKINCOLOR_ARTICHOKE: - case SKINCOLOR_VOMIT: - case SKINCOLOR_GARDEN: - case SKINCOLOR_TEA: - case SKINCOLOR_PISTACHIO: - cstart = 0x8b; // V_TEAMAP - break; - - case SKINCOLOR_LIME: - case SKINCOLOR_HANDHELD: - case SKINCOLOR_MOSS: - case SKINCOLOR_CAMOUFLAGE: - case SKINCOLOR_ROBOHOOD: - case SKINCOLOR_MINT: - case SKINCOLOR_GREEN: - case SKINCOLOR_PINETREE: - case SKINCOLOR_EMERALD: - case SKINCOLOR_SWAMP: - case SKINCOLOR_DREAM: - case SKINCOLOR_PLAGUE: - case SKINCOLOR_ALGAE: - cstart = 0x83; // V_GREENMAP - break; - - case SKINCOLOR_CARIBBEAN: - case SKINCOLOR_AZURE: - case SKINCOLOR_AQUA: - case SKINCOLOR_TEAL: - case SKINCOLOR_CYAN: - case SKINCOLOR_JAWZ: - case SKINCOLOR_CERULEAN: - case SKINCOLOR_NAVY: - case SKINCOLOR_SAPPHIRE: - cstart = 0x88; // V_SKYMAP - break; - - case SKINCOLOR_PIGEON: - case SKINCOLOR_PLATINUM: - case SKINCOLOR_STEEL: - cstart = 0x8c; // V_STEELMAP - break; - - case SKINCOLOR_PERIWINKLE: - case SKINCOLOR_BLUE: - case SKINCOLOR_BLUEBERRY: - case SKINCOLOR_NOVA: - cstart = 0x84; // V_BLUEMAP - break; - - case SKINCOLOR_ULTRAVIOLET: - case SKINCOLOR_PURPLE: - case SKINCOLOR_FUCHSIA: - cstart = 0x81; // V_PURPLEMAP - break; - - case SKINCOLOR_PASTEL: - case SKINCOLOR_MOONSLAM: - case SKINCOLOR_DUSK: - case SKINCOLOR_TOXIC: - case SKINCOLOR_MAUVE: - case SKINCOLOR_LAVENDER: - case SKINCOLOR_BYZANTIUM: - case SKINCOLOR_POMEGRANATE: - cstart = 0x89; // V_LAVENDERMAP - break; - - default: - break; - } - - return cstart; -} - INT32 V_SkinColorToHighlightcolor(skincolors_t color) { switch (color) diff --git a/src/v_video.h b/src/v_video.h index 7eea1468c..0a77c4bc2 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -287,8 +287,6 @@ INT32 V_ThinSubStringWidth(const char *string, INT32 length, INT32 option); // Find maximum length for substring taken from current string to fit into given width INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option); -char V_GetSkincolorChar(INT32 color); - INT32 V_SkinColorToHighlightcolor(skincolors_t color); // this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol From 3e327263c9e11a938cbebcad727f7a06e65c798e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 16:46:37 +0100 Subject: [PATCH 175/589] fix faulty papersprite flipping in opengl lol --- src/hardware/hw_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index e9aa0532d..15434ec20 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -4850,7 +4850,7 @@ static void HWR_ProjectSprite(mobj_t *thing) flip = sprframe->flip; // Will only be 0x00 or 0xFF if (papersprite && ang < ANGLE_180) - flip ^= 0xFFFF; + flip ^= 0xFF; } else { From 1b22c3af19cd9460564a976e8520cc334353608d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 16:52:39 +0100 Subject: [PATCH 176/589] those should be boolean just for correctness! --- src/d_clisrv.c | 8 ++++---- src/d_clisrv.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0241f06e0..29dea3d19 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -173,11 +173,11 @@ static UINT16 resynch_delay[MAXNETNODES]; // delay time before the player can be static UINT32 resynch_status[MAXNETNODES]; // 0 bit means synched for that player, 1 means possibly desynched static UINT8 resynch_sent[MAXNETNODES][MAXPLAYERS]; // what synch packets have we attempted to send to the player static UINT8 resynch_inprogress[MAXNETNODES]; -static UINT8 resynch_local_inprogress = false; // WE are desynched and getting packets to fix it. -UINT8 hu_resynching = 0; +static boolean resynch_local_inprogress = false; // WE are desynched and getting packets to fix it. +boolean hu_resynching = false; #ifdef SATURNPAK -UINT8 hu_redownloadinggamestate = 0; +boolean hu_redownloadinggamestate = false; static UINT8 gamestate_resend_counter[MAXNETNODES]; #endif @@ -192,7 +192,7 @@ static UINT8 mynode; // my address pointofview server #ifdef SATURNPAK static boolean cl_redownloadinggamestate = false; -boolean is_client_saturn[MAXNETNODES]; +static boolean is_client_saturn[MAXNETNODES]; #endif #ifdef SATURNJOIN diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 430729bc2..396b2190c 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -654,9 +654,9 @@ void D_ResetTiccmds(void); tic_t GetLag(INT32 node); -extern UINT8 hu_resynching; +extern boolean hu_resynching; #ifdef SATURNPAK -extern UINT8 hu_redownloadinggamestate; +extern boolean hu_redownloadinggamestate; #endif extern boolean hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player From 2084cdc6d5679a779948d5002475b64866ec0d6b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 17:07:27 +0100 Subject: [PATCH 177/589] hw_md2: remove pointless float casts durs and tics are int32. and so is var2, anim_duration is uint16 but that still makes no sense lul --- src/hardware/hw_md2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 2fd33f65b..d9bf41645 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1336,8 +1336,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr) if (spr->mobj->frame & FF_ANIMATE) { // set duration and tics to be the correct values for FF_ANIMATE states - durs = (float)spr->mobj->state->var2; - tics = (float)spr->mobj->anim_duration; + durs = spr->mobj->state->var2; + tics = (INT32)spr->mobj->anim_duration; } //FIXME: this is not yet correct From 94026e43317cd66498022c7b2e687ffd557866c0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 17:44:56 +0100 Subject: [PATCH 178/589] makefile: comment out all the "Wno" flags we effectively fixed all of them, so this does not throw any warnings for me atleast in case we may screw up id rather have those warnings appear --- src/Makefile.d/versions.mk | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index c3989bb4f..cb13c286c 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,8 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference +WFLAGS:=-Wall -Wnull-dereference +#WFLAGS+=-Wno-trigraphs ifdef GCC152 WFLAGS+=-Wzero-as-null-pointer-constant endif @@ -31,7 +32,7 @@ ifndef RELAXWARNINGS WFLAGS+=-W #WFLAGS+=-Wno-sign-compare ifndef GCC295 - WFLAGS+=-Wno-div-by-zero +# WFLAGS+=-Wno-div-by-zero endif #WFLAGS+=-Wsystem-headers WFLAGS+=-Wfloat-equal @@ -62,7 +63,7 @@ endif endif WFLAGS+=-Wsign-compare ifdef GCC91 - WFLAGS+=-Wno-error=address-of-packed-member +# WFLAGS+=-Wno-error=address-of-packed-member endif ifdef GCC45 WFLAGS+=-Wlogical-op @@ -105,14 +106,14 @@ endif endif WFLAGS+=-Wformat-y2k ifdef GCC71 -WFLAGS+=-Wno-error=format-overflow=2 +#WFLAGS+=-Wno-error=format-overflow=2 endif WFLAGS+=-Wformat-security ifndef GCC29 #WFLAGS+=-Winit-self endif ifdef GCC46 -WFLAGS+=-Wno-suggest-attribute=noreturn +#WFLAGS+=-Wno-suggest-attribute=noreturn endif ifdef NOLDWARNING @@ -130,21 +131,21 @@ ifdef GCC44 #WFLAGS+=-Wno-error=array-bounds endif ifdef GCC46 - WFLAGS+=-Wno-error=suggest-attribute=noreturn +# WFLAGS+=-Wno-error=suggest-attribute=noreturn endif ifdef GCC54 - WFLAGS+=-Wno-logical-op -Wno-error=logical-op +# WFLAGS+=-Wno-logical-op -Wno-error=logical-op endif ifdef GCC61 - WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare +# WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare endif ifdef GCC71 WFLAGS+=-Wimplicit-fallthrough=4 endif ifdef GCC81 - WFLAGS+=-Wno-error=format-overflow - WFLAGS+=-Wno-format-overflow - WFLAGS+=-Wno-error=multistatement-macros +# WFLAGS+=-Wno-error=format-overflow +# WFLAGS+=-Wno-format-overflow +# WFLAGS+=-Wno-error=multistatement-macros endif ifneq (,$(filter $(CC) $(CXX),clang clang++)) @@ -183,6 +184,6 @@ endif # Lua ifdef GCC43 ifndef GCC44 -WFLAGS+=-Wno-logical-op +#WFLAGS+=-Wno-logical-op endif endif From 1e51365cadaa3d6075b00eb8214a59618224755e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 17:43:08 +0100 Subject: [PATCH 179/589] add comment about K_KartUpdatePosition --- src/k_kart.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/k_kart.c b/src/k_kart.c index 0efd3a48b..2aa0377b2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6175,6 +6175,13 @@ void K_KartUpdatePosition(player_t *player) } } + // the player should NOT be checked against themselves! lol + // otherwise prevcheck will effectively be halved + // sadly this stuff is exposed to lua and atleast one script uses those so we cant fix it + // oh well + //if (player == &players[i]) + //continue; + const boolean isprevcheckpointi = mo->health == players[i].starpostnum; const boolean isnextcheckpointi = mo->health == (players[i].starpostnum + 1); From fedccd25b997b5b79cc9f67ac9381c8a9a579238 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 18:04:45 +0100 Subject: [PATCH 180/589] hw_cache: use verstable for HWR_PrecacheLevelFlats flatchecks + convert to C replaces the unordered_set and doesent require c++ --- src/hardware/{hw_cache.cpp => hw_cache.c} | 100 ++++++++++++---------- src/hardware/hw_data.h | 2 +- 2 files changed, 58 insertions(+), 44 deletions(-) rename src/hardware/{hw_cache.cpp => hw_cache.c} (92%) diff --git a/src/hardware/hw_cache.cpp b/src/hardware/hw_cache.c similarity index 92% rename from src/hardware/hw_cache.cpp rename to src/hardware/hw_cache.c index 09f4f1a7b..f7cfceecb 100644 --- a/src/hardware/hw_cache.cpp +++ b/src/hardware/hw_cache.c @@ -15,8 +15,6 @@ #ifdef HWRENDER -#include - #include "hw_main.h" #include "hw_glob.h" #include "hw_gl.h" @@ -100,7 +98,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm position = 0; } - position = std::max(((position * scale_y) + (FRACUNIT/2)) >> FRACBITS, 0); + position = max(((position * scale_y) + (FRACUNIT/2)) >> FRACBITS, 0); if (position + count >= pblockheight) count = pblockheight - position; @@ -164,7 +162,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, fixed_t xfrac, xfracstep; fixed_t yfracstep, scale_y; const column_t *patchcol; - UINT8 *block = static_cast(mipmap->data); + UINT8 *block = (UINT8 *)(mipmap->data); INT32 bpp; INT32 blockmodulo; RGBA_t *palette; @@ -214,7 +212,7 @@ static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, fixed_t xfrac, xfracstep; fixed_t yfracstep, scale_y; const column_t *patchcol; - UINT8 *block = static_cast(mipmap->data); + UINT8 *block = (UINT8 *)(mipmap->data); INT32 bpp; INT32 blockmodulo; INT32 width, height; @@ -290,7 +288,7 @@ static UINT8 *MakeBlock(GLMipmap_t *glMipmap) INT32 blocksize = (glMipmap->width * glMipmap->height); bpp = format2bpp(glMipmap->format); - block = static_cast(Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(glMipmap->data))); + block = (UINT8 *)(Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(glMipmap->data))); switch (bpp) { @@ -327,7 +325,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe texture = textures[texnum]; gltex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY; - gltex->mipmap.format = static_cast(textureformat); + gltex->mipmap.format = (GLTextureFormat_t)(textureformat); // hack the Legacy skies.. if (UNLIKELY(memcmp(texture->name, "SKY", 3) == 0 && @@ -346,7 +344,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe colormap += COLORMAP_REMAPOFFSET; #endif - gltex->mipmap.colormap = static_cast(Z_Calloc(sizeof(*gltex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL)); + gltex->mipmap.colormap = (GLColormap_t *)(Z_Calloc(sizeof(*gltex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL)); gltex->mipmap.colormap->source = colormap; memcpy(gltex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8)); @@ -379,7 +377,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - pdata = static_cast(W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL)); + pdata = (UINT8 *)(W_CacheLumpNumPwad(patch->wad, patch->lump, PU_LEVEL)); realpatch = (softwarepatch_t *)pdata; HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); @@ -415,7 +413,7 @@ void HWR_MakePatch(const patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipma glMipmap->flags = 0; // setup the texture info - glMipmap->format = static_cast(patchformat); + glMipmap->format = (GLTextureFormat_t)(patchformat); glPatch->max_s = (float)patch->width / (float)glMipmap->width; glPatch->max_t = (float)patch->height / (float)glMipmap->height; @@ -457,7 +455,7 @@ static void HWR_FreeTextureData(patch_t *patch) if (!patch || !patch->hardware) return; - glPatch = static_cast(patch->hardware); + glPatch = (GLPatch_t *)(patch->hardware); if (vid.glstate == VID_GL_LIBRARY_LOADED) GL_DeleteTexture(glPatch->mipmap); @@ -473,7 +471,7 @@ void HWR_FreeTexture(patch_t *patch) if (patch->hardware) { - GLPatch_t *glPatch = static_cast(patch->hardware); + GLPatch_t *glPatch = (GLPatch_t *)(patch->hardware); HWR_FreeTextureColormaps(patch); @@ -499,7 +497,7 @@ static void HWR_FreeTextureColormaps(patch_t *patch) if (!patch) return; - pat = static_cast(patch->hardware); + pat = (GLPatch_t *)(patch->hardware); if (!pat) return; @@ -614,24 +612,20 @@ void HWR_FreeMapTextures(void) gl_numtextures = 0; } +#define NAME flatcheck +#define KEY_TY UINT32 +#define HASH_FN vt_hash_integer +#define CMPR_FN vt_cmpr_integer +#include "../verstable.h" + static void HWR_PrecacheLevelFlats(void) { // lookup for flats that may´ve been already loaded - // too lazy to make a hashtable or smth so unordered set will do :carbuncle: - std::unordered_set flatpresent; + flatcheck flatpresent; + flatcheck_init(&flatpresent); size_t i, j; INT32 k; - auto load_flat = [&](lumpnum_t lump, boolean noencoremap) - { - // flat already loaded? - if (flatpresent.count(lump) == 0) - { - HWR_GetFlat(lump, noencoremap); - flatpresent.insert(lump); - } - }; - // special case for encore #ifdef GLENCORE if (encoremap) @@ -649,14 +643,23 @@ static void HWR_PrecacheLevelFlats(void) const levelflat_t *levelflat = &levelflats[pic]; - load_flat(levelflat->lumpnum, R_NoEncore(sec, ceiling)); + if (flatcheck_is_end(flatcheck_get(&flatpresent, levelflat->lumpnum))) + { + HWR_GetFlat(levelflat->lumpnum, R_NoEncore(sec, ceiling)); + flatcheck_insert(&flatpresent, levelflat->lumpnum); + } if (levelflat->speed) // is it an animated flat ? { // start from 0, occasionally basenumlump != flat->lumpnum for (k = 0; k < levelflat->numpics; k++) { - load_flat(levelflat->baselumpnum + k, R_NoEncore(sec, ceiling)); + lumpnum_t lump = levelflat->baselumpnum + k; + if (flatcheck_is_end(flatcheck_get(&flatpresent, lump))) + { + HWR_GetFlat(lump, R_NoEncore(sec, ceiling)); + flatcheck_insert(&flatpresent, lump); + } } } } @@ -671,18 +674,29 @@ static void HWR_PrecacheLevelFlats(void) { const levelflat_t *levelflat = &levelflats[i]; - load_flat(levelflat->lumpnum, false); + if (flatcheck_is_end(flatcheck_get(&flatpresent, levelflat->lumpnum))) + { + HWR_GetFlat(levelflat->lumpnum, false); + flatcheck_insert(&flatpresent, levelflat->lumpnum); + } if (levelflat->speed) // is it an animated flat ? { // start from 0, occasionally basenumlump != flat->lumpnum for (k = 0; k < levelflat->numpics; k++) { - load_flat(levelflat->baselumpnum + k, false); + lumpnum_t lump = levelflat->baselumpnum + k; + if (flatcheck_is_end(flatcheck_get(&flatpresent, lump))) + { + HWR_GetFlat(lump, false); + flatcheck_insert(&flatpresent, lump); + } } } } } + + flatcheck_cleanup(&flatpresent); } static void HWR_PrecacheLevelTextures(void) @@ -692,7 +706,7 @@ static void HWR_PrecacheLevelTextures(void) size_t i, j, f; INT32 h; - texturepresent = static_cast(calloc(gl_numtextures, sizeof(*texturepresent))); + texturepresent = (char *)(calloc(gl_numtextures, sizeof(*texturepresent))); if (texturepresent == NULL) I_Error("%s: Out of memory looking up textures", "HWR_PrecacheLevel"); @@ -867,7 +881,7 @@ void HWR_LoadMapTextures(size_t pnumtextures) HWR_FreeMapTextures(); gl_numtextures = pnumtextures; - gl_textures = static_cast(calloc(gl_numtextures, sizeof(*gl_textures))); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore), see: GLMapTextureSet_t + gl_textures = (GLMapTextureSet_t *)(calloc(gl_numtextures, sizeof(*gl_textures))); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore), see: GLMapTextureSet_t if (gl_textures == NULL) I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures. Sad!"); @@ -964,7 +978,7 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum) W_ReadLump(flatlumpnum, Z_Malloc(size, PU_HWRCACHE, &glMipmap->data)); #ifdef GLENCORE - flat = static_cast(glMipmap->data); + flat = (UINT8 *)(glMipmap->data); for (steppy = 0; steppy < size; steppy++) { if (flat[steppy] == HWR_PATCHES_CHROMAKEY_COLORINDEX) @@ -1008,7 +1022,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) if (!noencoremap && encoremap) colormap += COLORMAP_REMAPOFFSET; #endif - glMipmap->colormap = static_cast(Z_Calloc(sizeof(*glMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL)); + glMipmap->colormap = (GLColormap_t *)(Z_Calloc(sizeof(*glMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL)); glMipmap->colormap->source = colormap; memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); } @@ -1032,7 +1046,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap) // --------------------+ static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *glMipmap) { - GLPatch_t *glPatch = static_cast(patch->hardware); + GLPatch_t *glPatch = (GLPatch_t *)(patch->hardware); if (!glMipmap->downloaded) { @@ -1053,7 +1067,7 @@ static void HWR_LoadPatchMipmap(patch_t *patch, GLMipmap_t *glMipmap) // ----------------------+ static void HWR_UpdatePatchMipmap(patch_t *patch, GLMipmap_t *glMipmap) { - GLPatch_t *glPatch = static_cast(patch->hardware); + GLPatch_t *glPatch = (GLPatch_t *)(patch->hardware); HWR_MakePatch(patch, glPatch, glMipmap, true); // If hardware does not have the texture, then call GL_SetTexture to upload it @@ -1089,7 +1103,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) if (!patch->hardware) Patch_CreateGL(patch); - glPatch = static_cast(patch->hardware); + glPatch = (GLPatch_t *)(patch->hardware); // Blatant hack for encore colormapping aside... if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET)) @@ -1125,12 +1139,12 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) // (it have a liste of mipmap) // this malloc is cleared in HWR_FreeColormapCache // (...) unfortunately z_malloc fragment alot the memory :(so malloc is better - newMipmap = static_cast(calloc(1, sizeof (*newMipmap))); + newMipmap = (GLMipmap_t *)(calloc(1, sizeof (*newMipmap))); if (newMipmap == NULL) I_Error("%s: Out of memory", "HWR_GetMappedPatch"); glMipmap->nextcolormap = newMipmap; - newMipmap->colormap = static_cast(Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL)); + newMipmap->colormap = (GLColormap_t *)(Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL)); newMipmap->colormap->source = colormap; memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); @@ -1153,7 +1167,7 @@ patch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum) { void *ptr = Z_Calloc(sizeof(patch_t), PU_PATCH, &lumpcache[lumpnum]); Patch_Create(NULL, 0, ptr); - Patch_AllocateHardwarePatch(static_cast(ptr)); + Patch_AllocateHardwarePatch((patch_t *)(ptr)); } return (patch_t *)(lumpcache[lumpnum]); @@ -1170,7 +1184,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 { INT32 i,j; fixed_t posx, posy, stepx, stepy; - UINT8 *block = static_cast(mipmap->data); // places the data directly into here + UINT8 *block = (UINT8 *)(mipmap->data); // places the data directly into here UINT8 *flat; UINT8 *dest, *src, texel; RGBA_t col; @@ -1326,7 +1340,7 @@ void HWR_SetPalette(RGBA_t *palette) static void HWR_SetPaletteLookup(RGBA_t *palette) { int r, g, b; - UINT8 *lut = static_cast(Z_Malloc( + UINT8 *lut = (UINT8 *)(Z_Malloc( HWR_PALETTE_LUT_SIZE*HWR_PALETTE_LUT_SIZE*HWR_PALETTE_LUT_SIZE*sizeof(UINT8), PU_STATIC, NULL)); #define STEP_SIZE (256/HWR_PALETTE_LUT_SIZE) @@ -1371,7 +1385,7 @@ void HWR_SetMapPalette(void) if (palsize < 768) // 256 * 3 I_Error("HWR_SetMapPalette: A programmer assumed palette lumps are at least 768 bytes long, but apparently this was a wrong assumption!\n"); - RGB_data = static_cast(W_CacheLumpNum(lumpnum, PU_CACHE)); + RGB_data = (UINT8 *)(W_CacheLumpNum(lumpnum, PU_CACHE)); // we got the RGB palette now, but we need it in RGBA format. for (i = 0; i < 256; i++) { @@ -1406,7 +1420,7 @@ static UINT32 HWR_CreateLightTable(UINT8 *lighttable) { UINT32 i, id; RGBA_t *palette = HWR_GetTexturePalette(); - RGBA_t *hw_lighttable = static_cast(Z_Malloc(256 * 32 * sizeof(RGBA_t), PU_STATIC, NULL)); + RGBA_t *hw_lighttable = (RGBA_t *)(Z_Malloc(256 * 32 * sizeof(RGBA_t), PU_STATIC, NULL)); // To make the palette index -> RGBA mapping easier for the shader, // the hardware lighttable is composed of RGBA colors instead of palette indices. diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index bb174b205..93ccfd4ac 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -54,7 +54,7 @@ struct GLMipmap_s UINT16 width, height; UINT32 downloaded; // The GPU has this texture. - struct GLMipmap_s *nextcolormap; + struct GLMipmap_s *nextcolormap; struct GLColormap_s *colormap; }; typedef struct GLMipmap_s GLMipmap_t; From 1ec29c1c94579ffb9fc263bd202531b48daad8f0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 21:27:02 +0100 Subject: [PATCH 181/589] better flags for ASAN and UBSAN compile with -O1 and -fno-omit-frame-pointer -fno-common for ASAN --- src/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index be4f995db..372594384 100644 --- a/src/Makefile +++ b/src/Makefile @@ -269,13 +269,13 @@ endif ifdef USEASAN # compile with asan -opts+=-fsanitize=address +opts+=-O1 -fsanitize=address -fno-omit-frame-pointer -fno-common libs+=-fsanitize=address endif ifdef USEUBSAN -# compile with asan -opts+=-fsanitize=undefined +# compile with ubsan +opts+=-O1 -fsanitize=undefined -fno-omit-frame-pointer libs+=-fsanitize=undefined endif From 3c70598aea71a51dd2abfe71f641e4e09ad11421 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 22:38:36 +0100 Subject: [PATCH 182/589] lumpnumcache: W_LumpExists should return true or false whoops was oversight by me prob doesent really matter due to wraparound but its still incorrect --- src/w_wad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index cfc25bbaa..5402e90a0 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1431,7 +1431,7 @@ UINT8 W_LumpExists(const char *name) // Check the lumpnumcache first. lumpnum_t cachenum = CheckLumpInCache(name); if (cachenum != LUMPERROR) - return cachenum; + return true; namelen = strlen(name); hash = W_HashLumpName(name); From db4cd73912b65e26ea2542b845ae6b2671db8455 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 26 Feb 2026 01:05:08 +0100 Subject: [PATCH 183/589] fix keepmusic resuming not resetting with "tunes" command this code sucks ass wtf was i cooking if this breaks again i will just wipe it lmao --- src/s_sound.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index f2ee1dc03..1e19c83fe 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1438,7 +1438,7 @@ void S_LoadMusicDefs(UINT16 wadnum) stoken = strtok(stoken, " "); if (stoken) { - if (! ReadMusicDefFields(wadnum, line, stoken, &def)) + if (!ReadMusicDefFields(wadnum, line, stoken, &def)) break; } @@ -1982,7 +1982,7 @@ static void S_SetKeepMusResume(void) { keepmusic.resume = 0; - if (fasticmp(music.name, mapmusic.name)) + if (fasticmp(music.name, keepmusic.name)) { keepmusic.resume = I_GetSongPosition(); } @@ -2078,9 +2078,12 @@ void S_InitMapMusic(void) S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, keepmusic.resume, 0, 500); } + keepmusic.resume = 0; return; } + keepmusic.resume = 0; + // Starting ambience should always be restarted // lug: but not when we keep the map music lol S_StopMusic(); @@ -2208,6 +2211,8 @@ static void Command_Tunes_f(void) mapmusic.position = position; mapmusic.resume = 0; + keepmusic.resume = 0; + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); if (argc > 3) From 6ff1cbf4b03c61ca2e4eac92834edec6347c7aee Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 26 Feb 2026 01:11:37 +0100 Subject: [PATCH 184/589] ok actually just remove keepmusic resume stuff well now it just broke with dynmusic this sucks, its probably fixable but the code was abysmal so shrug --- src/s_sound.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 1e19c83fe..546c183a8 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -116,9 +116,7 @@ consvar_t cv_skipintromusic = {"skipintromusic", "No", CV_SAVE, CV_YesNo, NULL, boolean keepmapmusic = false; // keep the current music on map restart boolean skipintromus = false; // skip the intro fanfare -static boolean resumekeepmusic = false; static music_t keepmusic; -static void S_SetKeepMusResume(void); #ifdef HAVE_OPENMPT openmpt_module *openmpt_mhandle = NULL; @@ -1848,8 +1846,6 @@ void S_StopMusic(void) mapmusic.resume = (cv_resume.value && fasticmp(music.name, mapmusic.name)) ? I_GetSongPosition() : 0; - S_SetKeepMusResume(); - if (I_SongPaused()) I_ResumeSong(); @@ -1976,17 +1972,6 @@ void S_ResetKeepAndSpecialMus(void) keepmapmusic = skipintromus = false; } -// saves the current song position everytime a song stops -// so we can resume it in some cases -static void S_SetKeepMusResume(void) -{ - keepmusic.resume = 0; - - if (fasticmp(music.name, keepmusic.name)) - { - keepmusic.resume = I_GetSongPosition(); - } -} // determine if we should keep the music on a map restart // this gets called BEFORE the level gets loaded in G_DoLoadLevel @@ -1995,7 +1980,7 @@ void S_KeepMusic(void) static INT16 oldmap = -1; static boolean oldencore = false; - keepmapmusic = resumekeepmusic = false; + keepmapmusic = false; if (!cv_keepmusic.value) { @@ -2009,9 +1994,7 @@ void S_KeepMusic(void) if (oldmap == gamemap && oldencore == encoremode) { - const boolean musicchanged = S_CheckMusicException(); - resumekeepmusic = (musicchanged && keepmusic.resume); - keepmapmusic = (!musicchanged || resumekeepmusic); + keepmapmusic = (S_CheckMusicException() == false); } oldencore = encoremode; @@ -2072,18 +2055,9 @@ void S_InitMapMusic(void) if (keepmapmusic) { - // this is kinda silly, but we can use it to fade back into the map song at the saved point, should the current music be different from the map music - if (resumekeepmusic) - { - S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, keepmusic.resume, 0, 500); - } - - keepmusic.resume = 0; return; } - keepmusic.resume = 0; - // Starting ambience should always be restarted // lug: but not when we keep the map music lol S_StopMusic(); @@ -2211,8 +2185,6 @@ static void Command_Tunes_f(void) mapmusic.position = position; mapmusic.resume = 0; - keepmusic.resume = 0; - S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); if (argc > 3) From 5577ba4c7ac98cb11339f4b416801ac100430c82 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Mar 2026 00:03:19 +0100 Subject: [PATCH 185/589] Autoload: dont add wads that contain maps --- src/d_main.c | 11 ++++++++++- src/w_wad.c | 13 ++++++++++++- src/w_wad.h | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 2832d6c6a..1a03b1972 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1124,9 +1124,18 @@ static void D_FindAddonsToAutoload(void) if (newline) *newline = '\0'; + // ok so theres still issues with players adding stuff to autoload by accident + // sometimes this stuff contains maps + // you can probably imagine how that goes in a netgame.... + if (W_CheckAutoLoadContainsMap(wadsToAutoload)) + { + CONS_Printf("Autoload: file %s contains map data! skipping...", wadsToAutoload); + continue; + } + if (!postload && W_CheckPostLoadList(wadsToAutoload)) { - CONS_Printf("forcing postload for file %s\n", wadsToAutoload); + CONS_Printf("Autoload: forcing postload for file %s\n", wadsToAutoload); postload = true; } diff --git a/src/w_wad.c b/src/w_wad.c index 8cc3fd214..4a1c1247a 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2576,6 +2576,18 @@ static int W_CheckFileContains(const char *filename, lumpchecklist_t *checklist) return contains; } +int W_CheckAutoLoadContainsMap(const char *filename) +{ + // for now this checks for map marker + static lumpchecklist_t autoloadblacklist[] = + { + {"MAP", 3}, + {NULL, 0}, + }; + + return W_CheckFileContains(filename, autoloadblacklist); +} + int W_CheckPostLoadList(const char *filename) { static lumpchecklist_t postloadlist[] = @@ -2588,7 +2600,6 @@ int W_CheckPostLoadList(const char *filename) {"SOC_", 4}, {"MAINCFG", 7}, {"OBJCTCFG", 8}, - {"MAP", 3}, {NULL, 0}, }; diff --git a/src/w_wad.h b/src/w_wad.h index 6240c31f3..98c57173e 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -243,6 +243,7 @@ void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5); int W_VerifyNMUSlumps(const char *filename, FILE *handle, boolean exit_on_error); +int W_CheckAutoLoadContainsMap(const char *filename); int W_CheckPostLoadList(const char *filename); #ifdef __cplusplus From 1cf04514b3b67685789182c83b95907be80a2154 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 1 Mar 2026 02:31:11 +0300 Subject: [PATCH 186/589] Fix W_MakeFileMD5 printing incorrect time --- src/w_wad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 4a1c1247a..3c37bf185 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -339,7 +339,7 @@ static inline INT32 W_MakeFileMD5(const char *filename, void *resblock) if ((fhandle = fopen(filename, "rb")) != NULL) { - tic_t t = I_GetTime(); + precise_t t = I_GetPreciseTime(); CONS_Debug(DBG_SETUP, "Making MD5 for %s\n",filename); @@ -350,7 +350,7 @@ static inline INT32 W_MakeFileMD5(const char *filename, void *resblock) } CONS_Debug(DBG_SETUP, "MD5 calc for %s took %f seconds\n", - filename, (float)(I_GetTime() - t)/NEWTICRATE); + filename, (float)(I_GetPreciseTime() - t)/I_GetPrecisePrecision()); fclose(fhandle); return 0; From 5ca3ab5966f2d221db802d0ed1c0d99d6a1e100a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Mar 2026 00:57:44 +0100 Subject: [PATCH 187/589] Autoload: fix incorrectly incrementing wad count those should only be incremented if we actually add something to the filearray and not instantly execute or error out --- src/d_main.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 1a03b1972..85ef4d226 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -130,8 +130,8 @@ static size_t startuppwadcount = 0; // autoloading static char *autoloadwadfiles[MAX_WADFILES]; static char *autoloadwadfilespost[MAX_WADFILES]; -static size_t autoloadcount = 0; -static size_t postloadcount = 0; +static size_t autoloadwadcount = 0; +static size_t postloadwadcount = 0; // boolean devparm = false; // started game with -devparm @@ -1037,7 +1037,7 @@ static INT32 D_DetectFileType(const char* filename) } // autoload that shit -static void D_AutoloadFile(const char *file, char **filearray, size_t index) +static void D_AutoloadFile(const char *file, char **filearray, size_t *index) { char *newfile; INT32 fileType = D_DetectFileType(file); @@ -1052,10 +1052,11 @@ static void D_AutoloadFile(const char *file, char **filearray, size_t index) { newfile = malloc(strlen(file) + 1); if (!newfile) - I_Error("No more free memory to AutoloadFile %s",file); + I_Error("D_AutoloadFile: No more free memory to autoload file %s", file); strcpy(newfile, file); - filearray[index] = newfile; + filearray[*index] = newfile; + (*index)++; } else { @@ -1098,7 +1099,7 @@ static void D_FindAddonsToAutoload(void) // If the file is found, run our shit if (!autoloadconfigfile) // nope outta here { - autoloadcount = postloadcount = 0; // so D_AddAutoloadFiles can skip everything since nothings there to autoload + autoloadwadcount = postloadwadcount = 0; // so D_AddAutoloadFiles can skip everything since nothings there to autoload return; } @@ -1142,18 +1143,16 @@ static void D_FindAddonsToAutoload(void) // LOAD IT if (!postload) { - D_AutoloadFile(wadsToAutoload, autoloadwadfiles, autoloadcount); - autoloadcount++; + D_AutoloadFile(wadsToAutoload, autoloadwadfiles, &autoloadwadcount); } else { - D_AutoloadFile(wadsToAutoload, autoloadwadfilespost, postloadcount); - postloadcount++; + D_AutoloadFile(wadsToAutoload, autoloadwadfilespost, &postloadwadcount); } } - autoloadwadfiles[autoloadcount] = NULL; - autoloadwadfilespost[postloadcount] = NULL; + autoloadwadfiles[autoloadwadcount] = NULL; + autoloadwadfilespost[postloadwadcount] = NULL; // we dont want memory leaks around here do we? fclose(autoloadconfigfile); @@ -1162,7 +1161,7 @@ static void D_FindAddonsToAutoload(void) static void D_AddAutoloadFiles(void) { // nothing to autoload - if (autoloadcount == 0) + if (autoloadwadcount == 0) return; CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); @@ -1170,15 +1169,15 @@ static void D_AddAutoloadFiles(void) if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0) CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); - D_CleanFile(autoloadwadfiles, autoloadcount); + D_CleanFile(autoloadwadfiles, autoloadwadcount); - autoloadcount = 0; + autoloadwadcount = 0; } void D_AddPostloadFiles(void) { // nothing to postload - if (postloadcount == 0 || !netgame) + if (postloadwadcount == 0 || !netgame) return; CONS_Printf("D_AddPostloadFiles(): Loading postloaded addons...\n"); @@ -1186,9 +1185,9 @@ void D_AddPostloadFiles(void) if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0) CONS_Printf("D_AddPostloadFiles(): Are you sure you put in valid files or what?\n"); - D_CleanFile(autoloadwadfilespost, postloadcount); + D_CleanFile(autoloadwadfilespost, postloadwadcount); - postloadcount = 0; + postloadwadcount = 0; } // ========================================================================== From e8c7cc6a9b57ffba849ff6ccaa3935ea2633baa0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Mar 2026 00:59:51 +0100 Subject: [PATCH 188/589] D_AutoloadFile: add overflow safeguard --- src/d_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index 85ef4d226..c312e3f59 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1042,6 +1042,12 @@ static void D_AutoloadFile(const char *file, char **filearray, size_t *index) char *newfile; INT32 fileType = D_DetectFileType(file); + if (*index >= MAX_WADFILES) + { + CONS_Printf("D_AutoloadFile: Failed to add file %s! Too many autoloaded files\n", file); + return; + } + if (!fileType) { CONS_Printf("D_AutoloadFile: File %s is unknown or invalid\n", file); From 1a9fa94cbd44d129af33b395bfe09acc3785f9fb Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Mar 2026 01:01:20 +0100 Subject: [PATCH 189/589] Autoload: dont attempt to load directories lol --- src/d_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index c312e3f59..0ecce2047 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1054,6 +1054,12 @@ static void D_AutoloadFile(const char *file, char **filearray, size_t *index) return; } + if (fileType == 1) + { + CONS_Printf("D_AutoloadFile: File %s is a directory\n", file); + return; + } + if (fileType <= 6) { newfile = malloc(strlen(file) + 1); From 397fb071e5eb9edfc4ca10b92770ae48d95d3c4b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Mar 2026 21:24:09 +0100 Subject: [PATCH 190/589] fix compiling with valgrind support --- src/z_zone.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/z_zone.cpp b/src/z_zone.cpp index 9e5b4f41e..f25f99e43 100644 --- a/src/z_zone.cpp +++ b/src/z_zone.cpp @@ -523,11 +523,19 @@ void Z_CheckHeap(INT32 tag) #ifdef VALGRIND_MEMPOOL_EXISTS if (!VALGRIND_MEMPOOL_EXISTS(block)) { - I_Error("Z_CheckHeap %d: block %u" + I_Error("Z_CheckHeap :" +#ifdef ZDEBUG + " %s %d" +#endif + " block %u" #ifdef ZDEBUG " (owned by %s:%d)" #endif - " should not exist", i, blocknumon + " should not exist" +#ifdef ZDEBUG + , file, line +#endif + , blocknumon #ifdef ZDEBUG , block->ownerfile, block->ownerline #endif From 82471339664b62115eb15cd9f1d44e7144acb4d5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Mar 2026 21:32:25 +0100 Subject: [PATCH 191/589] w_wad: use strnlen to check lump length for map marker lump name may not be null terminated here, so strlen may read out of bounds garbo using strnlen ensures we read max 8 characters which is the name buffer size --- src/w_wad.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index 3c37bf185..ef9bd471e 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2660,11 +2660,12 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) { if (vsizecache[realentry] == 0) continue; + vlumps[i].size = vsizecache[realentry]; const char *name = (fileinfo + realentry)->name; - if (strlen(name) == 5 && memcmp(name, "MAP", 3) == 0) + if (strnlen(name, 8) == 5 && memcmp(name, "MAP", 3) == 0) { numlumps--; // We skip map marker, so 1 of entries becomes empty continue; // This will skip i++ so we will write to same entry From f2b46fd1484e573babc3ab0f6e6da1843c942408 Mon Sep 17 00:00:00 2001 From: "X.organic" Date: Tue, 6 Apr 2021 01:01:33 +0200 Subject: [PATCH 192/589] Fix myhashfgets-related buffer overflows in deh_soc.c --- src/dehacked.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index a3513fbbe..6b09f0d5b 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -115,20 +115,25 @@ char *myfgets(char *buf, size_t bufsize, MYFILE *f) size_t i = 0; if (myfeof(f)) return NULL; + // we need one byte for a null terminated string bufsize--; + while (i < bufsize && !myfeof(f)) { char c = *f->curpos++; + if (c == '^') buf[i++] = myfget_color(f); else if (c == '\\') buf[i++] = myfget_hex(f); else if (c != '\r') buf[i++] = c; + if (c == '\n') break; } + buf[i] = '\0'; dbg_line++; @@ -138,25 +143,31 @@ char *myfgets(char *buf, size_t bufsize, MYFILE *f) static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f) { size_t i = 0; + if (myfeof(f)) return NULL; + // we need one byte for a null terminated string bufsize--; + while (i < bufsize && !myfeof(f)) { char c = *f->curpos++; + if (c == '^') buf[i++] = myfget_color(f); else if (c == '\\') buf[i++] = myfget_hex(f); else if (c != '\r') buf[i++] = c; + if (c == '\n') // Ensure debug line is right... dbg_line++; + if (c == '#') break; } - i++; + buf[i] = '\0'; return buf; @@ -315,7 +326,10 @@ static void readPlayer(MYFILE *f, INT32 num) goto done; PlayerMenu[num].status = IT_CALL; - for (i = 0; i < MAXLINELEN-3; i++) + // A friendly neighborhood alias for brevity's sake + const size_t note_size = sizeof(description[num].notes); + + for (i = 0; i < (INT32)(MAXLINELEN-note_size-3); i++) { if (s[i] == '=') { @@ -323,10 +337,12 @@ static void readPlayer(MYFILE *f, INT32 num) break; } } + if (playertext) { - strcpy(description[num].notes, playertext); - strcat(description[num].notes, myhashfgets(playertext, sizeof (description[num].notes), f)); + strlcpy(description[num].notes, playertext, note_size); + strlcat(description[num].notes, + myhashfgets(playertext, note_size, f), note_size); } else strcpy(description[num].notes, ""); @@ -335,7 +351,7 @@ static void readPlayer(MYFILE *f, INT32 num) // It works down here, though. { INT32 numline = 0; - for (i = 0; (size_t)i < sizeof(description[num].notes)-1; i++) + for (i = 0; (size_t)i < note_size-1; i++) { if (numline < 20 && description[num].notes[i] == '\n') numline++; @@ -344,6 +360,7 @@ static void readPlayer(MYFILE *f, INT32 num) break; } } + description[num].notes[strlen(description[num].notes)-1] = '\0'; description[num].notes[i] = '\0'; continue; From 07fc0eb03abd21ef36f96d345baf83f773ae7192 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Mar 2026 00:34:58 +0100 Subject: [PATCH 193/589] v_video: fix cv_palettenum bounds check mhhm yeah --- src/v_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v_video.c b/src/v_video.c index 9898e9c29..fcbeded5f 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -555,7 +555,7 @@ void V_SetPalette(INT32 palettenum) { palettenum = cv_palettenum.value; - if (palettenum * 256U > currentPaletteSize - 256) + if (palettenum * 256U > (currentPaletteSize - 256) / 3) { CONS_Alert(CONS_WARNING, "cv_palettenum %d out of range\n", palettenum); palettenum = 0; From efe873218811aea5d718a96dc63726c96aeb4347 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Mar 2026 00:43:33 +0100 Subject: [PATCH 194/589] fix flashpals throwing random garbage into the renderer in some cases iirc, if the provided palette currently in use did not provide subpalettes, this will read past the bounds of allocated memory, which aint good lol i just dumped the white flashpal and threw it into there since idk if -file or autoload gets called before the palette gets initialised, which would carry a risk of copying more garbage, hence this big ass array --- src/v_video.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 2 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index fcbeded5f..2aa680153 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -92,6 +92,97 @@ consvar_t cv_menucaps = {"menucaps", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NUL RGBA_t *pLocalPalette = NULL; RGBA_t *pGammaCorrectedPalette = NULL; +// huge ass array les gooooooo! +// this is basically the white flashpal byte for byte from our main palette lmao +static RGBA_t pFallbackFlashPal[] = { + {.s={253, 253, 253, 255}}, {.s={251, 251, 251, 255}}, {.s={249, 249, 249, 255}}, + {.s={247, 247, 247, 255}}, {.s={245, 245, 245, 255}}, {.s={243, 243, 243, 255}}, + {.s={241, 241, 241, 255}}, {.s={239, 239, 239, 255}}, {.s={237, 237, 237, 255}}, + {.s={235, 235, 235, 255}}, {.s={233, 233, 233, 255}}, {.s={231, 231, 231, 255}}, + {.s={229, 229, 229, 255}}, {.s={227, 227, 227, 255}}, {.s={225, 225, 225, 255}}, + {.s={223, 223, 223, 255}}, {.s={221, 221, 221, 255}}, {.s={219, 219, 219, 255}}, + {.s={217, 217, 217, 255}}, {.s={215, 215, 215, 255}}, {.s={213, 213, 213, 255}}, + {.s={211, 211, 211, 255}}, {.s={209, 209, 209, 255}}, {.s={207, 207, 207, 255}}, + {.s={205, 205, 205, 255}}, {.s={203, 203, 203, 255}}, {.s={201, 201, 201, 255}}, + {.s={199, 199, 199, 255}}, {.s={197, 197, 197, 255}}, {.s={195, 195, 195, 255}}, + {.s={193, 193, 193, 255}}, {.s={192, 192, 192, 255}}, {.s={239, 233, 227, 255}}, + {.s={237, 231, 225, 255}}, {.s={235, 229, 223, 255}}, {.s={233, 227, 221, 255}}, + {.s={231, 225, 219, 255}}, {.s={229, 223, 217, 255}}, {.s={227, 221, 215, 255}}, + {.s={225, 220, 214, 255}}, {.s={223, 218, 212, 255}}, {.s={220, 216, 210, 255}}, + {.s={218, 214, 208, 255}}, {.s={216, 212, 206, 255}}, {.s={214, 210, 204, 255}}, + {.s={212, 208, 202, 255}}, {.s={210, 206, 200, 255}}, {.s={208, 204, 198, 255}}, + {.s={239, 222, 210, 255}}, {.s={236, 220, 209, 255}}, {.s={234, 219, 208, 255}}, + {.s={232, 218, 207, 255}}, {.s={230, 216, 206, 255}}, {.s={227, 215, 205, 255}}, + {.s={225, 213, 204, 255}}, {.s={223, 212, 203, 255}}, {.s={221, 211, 202, 255}}, + {.s={218, 209, 201, 255}}, {.s={215, 208, 200, 255}}, {.s={212, 207, 199, 255}}, + {.s={210, 205, 198, 255}}, {.s={207, 203, 197, 255}}, {.s={204, 202, 196, 255}}, + {.s={202, 200, 195, 255}}, {.s={255, 250, 247, 255}}, {.s={255, 248, 244, 255}}, + {.s={255, 246, 241, 255}}, {.s={255, 244, 238, 255}}, {.s={255, 243, 236, 255}}, + {.s={255, 241, 233, 255}}, {.s={255, 239, 230, 255}}, {.s={255, 238, 228, 255}}, + {.s={255, 236, 224, 255}}, {.s={253, 234, 222, 255}}, {.s={251, 232, 220, 255}}, + {.s={249, 230, 218, 255}}, {.s={247, 228, 216, 255}}, {.s={245, 226, 214, 255}}, + {.s={243, 224, 212, 255}}, {.s={242, 223, 211, 255}}, {.s={255, 250, 246, 255}}, + {.s={255, 246, 237, 255}}, {.s={255, 242, 229, 255}}, {.s={255, 237, 220, 255}}, + {.s={255, 233, 213, 255}}, {.s={255, 229, 205, 255}}, {.s={255, 225, 198, 255}}, + {.s={255, 220, 192, 255}}, {.s={252, 218, 192, 255}}, {.s={248, 216, 192, 255}}, + {.s={245, 214, 192, 255}}, {.s={242, 213, 192, 255}}, {.s={238, 211, 192, 255}}, + {.s={235, 209, 192, 255}}, {.s={232, 207, 192, 255}}, {.s={229, 205, 192, 255}}, + {.s={255, 255, 251, 255}}, {.s={255, 255, 243, 255}}, {.s={255, 255, 235, 255}}, + {.s={255, 255, 227, 255}}, {.s={255, 255, 219, 255}}, {.s={255, 255, 211, 255}}, + {.s={255, 255, 203, 255}}, {.s={255, 255, 195, 255}}, {.s={255, 255, 192, 255}}, + {.s={243, 243, 192, 255}}, {.s={235, 235, 192, 255}}, {.s={227, 227, 192, 255}}, + {.s={219, 219, 192, 255}}, {.s={211, 211, 192, 255}}, {.s={203, 203, 192, 255}}, + {.s={195, 195, 192, 255}}, {.s={255, 255, 220, 255}}, {.s={250, 246, 213, 255}}, + {.s={245, 238, 208, 255}}, {.s={240, 230, 203, 255}}, {.s={235, 222, 199, 255}}, + {.s={230, 214, 196, 255}}, {.s={225, 208, 193, 255}}, {.s={220, 202, 192, 255}}, + {.s={255, 255, 255, 255}}, {.s={255, 247, 247, 255}}, {.s={255, 239, 239, 255}}, + {.s={255, 231, 231, 255}}, {.s={255, 223, 223, 255}}, {.s={255, 215, 215, 255}}, + {.s={255, 207, 207, 255}}, {.s={255, 199, 199, 255}}, {.s={255, 192, 192, 255}}, + {.s={251, 192, 192, 255}}, {.s={247, 192, 192, 255}}, {.s={243, 192, 192, 255}}, + {.s={239, 192, 192, 255}}, {.s={235, 192, 192, 255}}, {.s={231, 192, 192, 255}}, + {.s={227, 192, 192, 255}}, {.s={223, 192, 192, 255}}, {.s={219, 192, 192, 255}}, + {.s={215, 192, 192, 255}}, {.s={211, 192, 192, 255}}, {.s={207, 192, 192, 255}}, + {.s={203, 192, 192, 255}}, {.s={199, 192, 192, 255}}, {.s={195, 192, 192, 255}}, + {.s={255, 237, 237, 255}}, {.s={252, 232, 232, 255}}, {.s={249, 227, 227, 255}}, + {.s={246, 222, 222, 255}}, {.s={242, 218, 218, 255}}, {.s={239, 214, 214, 255}}, + {.s={236, 211, 211, 255}}, {.s={233, 207, 207, 255}}, {.s={227, 203, 192, 255}}, + {.s={225, 201, 192, 255}}, {.s={223, 199, 192, 255}}, {.s={220, 198, 192, 255}}, + {.s={218, 196, 192, 255}}, {.s={216, 194, 192, 255}}, {.s={214, 193, 192, 255}}, + {.s={213, 192, 192, 255}}, {.s={221, 255, 211, 255}}, {.s={219, 251, 210, 255}}, + {.s={217, 247, 209, 255}}, {.s={215, 243, 208, 255}}, {.s={214, 239, 206, 255}}, + {.s={212, 235, 205, 255}}, {.s={210, 231, 204, 255}}, {.s={208, 227, 203, 255}}, + {.s={206, 223, 201, 255}}, {.s={205, 219, 200, 255}}, {.s={203, 215, 199, 255}}, + {.s={201, 211, 198, 255}}, {.s={199, 207, 196, 255}}, {.s={197, 203, 195, 255}}, + {.s={195, 199, 194, 255}}, {.s={193, 195, 192, 255}}, {.s={246, 255, 233, 255}}, + {.s={241, 248, 228, 255}}, {.s={234, 241, 223, 255}}, {.s={228, 234, 218, 255}}, + {.s={222, 228, 213, 255}}, {.s={216, 221, 208, 255}}, {.s={210, 214, 203, 255}}, + {.s={204, 207, 199, 255}}, {.s={192, 255, 192, 255}}, {.s={192, 247, 192, 255}}, + {.s={192, 239, 192, 255}}, {.s={192, 231, 192, 255}}, {.s={192, 223, 192, 255}}, + {.s={192, 215, 192, 255}}, {.s={192, 207, 192, 255}}, {.s={192, 199, 192, 255}}, + {.s={255, 219, 255, 255}}, {.s={255, 192, 255, 255}}, {.s={247, 192, 247, 255}}, + {.s={239, 192, 239, 255}}, {.s={231, 192, 231, 255}}, {.s={223, 192, 223, 255}}, + {.s={215, 192, 215, 255}}, {.s={207, 192, 207, 255}}, {.s={249, 249, 252, 255}}, + {.s={240, 240, 247, 255}}, {.s={230, 230, 242, 255}}, {.s={221, 221, 238, 255}}, + {.s={212, 212, 233, 255}}, {.s={208, 208, 224, 255}}, {.s={203, 203, 214, 255}}, + {.s={198, 198, 204, 255}}, {.s={244, 251, 255, 255}}, {.s={239, 250, 255, 255}}, + {.s={234, 248, 255, 255}}, {.s={228, 246, 255, 255}}, {.s={223, 244, 255, 255}}, + {.s={218, 243, 255, 255}}, {.s={213, 241, 255, 255}}, {.s={207, 239, 255, 255}}, + {.s={205, 230, 247, 255}}, {.s={203, 227, 239, 255}}, {.s={201, 221, 231, 255}}, + {.s={199, 215, 223, 255}}, {.s={192, 239, 239, 255}}, {.s={192, 223, 223, 255}}, + {.s={192, 215, 215, 255}}, {.s={192, 207, 207, 255}}, {.s={249, 249, 255, 255}}, + {.s={240, 240, 255, 255}}, {.s={234, 234, 255, 255}}, {.s={226, 226, 255, 255}}, + {.s={220, 220, 255, 255}}, {.s={212, 212, 255, 255}}, {.s={204, 204, 255, 255}}, + {.s={197, 197, 255, 255}}, {.s={192, 192, 255, 255}}, {.s={192, 192, 249, 255}}, + {.s={192, 192, 242, 255}}, {.s={192, 192, 236, 255}}, {.s={192, 192, 230, 255}}, + {.s={192, 192, 224, 255}}, {.s={192, 192, 218, 255}}, {.s={192, 192, 212, 255}}, + {.s={192, 192, 211, 255}}, {.s={192, 192, 207, 255}}, {.s={192, 192, 205, 255}}, + {.s={192, 192, 201, 255}}, {.s={192, 192, 199, 255}}, {.s={192, 192, 195, 255}}, + {.s={192, 192, 193, 255}}, {.s={192, 255, 255, 255}}, {.s={243, 223, 243, 255}}, + {.s={237, 219, 237, 255}}, {.s={231, 215, 231, 255}}, {.s={225, 211, 225, 255}}, + {.s={219, 207, 219, 255}}, {.s={213, 203, 213, 255}}, {.s={207, 199, 207, 255}}, + {.s={201, 195, 201, 255}} +}; + static size_t currentPaletteSize; /* @@ -543,6 +634,7 @@ void V_ReloadPalette(void) // -------------+ void V_SetPalette(INT32 palettenum) { + RGBA_t *pal = NULL; if (!pLocalPalette) V_ReloadPalette(); @@ -563,15 +655,31 @@ void V_SetPalette(INT32 palettenum) } } + // if the palettenum goes beyond our current palette, then just fallback to the white flash pal + // our srb2 palette mostly just contains that as subpalettes, so everything uses this + // and makes it a good fallback case + // otherwise we will throw random garbage to the renderer which calls memcpy on it + // which is not really a good thing lol + // we probably could just memcpy from localpalette, but i dont trust -file nor autoload so + if (palettenum * 256U > (currentPaletteSize - 256) / 3) + { + CONS_Debug(DBG_RENDER, "palettenum %d out of range\n", palettenum); + pal = pFallbackFlashPal; + } + else + { + pal = &pLocalPalette[palettenum*256]; + } + #ifdef HWRENDER if (rendermode == render_opengl) - HWR_SetPalette(&pLocalPalette[palettenum*256]); + HWR_SetPalette(pal); #if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) else #endif #endif if (rendermode != render_none) - I_SetPalette(&pLocalPalette[palettenum*256]); + I_SetPalette(pal); } void V_SetPaletteLump(const char *pal) From 16cf4ede89f511967808b5e8737a9529ba891aa8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Mar 2026 08:31:27 +0100 Subject: [PATCH 195/589] v_video: generate missing flashpals instead not sure if this is more sane than the huge ass array from before but atleast this is more accurate and can basically generate flashpals from any palette while also still working with all the colour and gamma adjustments prob needs some cleanup idk this is all rather messy lol --- src/hardware/hw_main.cpp | 4 +- src/hardware/hw_main.h | 6 - src/m_menudefs.c | 2 - src/st_stuff.c | 2 +- src/v_paldeltas.h | 525 +++++++++++++++++++++++++++++++++++++++ src/v_video.c | 196 +++++++-------- 6 files changed, 614 insertions(+), 121 deletions(-) create mode 100644 src/v_paldeltas.h diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 15434ec20..e6ce072cf 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -242,7 +242,6 @@ consvar_t cv_glportals = {"gr_portals", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, consvar_t cv_glpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_glpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gltexturedepth = {"gr_texturedepth", "32 bits", CV_CALL|CV_SAVE, gltexdepth_cons_t, CV_gltextureformat_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -5913,7 +5912,6 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_glpaletterendering); CV_RegisterVar(&cv_glpalettedepth); - CV_RegisterVar(&cv_glflashpal); } // -------------------------------------------------------------------------- @@ -6070,7 +6068,7 @@ static void HWR_DoPostProcessor(void) { // Armageddon Blast Flash! // Could this even be considered postprocessor? - if (!HWR_PalRenderFlashpal()) + if (!HWR_ShouldUsePaletteRendering()) { const player_t *player = &players[displayplayers[viewssnum]]; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 8b5284acb..8a501f727 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -208,7 +208,6 @@ extern consvar_t cv_glportals; extern consvar_t cv_glpaletterendering; extern consvar_t cv_glpalettedepth; -extern consvar_t cv_glflashpal; FUNCINLINE static ATTRINLINE boolean HWR_UseShader(void) { @@ -220,11 +219,6 @@ FUNCINLINE static ATTRINLINE boolean HWR_ShouldUsePaletteRendering(void) return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader()); } -FUNCINLINE static ATTRINLINE boolean HWR_PalRenderFlashpal(void) -{ - return (cv_glflashpal.value && HWR_ShouldUsePaletteRendering()); -} - // Returns a pointer to the palette which should be used for caching textures. FUNCINLINE static ATTRINLINE RGBA_t *HWR_GetTexturePalette(void) { diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 00b927efd..aa3f186c8 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1023,8 +1023,6 @@ static menuitem_t OP_OpenGLOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Fallback Player 3D Model", &cv_glfallbackplayermodel, 20}, {IT_STRING | IT_CVAR, NULL, "Shaders", &cv_glshaders, 25}, {IT_STRING | IT_CVAR, NULL, "Palette Rendering", &cv_glpaletterendering, 30}, - {IT_STRING | IT_CVAR, NULL, "Palette Rendering Flashpals",&cv_glflashpal, 35}, - //{IT_STRING | IT_CVAR, NULL, "Min Shader Brightness", &cv_glsecbright, 40}, {IT_STRING | IT_CVAR, NULL, "Texture Quality", &cv_gltexturedepth, 45}, {IT_STRING | IT_CVAR, NULL, "Texture Filter", &cv_glfiltermode, 50}, diff --git a/src/st_stuff.c b/src/st_stuff.c index 6dc7111f3..64bc4dc00 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -180,7 +180,7 @@ static void ST_doPaletteStuff(void) INT32 palette = 0; #ifdef HWRENDER - if (rendermode == render_opengl && !HWR_PalRenderFlashpal()) + if (rendermode == render_opengl && !HWR_ShouldUsePaletteRendering()) return; #endif diff --git a/src/v_paldeltas.h b/src/v_paldeltas.h new file mode 100644 index 000000000..30fc86dfc --- /dev/null +++ b/src/v_paldeltas.h @@ -0,0 +1,525 @@ +#ifndef H_PALDELTA +#define H_PALDELTA + +// those are the differences in palette indices between the main srb2 playpal and its white and nuke subpalettes +// this is probably not the best way of doing any of this, but it works lol + +static const INT16 pPaletteDeltaFlash[256][3] = { + { 6, 6, 6}, + { 12, 12, 12}, + { 18, 18, 18}, + { 24, 24, 24}, + { 30, 30, 30}, + { 36, 36, 36}, + { 42, 42, 42}, + { 48, 48, 48}, + { 54, 54, 54}, + { 60, 60, 60}, + { 66, 66, 66}, + { 72, 72, 72}, + { 78, 78, 78}, + { 84, 84, 84}, + { 90, 90, 90}, + { 95, 95, 95}, + { 101, 101, 101}, + { 107, 107, 107}, + { 113, 113, 113}, + { 119, 119, 119}, + { 125, 125, 125}, + { 131, 131, 131}, + { 137, 137, 137}, + { 143, 143, 143}, + { 149, 149, 149}, + { 155, 155, 155}, + { 161, 161, 161}, + { 167, 167, 167}, + { 173, 173, 173}, + { 179, 179, 179}, + { 185, 185, 185}, + { 191, 191, 191}, + { 48, 66, 84}, + { 54, 71, 89}, + { 60, 77, 95}, + { 66, 83, 100}, + { 72, 88, 105}, + { 79, 94, 111}, + { 85, 99, 117}, + { 91, 105, 123}, + { 96, 111, 129}, + { 102, 117, 135}, + { 108, 123, 141}, + { 114, 128, 146}, + { 120, 134, 152}, + { 127, 140, 158}, + { 133, 145, 163}, + { 140, 152, 170}, + { 48, 98, 134}, + { 57, 104, 137}, + { 63, 107, 140}, + { 69, 110, 143}, + { 75, 116, 146}, + { 84, 119, 149}, + { 90, 125, 152}, + { 95, 128, 155}, + { 101, 131, 158}, + { 110, 137, 161}, + { 119, 140, 164}, + { 128, 143, 167}, + { 134, 149, 170}, + { 143, 155, 173}, + { 152, 158, 176}, + { 158, 164, 179}, + { 0, 15, 24}, + { 0, 21, 33}, + { 0, 27, 42}, + { 0, 33, 51}, + { 0, 36, 57}, + { 0, 42, 66}, + { 0, 48, 75}, + { 0, 51, 81}, + { 0, 57, 93}, + { 6, 63, 98}, + { 12, 69, 104}, + { 18, 75, 110}, + { 24, 81, 116}, + { 30, 87, 122}, + { 36, 93, 128}, + { 39, 95, 131}, + { 0, 12, 26}, + { 0, 26, 52}, + { 0, 39, 78}, + { 0, 52, 102}, + { 0, 65, 127}, + { 0, 78, 150}, + { 0, 91, 172}, + { 0, 102, 191}, + { 9, 108, 191}, + { 19, 114, 191}, + { 29, 120, 191}, + { 39, 127, 191}, + { 48, 133, 191}, + { 58, 139, 191}, + { 68, 145, 191}, + { 78, 150, 191}, + { 0, 0, 12}, + { 0, 0, 36}, + { 0, 0, 60}, + { 0, 0, 84}, + { 0, 0, 107}, + { 0, 0, 131}, + { 0, 0, 155}, + { 0, 0, 179}, + { 0, 0, 191}, + { 36, 36, 191}, + { 60, 60, 191}, + { 84, 84, 191}, + { 107, 107, 191}, + { 131, 131, 191}, + { 155, 155, 191}, + { 179, 179, 191}, + { 0, 0, 104}, + { 15, 27, 125}, + { 30, 51, 140}, + { 45, 75, 155}, + { 60, 98, 167}, + { 75, 122, 176}, + { 90, 140, 185}, + { 104, 158, 191}, + { 0, 0, 0}, + { 0, 24, 24}, + { 0, 48, 48}, + { 0, 72, 72}, + { 0, 95, 95}, + { 0, 119, 119}, + { 0, 143, 143}, + { 0, 167, 167}, + { 0, 191, 191}, + { 12, 191, 191}, + { 24, 191, 191}, + { 36, 191, 191}, + { 48, 191, 191}, + { 60, 191, 191}, + { 72, 191, 191}, + { 84, 191, 191}, + { 95, 191, 191}, + { 107, 191, 191}, + { 119, 191, 191}, + { 131, 191, 191}, + { 143, 191, 191}, + { 155, 191, 191}, + { 167, 191, 191}, + { 179, 191, 191}, + { 0, 54, 54}, + { 9, 69, 69}, + { 18, 84, 84}, + { 27, 98, 98}, + { 39, 110, 110}, + { 48, 122, 122}, + { 57, 131, 131}, + { 66, 143, 143}, + { 85, 156, 191}, + { 91, 161, 191}, + { 96, 166, 191}, + { 102, 172, 191}, + { 108, 177, 191}, + { 114, 182, 191}, + { 120, 187, 191}, + { 127, 191, 191}, + { 101, 0, 131}, + { 106, 11, 134}, + { 111, 23, 138}, + { 117, 35, 142}, + { 123, 47, 145}, + { 129, 59, 149}, + { 134, 71, 153}, + { 140, 83, 157}, + { 145, 95, 160}, + { 151, 106, 164}, + { 157, 118, 168}, + { 162, 130, 172}, + { 168, 142, 175}, + { 173, 154, 179}, + { 179, 166, 183}, + { 185, 179, 187}, + { 24, 0, 65}, + { 42, 20, 80}, + { 61, 41, 95}, + { 79, 61, 110}, + { 97, 82, 124}, + { 115, 101, 139}, + { 135, 123, 154}, + { 153, 143, 169}, + { 191, 0, 191}, + { 191, 24, 191}, + { 191, 48, 191}, + { 191, 72, 191}, + { 191, 95, 191}, + { 191, 119, 191}, + { 191, 143, 191}, + { 191, 167, 191}, + { 0, 107, 0}, + { 0, 191, 0}, + { 24, 191, 24}, + { 48, 191, 48}, + { 72, 191, 72}, + { 95, 191, 95}, + { 119, 191, 119}, + { 143, 191, 143}, + { 16, 16, 9}, + { 44, 44, 22}, + { 73, 73, 36}, + { 101, 101, 51}, + { 127, 127, 66}, + { 142, 142, 93}, + { 156, 156, 121}, + { 170, 170, 151}, + { 31, 10, 0}, + { 48, 15, 0}, + { 64, 21, 0}, + { 79, 25, 0}, + { 95, 30, 0}, + { 111, 36, 0}, + { 127, 41, 0}, + { 143, 48, 0}, + { 149, 73, 24}, + { 155, 84, 48}, + { 161, 101, 72}, + { 167, 119, 95}, + { 191, 48, 48}, + { 191, 95, 95}, + { 191, 119, 119}, + { 191, 143, 143}, + { 18, 18, 0}, + { 42, 42, 0}, + { 61, 61, 0}, + { 86, 86, 0}, + { 104, 104, 0}, + { 129, 129, 0}, + { 154, 154, 0}, + { 172, 172, 0}, + { 191, 191, 0}, + { 191, 191, 18}, + { 191, 191, 36}, + { 191, 191, 55}, + { 191, 191, 74}, + { 191, 191, 92}, + { 191, 191, 110}, + { 191, 191, 129}, + { 191, 191, 131}, + { 191, 191, 143}, + { 191, 191, 149}, + { 191, 191, 161}, + { 191, 191, 167}, + { 191, 191, 179}, + { 191, 191, 185}, + { 191, 0, 0}, + { 36, 95, 36}, + { 54, 107, 54}, + { 72, 119, 72}, + { 90, 131, 90}, + { 107, 143, 107}, + { 125, 155, 125}, + { 143, 167, 143}, + { 161, 179, 161} +}; + +static const INT16 pPaletteDeltaNuke[256][3] = { + { 6,-133,-133}, + { 12,-125,-125}, + { 18,-117,-117}, + { 24,-109,-109}, + { 30,-101,-101}, + { 36, -93, -93}, + { 42, -85, -85}, + { 48, -77, -77}, + { 54, -69, -69}, + { 60, -61, -61}, + { 66, -53, -53}, + { 72, -45, -45}, + { 78, -37, -37}, + { 84, -29, -29}, + { 90, -21, -21}, + { 95, -14, -14}, + { 101, -6, -6}, + { 107, 2, 2}, + { 113, 10, 10}, + { 119, 18, 18}, + { 125, 26, 26}, + { 131, 34, 34}, + { 137, 42, 42}, + { 143, 50, 50}, + { 149, 58, 58}, + { 155, 66, 66}, + { 161, 74, 74}, + { 167, 82, 82}, + { 173, 90, 90}, + { 179, 98, 98}, + { 185, 106, 106}, + { 191, 113, 113}, + { 48, -53, -29}, + { 54, -46, -22}, + { 60, -38, -14}, + { 66, -30, -7}, + { 72, -23, 0}, + { 79, -15, 8}, + { 85, -8, 16}, + { 91, -1, 23}, + { 96, 7, 31}, + { 102, 15, 39}, + { 108, 23, 47}, + { 114, 30, 54}, + { 120, 38, 62}, + { 127, 46, 70}, + { 133, 53, 77}, + { 140, 62, 86}, + { 48, -10, 38}, + { 57, -2, 42}, + { 63, 2, 46}, + { 69, 6, 50}, + { 75, 14, 54}, + { 84, 18, 58}, + { 90, 26, 62}, + { 95, 30, 66}, + { 101, 34, 70}, + { 110, 42, 74}, + { 119, 46, 78}, + { 128, 50, 82}, + { 134, 58, 86}, + { 143, 66, 90}, + { 152, 70, 94}, + { 158, 78, 98}, + { 0,-121,-109}, + { 0,-113, -97}, + { 0,-105, -85}, + { 0, -97, -73}, + { 0, -93, -65}, + { 0, -85, -53}, + { 0, -77, -41}, + { 0, -73, -33}, + { 0, -65, -17}, + { 6, -57, -10}, + { 12, -49, -2}, + { 18, -41, 6}, + { 24, -33, 14}, + { 30, -25, 22}, + { 36, -17, 30}, + { 39, -14, 34}, + { 0,-124,-106}, + { 0,-106, -71}, + { 0, -89, -37}, + { 0, -71, -4}, + { 0, -54, 28}, + { 0, -37, 59}, + { 0, -20, 88}, + { 0, -4, 113}, + { 9, 4, 113}, + { 19, 12, 113}, + { 29, 20, 113}, + { 39, 28, 113}, + { 48, 36, 113}, + { 58, 44, 113}, + { 68, 52, 113}, + { 78, 59, 113}, + { 0,-141,-125}, + { 0,-141, -93}, + { 0,-141, -61}, + { 0,-141, -29}, + { 0,-141, 2}, + { 0,-141, 34}, + { 0,-141, 66}, + { 0,-141, 98}, + { 0,-141, 113}, + { 36, -93, 113}, + { 60, -61, 113}, + { 84, -29, 113}, + { 107, 2, 113}, + { 131, 34, 113}, + { 155, 66, 113}, + { 179, 98, 113}, + { 0,-141, -2}, + { 15,-105, 26}, + { 30, -73, 46}, + { 45, -41, 66}, + { 60, -10, 82}, + { 75, 22, 94}, + { 90, 46, 106}, + { 104, 70, 113}, + { 0,-141,-141}, + { 0,-109,-109}, + { 0, -77, -77}, + { 0, -45, -45}, + { 0, -14, -14}, + { 0, 18, 18}, + { 0, 50, 50}, + { 0, 82, 82}, + { 0, 113, 113}, + { 12, 113, 113}, + { 24, 113, 113}, + { 36, 113, 113}, + { 48, 113, 113}, + { 60, 113, 113}, + { 72, 113, 113}, + { 84, 113, 113}, + { 95, 113, 113}, + { 107, 113, 113}, + { 119, 113, 113}, + { 131, 113, 113}, + { 143, 113, 113}, + { 155, 113, 113}, + { 167, 113, 113}, + { 179, 113, 113}, + { 0, -69, -69}, + { 9, -49, -49}, + { 18, -29, -29}, + { 27, -10, -10}, + { 39, 6, 6}, + { 48, 22, 22}, + { 57, 34, 34}, + { 66, 50, 50}, + { 85, 67, 113}, + { 91, 74, 113}, + { 96, 81, 113}, + { 102, 88, 113}, + { 108, 95, 113}, + { 114, 102, 113}, + { 120, 108, 113}, + { 127, 113, 113}, + { 101,-141, 34}, + { 106,-126, 38}, + { 111,-110, 43}, + { 117, -94, 48}, + { 123, -78, 53}, + { 129, -62, 58}, + { 134, -46, 63}, + { 140, -30, 68}, + { 145, -14, 73}, + { 151, 1, 78}, + { 157, 17, 83}, + { 162, 33, 88}, + { 168, 49, 93}, + { 173, 65, 98}, + { 179, 81, 103}, + { 185, 98, 109}, + { 24,-141, -54}, + { 42,-114, -34}, + { 61, -86, -14}, + { 79, -59, 6}, + { 97, -32, 25}, + { 115, -6, 45}, + { 135, 23, 65}, + { 153, 50, 84}, + { 191,-141, 113}, + { 191,-109, 113}, + { 191, -77, 113}, + { 191, -45, 113}, + { 191, -14, 113}, + { 191, 18, 113}, + { 191, 50, 113}, + { 191, 82, 113}, + { 0, 2,-141}, + { 0, 113,-141}, + { 24, 113,-109}, + { 48, 113, -77}, + { 72, 113, -45}, + { 95, 113, -14}, + { 119, 113, 18}, + { 143, 113, 50}, + { 16,-119,-129}, + { 44, -82,-111}, + { 73, -43, -92}, + { 101, -6, -73}, + { 127, 29, -53}, + { 142, 48, -17}, + { 156, 67, 21}, + { 170, 86, 61}, + { 31,-127,-141}, + { 48,-121,-141}, + { 64,-113,-141}, + { 79,-107,-141}, + { 95,-100,-141}, + { 111, -93,-141}, + { 127, -86,-141}, + { 143, -77,-141}, + { 149, -43,-109}, + { 155, -29, -77}, + { 161, -6, -45}, + { 167, 18, -14}, + { 191, -77, -77}, + { 191, -14, -14}, + { 191, 18, 18}, + { 191, 50, 50}, + { 18,-117,-141}, + { 42, -84,-141}, + { 61, -59,-141}, + { 86, -26,-141}, + { 104, -2,-141}, + { 129, 31,-141}, + { 154, 64,-141}, + { 172, 89,-141}, + { 191, 113,-141}, + { 191, 113,-117}, + { 191, 113, -92}, + { 191, 113, -67}, + { 191, 113, -42}, + { 191, 113, -18}, + { 191, 113, 6}, + { 191, 113, 31}, + { 191, 113, 34}, + { 191, 113, 50}, + { 191, 113, 58}, + { 191, 113, 74}, + { 191, 113, 82}, + { 191, 113, 98}, + { 191, 113, 106}, + { 191,-141,-141}, + { 36, -14, -93}, + { 54, 2, -69}, + { 72, 18, -45}, + { 90, 34, -21}, + { 107, 50, 2}, + { 125, 66, 26}, + { 143, 82, 50}, + { 161, 98, 74} +}; + +#endif diff --git a/src/v_video.c b/src/v_video.c index 2aa680153..940dd190d 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -91,97 +91,7 @@ consvar_t cv_menucaps = {"menucaps", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NUL // local copy of the palette for V_GetColor() RGBA_t *pLocalPalette = NULL; RGBA_t *pGammaCorrectedPalette = NULL; - -// huge ass array les gooooooo! -// this is basically the white flashpal byte for byte from our main palette lmao -static RGBA_t pFallbackFlashPal[] = { - {.s={253, 253, 253, 255}}, {.s={251, 251, 251, 255}}, {.s={249, 249, 249, 255}}, - {.s={247, 247, 247, 255}}, {.s={245, 245, 245, 255}}, {.s={243, 243, 243, 255}}, - {.s={241, 241, 241, 255}}, {.s={239, 239, 239, 255}}, {.s={237, 237, 237, 255}}, - {.s={235, 235, 235, 255}}, {.s={233, 233, 233, 255}}, {.s={231, 231, 231, 255}}, - {.s={229, 229, 229, 255}}, {.s={227, 227, 227, 255}}, {.s={225, 225, 225, 255}}, - {.s={223, 223, 223, 255}}, {.s={221, 221, 221, 255}}, {.s={219, 219, 219, 255}}, - {.s={217, 217, 217, 255}}, {.s={215, 215, 215, 255}}, {.s={213, 213, 213, 255}}, - {.s={211, 211, 211, 255}}, {.s={209, 209, 209, 255}}, {.s={207, 207, 207, 255}}, - {.s={205, 205, 205, 255}}, {.s={203, 203, 203, 255}}, {.s={201, 201, 201, 255}}, - {.s={199, 199, 199, 255}}, {.s={197, 197, 197, 255}}, {.s={195, 195, 195, 255}}, - {.s={193, 193, 193, 255}}, {.s={192, 192, 192, 255}}, {.s={239, 233, 227, 255}}, - {.s={237, 231, 225, 255}}, {.s={235, 229, 223, 255}}, {.s={233, 227, 221, 255}}, - {.s={231, 225, 219, 255}}, {.s={229, 223, 217, 255}}, {.s={227, 221, 215, 255}}, - {.s={225, 220, 214, 255}}, {.s={223, 218, 212, 255}}, {.s={220, 216, 210, 255}}, - {.s={218, 214, 208, 255}}, {.s={216, 212, 206, 255}}, {.s={214, 210, 204, 255}}, - {.s={212, 208, 202, 255}}, {.s={210, 206, 200, 255}}, {.s={208, 204, 198, 255}}, - {.s={239, 222, 210, 255}}, {.s={236, 220, 209, 255}}, {.s={234, 219, 208, 255}}, - {.s={232, 218, 207, 255}}, {.s={230, 216, 206, 255}}, {.s={227, 215, 205, 255}}, - {.s={225, 213, 204, 255}}, {.s={223, 212, 203, 255}}, {.s={221, 211, 202, 255}}, - {.s={218, 209, 201, 255}}, {.s={215, 208, 200, 255}}, {.s={212, 207, 199, 255}}, - {.s={210, 205, 198, 255}}, {.s={207, 203, 197, 255}}, {.s={204, 202, 196, 255}}, - {.s={202, 200, 195, 255}}, {.s={255, 250, 247, 255}}, {.s={255, 248, 244, 255}}, - {.s={255, 246, 241, 255}}, {.s={255, 244, 238, 255}}, {.s={255, 243, 236, 255}}, - {.s={255, 241, 233, 255}}, {.s={255, 239, 230, 255}}, {.s={255, 238, 228, 255}}, - {.s={255, 236, 224, 255}}, {.s={253, 234, 222, 255}}, {.s={251, 232, 220, 255}}, - {.s={249, 230, 218, 255}}, {.s={247, 228, 216, 255}}, {.s={245, 226, 214, 255}}, - {.s={243, 224, 212, 255}}, {.s={242, 223, 211, 255}}, {.s={255, 250, 246, 255}}, - {.s={255, 246, 237, 255}}, {.s={255, 242, 229, 255}}, {.s={255, 237, 220, 255}}, - {.s={255, 233, 213, 255}}, {.s={255, 229, 205, 255}}, {.s={255, 225, 198, 255}}, - {.s={255, 220, 192, 255}}, {.s={252, 218, 192, 255}}, {.s={248, 216, 192, 255}}, - {.s={245, 214, 192, 255}}, {.s={242, 213, 192, 255}}, {.s={238, 211, 192, 255}}, - {.s={235, 209, 192, 255}}, {.s={232, 207, 192, 255}}, {.s={229, 205, 192, 255}}, - {.s={255, 255, 251, 255}}, {.s={255, 255, 243, 255}}, {.s={255, 255, 235, 255}}, - {.s={255, 255, 227, 255}}, {.s={255, 255, 219, 255}}, {.s={255, 255, 211, 255}}, - {.s={255, 255, 203, 255}}, {.s={255, 255, 195, 255}}, {.s={255, 255, 192, 255}}, - {.s={243, 243, 192, 255}}, {.s={235, 235, 192, 255}}, {.s={227, 227, 192, 255}}, - {.s={219, 219, 192, 255}}, {.s={211, 211, 192, 255}}, {.s={203, 203, 192, 255}}, - {.s={195, 195, 192, 255}}, {.s={255, 255, 220, 255}}, {.s={250, 246, 213, 255}}, - {.s={245, 238, 208, 255}}, {.s={240, 230, 203, 255}}, {.s={235, 222, 199, 255}}, - {.s={230, 214, 196, 255}}, {.s={225, 208, 193, 255}}, {.s={220, 202, 192, 255}}, - {.s={255, 255, 255, 255}}, {.s={255, 247, 247, 255}}, {.s={255, 239, 239, 255}}, - {.s={255, 231, 231, 255}}, {.s={255, 223, 223, 255}}, {.s={255, 215, 215, 255}}, - {.s={255, 207, 207, 255}}, {.s={255, 199, 199, 255}}, {.s={255, 192, 192, 255}}, - {.s={251, 192, 192, 255}}, {.s={247, 192, 192, 255}}, {.s={243, 192, 192, 255}}, - {.s={239, 192, 192, 255}}, {.s={235, 192, 192, 255}}, {.s={231, 192, 192, 255}}, - {.s={227, 192, 192, 255}}, {.s={223, 192, 192, 255}}, {.s={219, 192, 192, 255}}, - {.s={215, 192, 192, 255}}, {.s={211, 192, 192, 255}}, {.s={207, 192, 192, 255}}, - {.s={203, 192, 192, 255}}, {.s={199, 192, 192, 255}}, {.s={195, 192, 192, 255}}, - {.s={255, 237, 237, 255}}, {.s={252, 232, 232, 255}}, {.s={249, 227, 227, 255}}, - {.s={246, 222, 222, 255}}, {.s={242, 218, 218, 255}}, {.s={239, 214, 214, 255}}, - {.s={236, 211, 211, 255}}, {.s={233, 207, 207, 255}}, {.s={227, 203, 192, 255}}, - {.s={225, 201, 192, 255}}, {.s={223, 199, 192, 255}}, {.s={220, 198, 192, 255}}, - {.s={218, 196, 192, 255}}, {.s={216, 194, 192, 255}}, {.s={214, 193, 192, 255}}, - {.s={213, 192, 192, 255}}, {.s={221, 255, 211, 255}}, {.s={219, 251, 210, 255}}, - {.s={217, 247, 209, 255}}, {.s={215, 243, 208, 255}}, {.s={214, 239, 206, 255}}, - {.s={212, 235, 205, 255}}, {.s={210, 231, 204, 255}}, {.s={208, 227, 203, 255}}, - {.s={206, 223, 201, 255}}, {.s={205, 219, 200, 255}}, {.s={203, 215, 199, 255}}, - {.s={201, 211, 198, 255}}, {.s={199, 207, 196, 255}}, {.s={197, 203, 195, 255}}, - {.s={195, 199, 194, 255}}, {.s={193, 195, 192, 255}}, {.s={246, 255, 233, 255}}, - {.s={241, 248, 228, 255}}, {.s={234, 241, 223, 255}}, {.s={228, 234, 218, 255}}, - {.s={222, 228, 213, 255}}, {.s={216, 221, 208, 255}}, {.s={210, 214, 203, 255}}, - {.s={204, 207, 199, 255}}, {.s={192, 255, 192, 255}}, {.s={192, 247, 192, 255}}, - {.s={192, 239, 192, 255}}, {.s={192, 231, 192, 255}}, {.s={192, 223, 192, 255}}, - {.s={192, 215, 192, 255}}, {.s={192, 207, 192, 255}}, {.s={192, 199, 192, 255}}, - {.s={255, 219, 255, 255}}, {.s={255, 192, 255, 255}}, {.s={247, 192, 247, 255}}, - {.s={239, 192, 239, 255}}, {.s={231, 192, 231, 255}}, {.s={223, 192, 223, 255}}, - {.s={215, 192, 215, 255}}, {.s={207, 192, 207, 255}}, {.s={249, 249, 252, 255}}, - {.s={240, 240, 247, 255}}, {.s={230, 230, 242, 255}}, {.s={221, 221, 238, 255}}, - {.s={212, 212, 233, 255}}, {.s={208, 208, 224, 255}}, {.s={203, 203, 214, 255}}, - {.s={198, 198, 204, 255}}, {.s={244, 251, 255, 255}}, {.s={239, 250, 255, 255}}, - {.s={234, 248, 255, 255}}, {.s={228, 246, 255, 255}}, {.s={223, 244, 255, 255}}, - {.s={218, 243, 255, 255}}, {.s={213, 241, 255, 255}}, {.s={207, 239, 255, 255}}, - {.s={205, 230, 247, 255}}, {.s={203, 227, 239, 255}}, {.s={201, 221, 231, 255}}, - {.s={199, 215, 223, 255}}, {.s={192, 239, 239, 255}}, {.s={192, 223, 223, 255}}, - {.s={192, 215, 215, 255}}, {.s={192, 207, 207, 255}}, {.s={249, 249, 255, 255}}, - {.s={240, 240, 255, 255}}, {.s={234, 234, 255, 255}}, {.s={226, 226, 255, 255}}, - {.s={220, 220, 255, 255}}, {.s={212, 212, 255, 255}}, {.s={204, 204, 255, 255}}, - {.s={197, 197, 255, 255}}, {.s={192, 192, 255, 255}}, {.s={192, 192, 249, 255}}, - {.s={192, 192, 242, 255}}, {.s={192, 192, 236, 255}}, {.s={192, 192, 230, 255}}, - {.s={192, 192, 224, 255}}, {.s={192, 192, 218, 255}}, {.s={192, 192, 212, 255}}, - {.s={192, 192, 211, 255}}, {.s={192, 192, 207, 255}}, {.s={192, 192, 205, 255}}, - {.s={192, 192, 201, 255}}, {.s={192, 192, 199, 255}}, {.s={192, 192, 195, 255}}, - {.s={192, 192, 193, 255}}, {.s={192, 255, 255, 255}}, {.s={243, 223, 243, 255}}, - {.s={237, 219, 237, 255}}, {.s={231, 215, 231, 255}}, {.s={225, 211, 225, 255}}, - {.s={219, 207, 219, 255}}, {.s={213, 203, 213, 255}}, {.s={207, 199, 207, 255}}, - {.s={201, 195, 201, 255}} -}; +static RGBA_t *pFallbackFlashPal = NULL; static size_t currentPaletteSize; @@ -500,6 +410,58 @@ UINT32 V_GammaCorrect(UINT32 input, double power) return result.rgba; } +#include "v_paldeltas.h" +// remaps a palette with given "deltas" +// this is used with premade deltas between the srb2 palette and its both flashpals +// so we may approximate generate our own, should the current palette miss them +static void ApplyPaletteDelta(const RGBA_t *pal_in, RGBA_t *pal_out, const INT16 pal_delta[][3]) +{ + size_t i; + + for (i = 0; i < 256; i++) + { + INT16 r = (INT16)pal_in[i].s.red + pal_delta[i][0]; + INT16 g = (INT16)pal_in[i].s.green + pal_delta[i][1]; + INT16 b = (INT16)pal_in[i].s.blue + pal_delta[i][2]; + pal_out[i].s.red = (UINT8)CLAMP(r, 0 , 255); + pal_out[i].s.green = (UINT8)CLAMP(g, 0 , 255); + pal_out[i].s.blue = (UINT8)CLAMP(b, 0 , 255); + pal_out[i].s.alpha = 0xFF; // pal_in[i].s.alpha + } +} + +static void GenerateFlashPalettes(void) +{ + size_t i, palsize; + RGBA_t *pFlashPalGammaCorrectedPalette = NULL; + + // generate flashpalettes if the current palette does not provide any subpalettes + if (currentPaletteSize >= (14 * (256 * 3))) // 14 palettes are in playpal + return; + + palsize = (2*256); + + pFallbackFlashPal = Z_Malloc(sizeof(*pFallbackFlashPal)*palsize, PU_STATIC, NULL); + pFlashPalGammaCorrectedPalette = Z_Malloc(sizeof (*pFlashPalGammaCorrectedPalette)*palsize, PU_STATIC, NULL); + + // apply our deltas to the palettes to get the white and red "flashes" + ApplyPaletteDelta(pLocalPalette, pFallbackFlashPal, pPaletteDeltaFlash); + ApplyPaletteDelta(pLocalPalette, pFallbackFlashPal+256, pPaletteDeltaNuke); + + // apply colour and gamma correction if needed + if (Cubeapply) + { + for (i = 0; i < palsize; i++) + { + pFlashPalGammaCorrectedPalette[i].rgba = V_GammaDecode(pFallbackFlashPal[i].rgba); + V_CubeApply(&pFlashPalGammaCorrectedPalette[i]); + pFallbackFlashPal[i].rgba = V_GammaEncode(pFlashPalGammaCorrectedPalette[i].rgba); + } + } + + Z_Free(pFlashPalGammaCorrectedPalette); +} + // keep a copy of the palette so that we can get the RGB value for a color index at any time. static void LoadPalette(const char *lumpname) { @@ -519,6 +481,8 @@ static void LoadPalette(const char *lumpname) Z_Free(pLocalPalette); Z_Free(pGammaCorrectedPalette); + Z_Free(pFallbackFlashPal); + pFallbackFlashPal = NULL; pLocalPalette = Z_Malloc(sizeof (*pLocalPalette)*palsize, PU_STATIC, NULL); pGammaCorrectedPalette = Z_Malloc(sizeof (*pGammaCorrectedPalette)*palsize, PU_STATIC, NULL); @@ -538,12 +502,19 @@ static void LoadPalette(const char *lumpname) pLocalPalette[i].s.alpha = 0xFF; pGammaCorrectedPalette[i].rgba = V_GammaDecode(pLocalPalette[i].rgba); + } - if (!Cubeapply) - continue; + GenerateFlashPalettes(); - V_CubeApply(&pGammaCorrectedPalette[i]); - pLocalPalette[i].rgba = V_GammaEncode(pGammaCorrectedPalette[i].rgba); + // gotta apply any colour and gamma adjustments afterwards + // so we dont double apply it to the generated flashpals + if (Cubeapply) + { + for (i = 0; i < palsize; i++) + { + V_CubeApply(&pGammaCorrectedPalette[i]); + pLocalPalette[i].rgba = V_GammaEncode(pGammaCorrectedPalette[i].rgba); + } } } @@ -646,25 +617,32 @@ void V_SetPalette(INT32 palettenum) if (palettenum == 0) { palettenum = cv_palettenum.value; - - if (palettenum * 256U > (currentPaletteSize - 256) / 3) - { - CONS_Alert(CONS_WARNING, "cv_palettenum %d out of range\n", palettenum); - palettenum = 0; - } } } - // if the palettenum goes beyond our current palette, then just fallback to the white flash pal - // our srb2 palette mostly just contains that as subpalettes, so everything uses this - // and makes it a good fallback case - // otherwise we will throw random garbage to the renderer which calls memcpy on it - // which is not really a good thing lol - // we probably could just memcpy from localpalette, but i dont trust -file nor autoload so - if (palettenum * 256U > (currentPaletteSize - 256) / 3) + // in many cases custom palettes do not provide the needed subpalettes for flashpals to work + // before this would mean the renderer gets passed random data out of allocated memory bounds + // which was not very cool :chonkbuncle: + // gladly 2.1 only actually has 2 different subpalettes + // one for "white flash" and one red/pinkish one for nuke + // since we checked the palette earlier we should have generated those ourselves + if (((size_t)palettenum >= currentPaletteSize / (256 * 3))) { CONS_Debug(DBG_RENDER, "palettenum %d out of range\n", palettenum); - pal = pFallbackFlashPal; + + // if for some reason we did not generate flashpals + // just fall back to the main palette i guess? + if (pFallbackFlashPal != NULL) + { + if (palettenum == PAL_NUKE) + pal = &pFallbackFlashPal[256]; + else + pal = pFallbackFlashPal; + } + else + { + pal = pLocalPalette; + } } else { From 6430150b63b9503e7e6cc97b3af13ec5125edbd5 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Mar 2026 17:53:16 +0100 Subject: [PATCH 196/589] fix parts of png info text for screenshots not being null terminated in some cases --- src/m_misc.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/m_misc.c b/src/m_misc.c index ee17e2098..97777a979 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -788,10 +788,10 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png else snprintf(locationtxt, 40, "Unknown"); - memset(png_infotext,0x00,sizeof (png_infotext)); + memset(png_infotext, 0x00, sizeof(png_infotext)); for (i = 0; i < SRB2PNGTXT; i++) - png_infotext[i].key = keytxt[i]; + png_infotext[i].key = keytxt[i]; png_infotext[0].text = titletxt; if (movie) @@ -804,9 +804,15 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png png_infotext[5].text = locationtxt; png_infotext[6].text = interfacetxt; png_infotext[7].text = rendermodetxt; - png_infotext[8].text = strncpy(ctrevision, comprevision, sizeof(ctrevision)-1); - png_infotext[9].text = strncpy(ctdate, compdate, sizeof(ctdate)-1); - png_infotext[10].text = strncpy(cttime, comptime, sizeof(cttime)-1); + strncpy(ctrevision, comprevision, sizeof(ctrevision)-1); + ctrevision[sizeof(ctrevision)-1] = '\0'; + png_infotext[8].text = ctrevision; + strncpy(ctdate, compdate, sizeof(ctdate)-1); + ctdate[sizeof(ctdate)-1] = '\0'; + png_infotext[9].text = ctdate; + strncpy(cttime, comptime, sizeof(cttime)-1); + cttime[sizeof(cttime)-1] = '\0'; + png_infotext[10].text = cttime; png_set_text(png_ptr, png_info_ptr, png_infotext, SRB2PNGTXT); #undef SRB2PNGTXT @@ -1564,6 +1570,7 @@ char *M_GetToken(const char *inputString) { startPos = endPos; } + if (stringToUse == NULL) return NULL; @@ -1634,7 +1641,8 @@ char *M_GetToken(const char *inputString) } // If the end of the string is reached, no token is to be read - if (startPos == stringLength) { + if (startPos == stringLength) + { endPos = stringLength; return NULL; } @@ -1644,7 +1652,7 @@ char *M_GetToken(const char *inputString) || stringToUse[startPos] == '}') { endPos = startPos + 1; - texturesToken = (char *)Z_Malloc(2*sizeof(char),PU_STATIC,NULL); + texturesToken = (char *)Z_Malloc(2*sizeof(char), PU_STATIC, NULL); texturesToken[0] = stringToUse[startPos]; texturesToken[1] = '\0'; return texturesToken; @@ -1855,8 +1863,10 @@ int M_PathParts(const char *path) int n; const char *p; const char *t; + if (path == NULL) return 0; + for (n = 0, p = path ;; ++n) { t = p; @@ -1869,6 +1879,7 @@ int M_PathParts(const char *path) break; } } + return n; } @@ -1911,7 +1922,9 @@ void M_MkdirEachUntil(const char *cpath, int start, int end, int mode) if (!( p = strchr(p, PATHSEP[0]) )) return; } + p += strspn(p, PATHSEP); + for (;;) { if (end > 0 && !--end) From 9ee535066e8aa44a4fc07d0ebb21ac809ca33642 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 3 Mar 2026 02:22:02 +0100 Subject: [PATCH 197/589] =?UTF-8?q?OpenGL:=20initialize=20all=20FSurfaceIn?= =?UTF-8?q?fo=C2=B4s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit seen this a bunch of times now that occasionally something tries to access uninit values from a surface info since those are really small we just always init them now --- src/hardware/hw_draw.c | 14 +++++++------- src/hardware/hw_main.cpp | 22 ++++++++++------------ src/hardware/hw_md2.c | 5 ++--- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 4797f21de..3602cef1b 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -222,7 +222,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p if (alphalevel) { - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; switch (alphalevel) @@ -385,7 +385,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, // clip it since it is used for bunny scroll in doom I if (alphalevel) { - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; switch (alphalevel) @@ -490,7 +490,7 @@ void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum) void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) { FOutVector v[4]; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; FBITFIELD poly_flags = PF_NoTexture|PF_Modulated|PF_NoDepthTest; v[0].x = v[3].x = -1.0f; @@ -543,7 +543,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) void HWR_DrawConsoleBack(UINT32 color, INT32 height) { FOutVector v[4]; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; // setup some neat-o translucency effect if (!height) //cool hack 0 height is full height @@ -598,7 +598,7 @@ void HWR_drawAMline(const fline_t *fl, INT32 color) void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) { FOutVector v[4]; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; float fx, fy, fw, fh, fwait = 0; RGBA_t *palette; @@ -702,7 +702,7 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options) { FOutVector v[4]; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; float fx, fy, fw, fh; if (w < 0 || h < 0) @@ -820,7 +820,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) { FOutVector v[4]; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; float fx, fy, fw, fh; if (w < 0 || h < 0) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index e6ce072cf..bf11f0c7c 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -550,7 +550,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t // Render a floor or ceiling convex polygon static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap) { - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; FOutVector *v3d; polyvertex_t *pv; pslope_t *slope = NULL; @@ -1375,7 +1375,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom extracolormap_t *colormap = gl_frontsector->extra_colormap; lightnum = HWR_CalcWallLight(lightnum, gl_curline, colormap); - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; Surf.PolyColor.s.alpha = 255; @@ -2674,7 +2674,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, float scrollx = 0.0f, scrolly = 0.0f; float anglef = 0.0f, cosangf = 0.0f, sinangf = 0.0f; angle_t angle = 0; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; fixed_t tempxsow, tempytow; size_t nrPlaneVerts; @@ -2841,9 +2841,8 @@ static void HWR_AddPolyObjectPlanes(void) light = R_GetPlaneLight(gl_frontsector, polyobjsector->floorheight, true); if (po_ptrs[i]->translucency > 0) { - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; FBITFIELD blendmode; - memset(&Surf, 0x00, sizeof(Surf)); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight, (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap)); @@ -2864,9 +2863,8 @@ static void HWR_AddPolyObjectPlanes(void) light = R_GetPlaneLight(gl_frontsector, polyobjsector->ceilingheight, true); if (po_ptrs[i]->translucency > 0) { - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; FBITFIELD blendmode; - memset(&Surf, 0x00, sizeof(Surf)); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight, (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap)); @@ -3418,7 +3416,7 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t { float this_scale = 1.0f; FOutVector swallVerts[4]; - FSurfaceInfo sSurf; + FSurfaceInfo sSurf = {}; FBITFIELD blendmode = 0; fixed_t floorheight, mobjfloor; pslope_t *floorslope; @@ -3654,7 +3652,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) FOutVector baseWallVerts[4]; // This is what the verts should end up as patch_t *gpatch; GLPatch_t *hwrpatch; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; extracolormap_t *colormap; INT32 lightlevel; boolean lightset = true; @@ -3939,7 +3937,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) FOutVector wallVerts[4]; patch_t *gpatch; // sprite patch converted to hardware GLPatch_t *hwrpatch; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; FBITFIELD blend = 0; INT32 shader = SHADER_NONE; @@ -4104,7 +4102,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) FOutVector wallVerts[4]; patch_t *gpatch; // sprite patch converted to hardware GLPatch_t *hwrpatch; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; INT32 shader = SHADER_NONE; @@ -6081,7 +6079,7 @@ static void HWR_DoPostProcessor(void) {-4.0f, -4.0f, 4.0f, 0.0f, 0.0f} }; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; // This won't change if the flash palettes are changed unfortunately, but it works for its purpose if (player->flashpal == PAL_NUKE) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index d9bf41645..2aefecea1 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1099,7 +1099,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) INT32 frame = 0; INT32 nextFrame = -1; FTransform p; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; if (!cv_glmdls.value || spr->precip) return; @@ -1475,7 +1475,7 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c patch_t *gpatch, *blendgpatch; GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; FTransform p; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; if (!md2->model) { @@ -1526,7 +1526,6 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c if (blendgpatch) hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); - memset(&Surf, 0x00, sizeof(FSurfaceInfo)); Surf.PolyColor.rgba = 0xFFFFFFFF; Surf.PolyFlags = PF_Occlude | PF_Modulated; From 7b408a33d7f0413b1645f16c9fa4235767446f84 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 3 Mar 2026 02:19:29 +0100 Subject: [PATCH 198/589] fix openmpt versions strings leaking from https://lib.openmpt.org/doc/libopenmpt_c_overview.html "All strings returned from libopenmpt are dynamically allocated and must be freed with openmpt_free_string()." didnt knew this tbh lol --- src/sdl/mixer_sound.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 7dccd9673..f177412e7 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -216,8 +216,13 @@ void I_StartupSound(void) SDLmixlinked->major, SDLmixlinked->minor, SDLmixlinked->patch); #ifdef HAVE_OPENMPT - I_OutputMsg("libopenmpt version: %s\n", openmpt_get_string("library_version")); - I_OutputMsg("libopenmpt build date: %s\n", openmpt_get_string("build")); + const char *openmptstr; + openmptstr = openmpt_get_string("library_version"); + I_OutputMsg("libopenmpt version: %s\n", openmptstr); + openmpt_free_string(openmptstr); + openmptstr = openmpt_get_string("build"); + I_OutputMsg("libopenmpt build date: %s\n", openmptstr); + openmpt_free_string(openmptstr); #endif sound_started = true; From a1666704e51447667e7d2ce2795d70bdab40ea8b Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 9 Mar 2026 14:51:24 +0300 Subject: [PATCH 199/589] Hide offroad particles when player is doing saltyhop --- src/k_kart.c | 12 ++++++++++-- src/k_kart.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 2aa0377b2..3ba8ce8a2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2159,7 +2159,13 @@ static void K_GetKartBoostPower(player_t *player) && player->speed > 0 && !player->spectator) { - K_SpawnWipeoutTrail(player->mo, true); + mobj_t *dust = K_SpawnWipeoutTrail(player->mo, true); + + // Technically, all mobjs that think can cause desynchs if they are spawned conditionally, so best we can do + // is to hide them if you are in saltyhop jump + if (dust && player->mo->salty.jump) + dust->flags2 |= MF2_DONTDRAW; + if (leveltime % 6 == 0) S_StartSound(player->mo, sfx_cdfm70); } @@ -3634,7 +3640,7 @@ void K_SpawnSparkleTrail(mobj_t *mo) P_SetMobjState(sparkle, S_KARTINVULN_LARGE1); } -void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) +mobj_t *K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) { mobj_t *dust; angle_t aoff; @@ -3675,6 +3681,8 @@ void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) if (translucent) dust->flags2 |= MF2_SHADOW; + + return dust; } // K_DriftDustHandling diff --git a/src/k_kart.h b/src/k_kart.h index ab0d8bd14..9307ce273 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -57,7 +57,7 @@ boolean K_ShouldSlopeRoll(mobj_t *mobj); void K_RollMobjBySlopes(mobj_t *mo, pslope_t *slope); void K_SpawnBoostTrail(player_t *player); void K_SpawnSparkleTrail(mobj_t *mo); -void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent); +mobj_t *K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent); void K_DriftDustHandling(mobj_t *spawner); void K_PuntMine(mobj_t *mine, mobj_t *punter); void K_DoSneaker(player_t *player, INT32 type); From af84105e40b7928496e476cbeef97c00689fe2e8 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 10 Mar 2026 16:55:20 +0100 Subject: [PATCH 200/589] better error for nodeless maps --- src/p_setup.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index c9aba324a..8b0074d2b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -414,7 +414,7 @@ void P_UpdateSegLightOffset(seg_t *li) angle_t liAngle = R_PointToAngle2(0, 0, (li->v1->x - li->v2->x), (li->v1->y - li->v2->y)) - ANGLE_90; light = FixedMul(FINECOSINE(liAngle >> ANGLETOFINESHIFT), FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT)) - + FixedMul(FINESINE(liAngle >> ANGLETOFINESHIFT), FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); + + FixedMul(FINESINE(liAngle >> ANGLETOFINESHIFT), FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); light = (light + FRACUNIT) / 2; } else @@ -1914,7 +1914,7 @@ static void P_LoadMapBSP(const virtres_t* virt) if (numsubsectors <= 0) I_Error("Level has no subsectors (did you forget to run it through a nodesbuilder?)"); if (numnodes <= 0) - I_Error("Level has no nodes"); + I_Error("Level has no nodes (does your map have at least 2 sectors?)"); if (numsegs <= 0) I_Error("Level has no segs"); @@ -2077,10 +2077,10 @@ static void P_LevelInitStuff(boolean reloadinggamestate) stagefailed = false; // earthquake camera - memset(&quake,0,sizeof(struct quake)); + memset(&quake, 0, sizeof(struct quake)); // song credit init - memset(&cursongcredit,0,sizeof(struct cursongcredit)); + memset(&cursongcredit, 0, sizeof(struct cursongcredit)); cursongcredit.trans = NUMTRANSMAPS; for (i = 0; i < MAXPLAYERS; i++) From 98da654e027139c44b01c4b86affd478efbcfec2 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 10 Mar 2026 16:54:42 +0100 Subject: [PATCH 201/589] Fix P_MakeMapMD5 printing incorrect time :chonkbuncle: --- src/p_setup.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 8b0074d2b..3f3759bf9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2174,14 +2174,14 @@ static INT32 P_MakeBufferMD5(const char *buffer, size_t len, void *resblock) memset(resblock, 0x00, 16); return 1; #else - tic_t t = I_GetTime(); + precise_t t = I_GetPreciseTime(); 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); + CONS_Debug(DBG_SETUP, "MD5 calc took %f seconds\n", (float)(I_GetPreciseTime() - t)/I_GetPrecisePrecision()); return 0; #endif @@ -2203,10 +2203,10 @@ static void P_MakeMapMD5(virtres_t *virt, void *dest) virtlump_t* virtmthings = vres_Find(virt, "THINGS"); virtlump_t* virtsides = vres_Find(virt, "SIDEDEFS"); - P_MakeBufferMD5((char*)virtlines->data, virtlines->size, linemd5); - P_MakeBufferMD5((char*)virtsectors->data, virtsectors->size, sectormd5); - P_MakeBufferMD5((char*)virtmthings->data, virtmthings->size, thingmd5); - P_MakeBufferMD5((char*)virtsides->data, virtsides->size, sidedefmd5); + P_MakeBufferMD5((char*)virtlines->data, virtlines->size, linemd5); + P_MakeBufferMD5((char*)virtsectors->data, virtsectors->size, sectormd5); + P_MakeBufferMD5((char*)virtmthings->data, virtmthings->size, thingmd5); + P_MakeBufferMD5((char*)virtsides->data, virtsides->size, sidedefmd5); for (i = 0; i < 16; i++) resmd5[i] = (linemd5[i] + sectormd5[i] + thingmd5[i] + sidedefmd5[i]) & 0xFF; From a7ebc7e74539713989ea0c35af0e9b0d8c14bc14 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 16:39:19 +0100 Subject: [PATCH 202/589] Blua: micro-optimization: avoid one API call in 'read_chars' https://github.com/lua/lua/commit/f86f4116c82654d24faa4a32a909d0c27f3d4746 --- src/blua/liolib.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/blua/liolib.c b/src/blua/liolib.c index 2cd8dd481..2ef46c6a6 100644 --- a/src/blua/liolib.c +++ b/src/blua/liolib.c @@ -356,20 +356,21 @@ static int read_line (lua_State *L, FILE *f) { static int read_chars (lua_State *L, FILE *f, size_t n) { - size_t rlen; /* how much to read */ - size_t nr; /* number of chars actually read */ + size_t tbr = n; /* number of chars to be read */ + size_t rlen; /* how much to read in each cycle */ + size_t nr; /* number of chars actually read in each cycle */ luaL_Buffer b; luaL_buffinit(L, &b); rlen = LUAL_BUFFERSIZE; /* try to read that much each time */ do { char *p = luaL_prepbuffer(&b); - if (rlen > n) rlen = n; /* cannot read more than asked */ + if (rlen > tbr) rlen = tbr; /* cannot read more than asked */ nr = fread(p, sizeof(char), rlen, f); luaL_addsize(&b, nr); - n -= nr; /* still have to read `n' chars */ - } while (n > 0 && nr == rlen); /* until end of count or eof */ + tbr -= nr; /* still have to read 'tbr' chars */ + } while (tbr > 0 && nr == rlen); /* until end of count or eof */ luaL_pushresult(&b); /* close buffer */ - return (n == 0 || lua_objlen(L, -1) > 0); + return (tbr == 0 || tbr < n); /* true iff read something */ } @@ -432,13 +433,13 @@ static int f_read (lua_State *L) { static int io_readline (lua_State *L) { FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1)); - int sucess; + int success; if (f == NULL) /* file is already closed? */ luaL_error(L, "file is already closed"); - sucess = read_line(L, f); + success = read_line(L, f); if (ferror(f)) return luaL_error(L, "%s", strerror(errno)); - if (sucess) return 1; + if (success) return 1; else { /* EOF */ if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */ lua_settop(L, 0); From 91435fe1b2bf99a28ff18946cf191890230d0dfc Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 16:39:56 +0100 Subject: [PATCH 203/589] Blua: small optimization (reorder of BinOpr enum to unify some cases in switches) https://github.com/lua/lua/commit/d7872dcf91eb2075312a03973a6cdb489610c796 --- src/blua/lcode.c | 25 +++++++++++++------------ src/blua/lcode.h | 6 +++--- src/blua/lparser.c | 8 ++++---- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/blua/lcode.c b/src/blua/lcode.c index efb20e96b..567b88500 100644 --- a/src/blua/lcode.c +++ b/src/blua/lcode.c @@ -790,18 +790,19 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) { case OPR_BXOR: codearith(fs, OP_BXOR, e1, e2); break; case OPR_BSHL: codearith(fs, OP_BSHL, e1, e2); break; case OPR_BSHR: codearith(fs, OP_BSHR, e1, e2); break; - case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break; - case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break; - case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break; - case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break; - case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break; - case OPR_POW: codearith(fs, OP_POW, e1, e2); break; - case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break; - case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break; - case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break; - case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break; - case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break; - case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break; + case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV: + case OPR_MOD: case OPR_POW: { + codearith(fs, op - OPR_ADD + OP_ADD, e1, e2); + break; + } + case OPR_EQ: case OPR_LT: case OPR_LE: { + codecomp(fs, op - OPR_EQ + OP_EQ, 1, e1, e2); + break; + } + case OPR_NE: case OPR_GT: case OPR_GE: { + codecomp(fs, op - OPR_NE + OP_EQ, 0, e1, e2); + break; + } default: lua_assert(0); } } diff --git a/src/blua/lcode.h b/src/blua/lcode.h index 5b8009472..b15c1bfeb 100644 --- a/src/blua/lcode.h +++ b/src/blua/lcode.h @@ -21,13 +21,13 @@ /* -** grep "ORDER OPR" if you change these enums +** grep "ORDER OPR" if you change these enums (ORDER OP) */ typedef enum BinOpr { OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, OPR_CONCAT, - OPR_NE, OPR_EQ, - OPR_LT, OPR_LE, OPR_GT, OPR_GE, + OPR_EQ, OPR_LT, OPR_LE, + OPR_NE, OPR_GT, OPR_GE, OPR_AND, OPR_OR, OPR_BAND, OPR_BOR, OPR_BXOR, OPR_BSHL, OPR_BSHR, diff --git a/src/blua/lparser.c b/src/blua/lparser.c index 871c9730d..8046b0f1f 100644 --- a/src/blua/lparser.c +++ b/src/blua/lparser.c @@ -881,10 +881,10 @@ static const struct { lu_byte right; /* right priority */ } priority[] = { /* ORDER OPR */ {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */ - {10, 9}, {5, 4}, /* power and concat (right associative) */ - {3, 3}, {3, 3}, /* equality and inequality */ - {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */ - {2, 2}, {1, 1} /* logical (and/or) */ + {10, 9}, {5, 4}, /* ^, .. (right associative) */ + {3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */ + {3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */ + {2, 2}, {1, 1} /* and, or */ ,{6, 6}, {6, 6}, {6, 6}, /* bit-wise (band/bor/bxor) */ {7, 7}, {7, 7} /* shl/shr */ }; From edc10a35a1e41e1143d41e7b1f64f1e10baa6bfb Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 16:40:51 +0100 Subject: [PATCH 204/589] Blua: better names for metamethods in debug information https://github.com/lua/lua/commit/becf19feeffeb0bf2297e163da4ccc7b4b5e6b5c --- src/blua/ldebug.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/blua/ldebug.c b/src/blua/ldebug.c index 542e209a1..e209fae5d 100644 --- a/src/blua/ldebug.c +++ b/src/blua/ldebug.c @@ -542,16 +542,39 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos, static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { + TMS tm = 0; Instruction i; if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1)) return NULL; /* calling function is not Lua (or is unknown) */ ci--; /* calling function */ i = ci_func(ci)->l.p->code[currentpc(L, ci)]; - if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL || - GET_OPCODE(i) == OP_TFORLOOP) - return getobjname(L, ci, GETARG_A(i), name); - else - return NULL; /* no useful name can be found */ + switch (GET_OPCODE(i)) { + case OP_CALL: + case OP_TAILCALL: + case OP_TFORLOOP: + return getobjname(L, ci, GETARG_A(i), name); + case OP_GETGLOBAL: + case OP_SELF: + case OP_GETTABLE: tm = TM_INDEX; break; + case OP_SETGLOBAL: + case OP_SETTABLE: tm = TM_NEWINDEX; break; + case OP_EQ: tm = TM_EQ; break; + case OP_ADD: tm = TM_ADD; break; + case OP_SUB: tm = TM_SUB; break; + case OP_MUL: tm = TM_MUL; break; + case OP_DIV: tm = TM_DIV; break; + case OP_MOD: tm = TM_MOD; break; + case OP_POW: tm = TM_POW; break; + case OP_UNM: tm = TM_UNM; break; + case OP_LEN: tm = TM_LEN; break; + case OP_LT: tm = TM_LT; break; + case OP_LE: tm = TM_LE; break; + case OP_CONCAT: tm = TM_CONCAT; break; + default: + return NULL; /* else no useful name can be found */ + } + *name = getstr(G(L)->tmname[tm]); + return "metamethod"; } From 90b5f9050adaa97bf2bc20637dc4f2f5fee62c1c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 16:41:42 +0100 Subject: [PATCH 205/589] Blua: small optimization in luaL_addlstring (avoid adding chars one by one) https://github.com/lua/lua/commit/f292760f12022a83cf01e788482a264aeeb3c276 --- src/blua/lauxlib.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/blua/lauxlib.c b/src/blua/lauxlib.c index 5fb454d5e..51605eaf1 100644 --- a/src/blua/lauxlib.c +++ b/src/blua/lauxlib.c @@ -20,6 +20,7 @@ #define lauxlib_c #define LUA_LIB +#include "ldebug.h" #include "lua.h" #include "lauxlib.h" @@ -468,8 +469,19 @@ LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) { LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { - while (l--) - luaL_addchar(B, *s++); + while (l) { + size_t space = bufffree(B); + if (space == 0) { + luaL_prepbuffer(B); + lua_assert(bufffree(B) == LUAL_BUFFERSIZE); + space = LUAL_BUFFERSIZE; + } + if (space > l) space = l; + memcpy(B->p, s, space); + B->p += space; + s += space; + l -= space; + } } From 43608810da4feed212444d33b6eca83a34a756d9 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 11 Feb 2026 13:44:18 +0100 Subject: [PATCH 206/589] lua branching hint stuff rechecked against lua 5.4 --- src/blua/lauxlib.c | 2 +- src/blua/ldo.c | 4 ++-- src/blua/lstring.c | 4 ++-- src/blua/lvm.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/blua/lauxlib.c b/src/blua/lauxlib.c index 51605eaf1..05a115002 100644 --- a/src/blua/lauxlib.c +++ b/src/blua/lauxlib.c @@ -698,6 +698,6 @@ static int panic (lua_State *L) { LUALIB_API lua_State *luaL_newstate (void) { lua_State *L = lua_newstate(l_alloc, NULL); - if (L) lua_atpanic(L, &panic); + if (l_likely(L)) lua_atpanic(L, &panic); return L; } diff --git a/src/blua/ldo.c b/src/blua/ldo.c index c573dab17..1bda07f11 100644 --- a/src/blua/ldo.c +++ b/src/blua/ldo.c @@ -164,7 +164,7 @@ void luaD_reallocCI (lua_State *L, int newsize) { void luaD_growstack (lua_State *L, int n) { - if (l_likely(n <= L->stacksize)) /* double size is enough? */ + if (n <= L->stacksize) /* double size is enough? */ luaD_reallocstack(L, 2*L->stacksize); else luaD_reallocstack(L, L->stacksize + n); @@ -318,7 +318,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { ci->top = L->top + LUA_MINSTACK; lua_assert(ci->top <= L->stack_last); ci->nresults = nresults; - if (L->hookmask & LUA_MASKCALL) + if (l_unlikely(L->hookmask & LUA_MASKCALL)) luaD_callhook(L, LUA_HOOKCALL, -1); lua_unlock(L); n = (*curr_func(L)->c.f)(L); /* do the actual call */ diff --git a/src/blua/lstring.c b/src/blua/lstring.c index 0bcc30877..44086dd28 100644 --- a/src/blua/lstring.c +++ b/src/blua/lstring.c @@ -51,7 +51,7 @@ static TString *newlstr (lua_State *L, const char *str, size_t l, unsigned int h) { TString *ts; stringtable *tb; - if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)) + if (l_unlikely(l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char))) luaM_toobig(L); ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString))); ts->tsv.len = l; @@ -83,7 +83,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { o != NULL; o = o->gch.next) { TString *ts = rawgco2ts(o); - if (l_unlikely(ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0))) { + if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { /* string may be dead */ if (isdead(G(L), o)) changewhite(o); return ts; diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 02d2265c1..00e345478 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -28,7 +28,7 @@ -/* limit for table tag-method chains (to avoid loops) */ +/* limit for table tag-method chains (to avoid infinite loops) */ #define MAXTAGLOOP 100 From 9afc018a45ef24927fa39da303353038cb122340 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Mar 2026 18:58:05 +0100 Subject: [PATCH 207/589] Avoid computing invalid addresses luaV_execute should compute 'ra' only when the instruction uses it. Computing an illegal address is undefined behavior even if the address is never dereferenced. --- src/blua/lvm.c | 62 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 15 deletions(-) diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 00e345478..7afbbd572 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -366,6 +366,7 @@ static void Arith (lua_State *L, StkId ra, TValue *rb, #define arith_op(op,tm) { \ + StkId ra = RA(i); \ TValue *rb = RKB(i); \ TValue *rc = RKC(i); \ if (ttisnumber(rb) && ttisnumber(rc)) { \ @@ -392,7 +393,6 @@ void luaV_execute (lua_State *L, int nexeccalls) { /* main loop of interpreter */ for (;;) { const Instruction i = *pc++; - StkId ra; if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) && (--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) { traceexec(L, pc); @@ -402,26 +402,28 @@ void luaV_execute (lua_State *L, int nexeccalls) { } base = L->base; } - /* warning!! several calls may realloc the stack and invalidate `ra' */ - ra = RA(i); lua_assert(base == L->base && L->base == L->ci->base); lua_assert(base <= L->top && L->top <= L->stack + L->stacksize); lua_assert(L->top == L->ci->top || luaG_checkopenop(i)); switch (GET_OPCODE(i)) { case OP_MOVE: { + StkId ra = RA(i); setobjs2s(L, ra, RB(i)); continue; } case OP_LOADK: { + StkId ra = RA(i); setobj2s(L, ra, KBx(i)); continue; } case OP_LOADBOOL: { + StkId ra = RA(i); setbvalue(ra, GETARG_B(i)); if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ continue; } case OP_LOADNIL: { + StkId ra = RA(i); TValue *rb = RB(i); do { setnilvalue(rb--); @@ -429,11 +431,13 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_GETUPVAL: { + StkId ra = RA(i); int b = GETARG_B(i); setobj2s(L, ra, cl->upvals[b]->v); continue; } case OP_GETGLOBAL: { + StkId ra = RA(i); TValue g; TValue *rb = KBx(i); sethvalue(L, &g, cl->env); @@ -442,10 +446,14 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_GETTABLE: { - Protect(luaV_gettable(L, RB(i), RKC(i), ra)); + StkId ra = RA(i); + StkId rb = RB(i); + TValue *rc = RKC(i); + Protect(luaV_gettable(L, rb, rc, ra)); continue; } case OP_SETGLOBAL: { + StkId ra = RA(i); TValue g; sethvalue(L, &g, cl->env); lua_assert(ttisstring(KBx(i))); @@ -453,16 +461,21 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_SETUPVAL: { + StkId ra = RA(i); UpVal *uv = cl->upvals[GETARG_B(i)]; setobj(L, uv->v, ra); luaC_barrier(L, uv, ra); continue; } case OP_SETTABLE: { - Protect(luaV_settable(L, ra, RKB(i), RKC(i))); + StkId ra = RA(i); + TValue *rb = RKB(i); + TValue *rc = RKC(i); + Protect(luaV_settable(L, ra, rb, rc)); continue; } case OP_NEWTABLE: { + StkId ra = RA(i); int b = GETARG_B(i); int c = GETARG_C(i); sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c))); @@ -470,6 +483,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_SELF: { + StkId ra = RA(i); StkId rb = RB(i); setobjs2s(L, ra+1, rb); Protect(luaV_gettable(L, rb, RKC(i), ra)); @@ -488,6 +502,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_DIV: { + StkId ra = RA(i); TValue *rb = RKB(i); TValue *rc = RKC(i); if (ttisnumber(rb) && ttisnumber(rc)) { @@ -503,6 +518,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_MOD: { + StkId ra = RA(i); TValue *rb = RKB(i); TValue *rc = RKC(i); if (ttisnumber(rb) && ttisnumber(rc)) { @@ -522,26 +538,27 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_BAND: { - arith_op(luai_numand, TM_AND); - continue; + arith_op(luai_numand, TM_AND); + continue; } case OP_BOR: { - arith_op(luai_numor, TM_OR); - continue; + arith_op(luai_numor, TM_OR); + continue; } case OP_BXOR: { - arith_op(luai_numxor, TM_XOR); - continue; + arith_op(luai_numxor, TM_XOR); + continue; } case OP_BSHL: { - arith_op(luai_numshl, TM_SHL); - continue; + arith_op(luai_numshl, TM_SHL); + continue; } case OP_BSHR: { - arith_op(luai_numshr, TM_SHR); - continue; + arith_op(luai_numshr, TM_SHR); + continue; } case OP_BNOT: { + StkId ra = RA(i); TValue *rb = RB(i); if (ttisnumber(rb)) { lua_Number nb = nvalue(rb); @@ -553,6 +570,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_UNM: { + StkId ra = RA(i); TValue *rb = RB(i); if (ttisnumber(rb)) { lua_Number nb = nvalue(rb); @@ -564,11 +582,13 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_NOT: { + StkId ra = RA(i); int res = l_isfalse(RB(i)); /* next assignment may change this value */ setbvalue(ra, res); continue; } case OP_LEN: { + StkId ra = RA(i); TValue *rb = RB(i); switch (ttype(rb)) { case LUA_TTABLE: { @@ -626,12 +646,14 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_TEST: { + StkId ra = RA(i); if (l_isfalse(ra) != GETARG_C(i)) dojump(L, pc, GETARG_sBx(*pc)); pc++; continue; } case OP_TESTSET: { + StkId ra = RA(i); TValue *rb = RB(i); if (l_isfalse(rb) != GETARG_C(i)) { setobjs2s(L, ra, rb); @@ -641,6 +663,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_CALL: { + StkId ra = RA(i); int b = GETARG_B(i); int nresults = GETARG_C(i) - 1; if (b != 0) L->top = ra+b; /* else previous instruction set top */ @@ -662,6 +685,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { } } case OP_TAILCALL: { + StkId ra = RA(i); int b = GETARG_B(i); if (b != 0) L->top = ra+b; /* else previous instruction set top */ L->savedpc = pc; @@ -694,6 +718,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { } } case OP_RETURN: { + StkId ra = RA(i); int b = GETARG_B(i); if (b != 0) L->top = ra+b-1; if (L->openupval) luaF_close(L, base); @@ -709,6 +734,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { } } case OP_FORLOOP: { + StkId ra = RA(i); lua_Number step = nvalue(ra+2); lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ lua_Number limit = nvalue(ra+1); @@ -721,6 +747,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_FORPREP: { + StkId ra = RA(i); const TValue *init = ra; const TValue *plimit = ra+1; const TValue *pstep = ra+2; @@ -737,6 +764,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_TFORLOOP: { + StkId ra = RA(i); StkId cb = ra + 3; /* call base */ setobjs2s(L, cb+2, ra+2); setobjs2s(L, cb+1, ra+1); @@ -753,6 +781,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_SETLIST: { + StkId ra = RA(i); int n = GETARG_B(i); int c = GETARG_C(i); int last; @@ -775,10 +804,12 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_CLOSE: { + StkId ra = RA(i); luaF_close(L, ra); continue; } case OP_CLOSURE: { + StkId ra = RA(i); Proto *p; Closure *ncl; int nup, j; @@ -799,6 +830,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_VARARG: { + StkId ra = RA(i); int b = GETARG_B(i) - 1; int j; CallInfo *ci = L->ci; From 966f60f590ffcfb62793d2298c6759fbd6f44f5c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 11 Feb 2026 17:02:20 +0100 Subject: [PATCH 208/589] =?UTF-8?q?Experiment:=20replace=20lua=C2=B4s=20st?= =?UTF-8?q?ring=20hash=20with=20luajits=20ARX=20hash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the string hashing was the most hit and most spent in part of the whole game in alot of cases replacing it with luajits algo absolutely massively improves lua performance (10-15fps in my bench timedemos!) however idk how all this stuff exactly works so this needs alot of testing to make sure nothing breaks ive rewritten the unaligned ptr access slightly to use memcpy for safety with some platforms that require stricter alignment --- src/blua/lstring.c | 54 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/src/blua/lstring.c b/src/blua/lstring.c index 44086dd28..a826ae32f 100644 --- a/src/blua/lstring.c +++ b/src/blua/lstring.c @@ -72,13 +72,63 @@ static TString *newlstr (lua_State *L, const char *str, size_t l, } -TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { - GCObject *o; +// string hash taken from luaJIT + +/* Unaligned load of uint32_t. */ +static inline __attribute__((always_inline)) uint32_t getu32(const void* ptr) +{ + uint32_t result; + memcpy(&result, ptr, 4); + return result; +} + +// smol macro to look a little less messy lul +#define getu8(p) *cast(const uint8_t *, p) + +/* Keyed sparse ARX string hash. Constant time. */ +static unsigned hash_sparse(const char *str, size_t len) +{ + /* Constants taken from lookup3 hash by Bob Jenkins. */ + unsigned int a, b, h = cast(unsigned int, len); +#define rol(x, n) (((x)<<(n)) | ((x)>>(-cast(int, n)&(8*sizeof(x)-1)))) + if (len >= 4) { /* Caveat: unaligned access! */ + a = getu32(str); + h ^= getu32(str+len-4); + b = getu32(str+(len>>1)-2); + h ^= b; h -= rol(b, 14); + b += getu32(str+(len>>2)-1); + } else { + a = getu8(str); + h ^= getu8(str+len-1); + b = getu8(str+(len>>1)); + h ^= b; h -= rol(b, 14); + } + a ^= h; a -= rol(h, 11); + b ^= a; b -= rol(a, 25); + h ^= b; h -= rol(b, 16); +#undef rol + return h; +} + +#undef getu8 + + +static inline __attribute__((always_inline)) unsigned luaS_hash (const char *str, size_t l) { +#if 0 unsigned int h = cast(unsigned int, l); /* seed */ size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */ size_t l1; for (l1=l; l1>=step; l1-=step) /* compute hash */ h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1])); + return h; +#else + return hash_sparse(str, l); +#endif +} + +TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { + GCObject *o; + unsigned int h = luaS_hash(str, l); for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)]; o != NULL; o = o->gch.next) { From f6ead71f0ca6da4ee92987740edce4b2450bcced Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 21 Feb 2026 23:12:44 +0100 Subject: [PATCH 209/589] blua: handle 0 length strings in hash_sparse --- src/blua/lstring.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/blua/lstring.c b/src/blua/lstring.c index a826ae32f..b2d7306e5 100644 --- a/src/blua/lstring.c +++ b/src/blua/lstring.c @@ -90,6 +90,9 @@ static unsigned hash_sparse(const char *str, size_t len) { /* Constants taken from lookup3 hash by Bob Jenkins. */ unsigned int a, b, h = cast(unsigned int, len); + + if (len == 0) return 0; + #define rol(x, n) (((x)<<(n)) | ((x)>>(-cast(int, n)&(8*sizeof(x)-1)))) if (len >= 4) { /* Caveat: unaligned access! */ a = getu32(str); From 1a4255d9df4088ebf73686fd18fe56162e2c7567 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Feb 2026 01:06:15 +0100 Subject: [PATCH 210/589] luaS_newlstr: use hash also for checking strings taken from raptorjit we can check the hash first to skip quite a bunch of memcmps which should be faster in most cases (hopefully but quick timedemo tests confirmed that) --- src/blua/lstring.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/blua/lstring.c b/src/blua/lstring.c index b2d7306e5..a84de4b08 100644 --- a/src/blua/lstring.c +++ b/src/blua/lstring.c @@ -90,9 +90,7 @@ static unsigned hash_sparse(const char *str, size_t len) { /* Constants taken from lookup3 hash by Bob Jenkins. */ unsigned int a, b, h = cast(unsigned int, len); - if (len == 0) return 0; - #define rol(x, n) (((x)<<(n)) | ((x)>>(-cast(int, n)&(8*sizeof(x)-1)))) if (len >= 4) { /* Caveat: unaligned access! */ a = getu32(str); @@ -136,7 +134,9 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { o != NULL; o = o->gch.next) { TString *ts = rawgco2ts(o); - if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) { + if (ts->tsv.hash == h && + ts->tsv.len == l && + (memcmp(str, getstr(ts), l) == 0)) { /* string may be dead */ if (isdead(G(L), o)) changewhite(o); return ts; From fed7020da179658edb27d8969c25661fc6b103c2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Feb 2026 14:03:50 +0100 Subject: [PATCH 211/589] hash_sparse: change length checks dont early return on 0 len, let it be the falltrough case, this seems to help branch prediction --- src/blua/lstring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/blua/lstring.c b/src/blua/lstring.c index a84de4b08..b1249238b 100644 --- a/src/blua/lstring.c +++ b/src/blua/lstring.c @@ -90,7 +90,6 @@ static unsigned hash_sparse(const char *str, size_t len) { /* Constants taken from lookup3 hash by Bob Jenkins. */ unsigned int a, b, h = cast(unsigned int, len); - if (len == 0) return 0; #define rol(x, n) (((x)<<(n)) | ((x)>>(-cast(int, n)&(8*sizeof(x)-1)))) if (len >= 4) { /* Caveat: unaligned access! */ a = getu32(str); @@ -98,11 +97,13 @@ static unsigned hash_sparse(const char *str, size_t len) b = getu32(str+(len>>1)-2); h ^= b; h -= rol(b, 14); b += getu32(str+(len>>2)-1); - } else { + } else if (len > 0) { a = getu8(str); h ^= getu8(str+len-1); b = getu8(str+(len>>1)); h ^= b; h -= rol(b, 14); + } else { + return 0; } a ^= h; a -= rol(h, 11); b ^= a; b -= rol(a, 25); From c7845118c00e6364945d397675afbfb1f21a2d43 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 25 Jan 2026 13:22:56 +0100 Subject: [PATCH 212/589] explicitly cast those --- src/hardware/hw_main.cpp | 15 +++++++-------- src/r_things.cpp | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index bf11f0c7c..0806d05c8 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3681,7 +3681,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) //Hurdler: 25/04/2000: now support colormap in hardware mode HWR_GetMappedPatch(gpatch, spr->colormap); - hwrpatch = ((GLPatch_t *)gpatch->hardware); + hwrpatch = static_cast(gpatch->hardware); // Draw shadow BEFORE sprite if (UNLIKELY(cv_shadow.value // Shadows enabled @@ -3783,10 +3783,10 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) { // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0) - Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + Surf.PolyColor.s.alpha = static_cast(FixedMul(FRACUNIT/2, static_cast(Surf.PolyColor.s.alpha))); if (cv_playerfade.value) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + Surf.PolyColor.s.alpha = static_cast(FixedMul(R_DoPlayerFade(sprmo), static_cast(Surf.PolyColor.s.alpha))); } if (HWR_UseShader()) @@ -3969,7 +3969,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) //Hurdler: 25/04/2000: now support colormap in hardware mode HWR_GetMappedPatch(gpatch, spr->colormap); - hwrpatch = ((GLPatch_t *)gpatch->hardware); + hwrpatch = static_cast(gpatch->hardware); // create the sprite billboard // @@ -4080,10 +4080,10 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) { // make hyu´d players translucent with reducevfx, could be done better, but im lazy as crap if (cv_reducevfx.value && sprmo->player->kartstuff[k_hyudorotimer] > 0) - Surf.PolyColor.s.alpha = FixedMul(FRACUNIT/2, Surf.PolyColor.s.alpha); + Surf.PolyColor.s.alpha = static_cast(FixedMul(FRACUNIT/2, static_cast(Surf.PolyColor.s.alpha))); if (cv_playerfade.value) - Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(sprmo), Surf.PolyColor.s.alpha); + Surf.PolyColor.s.alpha = static_cast(FixedMul(R_DoPlayerFade(sprmo), static_cast(Surf.PolyColor.s.alpha))); } if (HWR_UseShader()) @@ -4119,7 +4119,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) //Hurdler: 25/04/2000: now support colormap in hardware mode HWR_GetMappedPatch(gpatch, spr->colormap); - hwrpatch = ((GLPatch_t *)gpatch->hardware); + hwrpatch = static_cast(gpatch->hardware); // create the sprite billboard // @@ -4510,7 +4510,6 @@ static void HWR_RenderDrawNodes(void) drawnodes.clear(); // clear so our size is 0 again! } - // -------------------------------------------------------------------------- // Draw all vissprites // -------------------------------------------------------------------------- diff --git a/src/r_things.cpp b/src/r_things.cpp index 9da1f4c3e..310896a68 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1662,7 +1662,7 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->frame & FF_ABSOLUTELIGHTLEVEL) { - const UINT8 n = R_ThingLightLevel(thing); + const UINT8 n = static_cast(R_ThingLightLevel(thing)); // n = uint8 aka 0 - 255, so the shift will always be 0 - LIGHTLEVELS - 1 lights_array = scalelight[n >> LIGHTSEGSHIFT]; } From d6ed923f831e517f6ad33419ae6e44eac6b6a18b Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 10 Feb 2026 16:43:34 +0100 Subject: [PATCH 213/589] P_XYMovement: check for kart specific stuff first to determine friction apply this stuff is much more common than the other stuff being checked, so more likely to return earlier and save a bunch of other checks --- src/p_mobj.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index d44a48f1c..01b3977d0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1670,6 +1670,14 @@ void P_XYMovement(mobj_t *mo) if (mo->flags & MF_NOCLIPHEIGHT) return; // no frictions for objects that can pass through floors + //{ SRB2kart stuff + if (mo->type == MT_ORBINAUT || mo->type == MT_JAWZ_DUD || mo->type == MT_JAWZ || mo->type == MT_BALLHOG) //(mo->type == MT_JAWZ && !mo->tracer)) + return; + + if (mo->player && (mo->player->kartstuff[k_spinouttimer] && !mo->player->kartstuff[k_wipeoutslow]) && mo->player->speed <= K_GetKartSpeed(mo->player, false)/2) + return; + //} + if (mo->flags & MF_MISSILE || mo->flags2 & MF2_SKULLFLY || mo->type == MT_SHELL || mo->type == MT_VULTURE) return; // no friction for missiles ever @@ -1683,14 +1691,6 @@ void P_XYMovement(mobj_t *mo) && (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8)) // Special exception for tumbleweeds on slopes return; - //{ SRB2kart stuff - if (mo->type == MT_ORBINAUT || mo->type == MT_JAWZ_DUD || mo->type == MT_JAWZ || mo->type == MT_BALLHOG) //(mo->type == MT_JAWZ && !mo->tracer)) - return; - - if (mo->player && (mo->player->kartstuff[k_spinouttimer] && !mo->player->kartstuff[k_wipeoutslow]) && mo->player->speed <= K_GetKartSpeed(mo->player, false)/2) - return; - //} - if (((!(mo->eflags & MFE_VERTICALFLIP) && mo->z > mo->floorz) || (mo->eflags & MFE_VERTICALFLIP && mo->z+mo->height < mo->ceilingz)) && !(player && player->pflags & PF_SLIDING)) return; // no friction when airborne From 04f63b23ffe1c6a47ef82a707f3f23f080ab1b69 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 4 Feb 2026 13:02:27 +0100 Subject: [PATCH 214/589] software: hack for bogus height walls as per comment, this is merely a shitty workaround for a chain reaction of bad fixed point maths since im honestly not feeling like rewriting most of the software renderer to either operate on 64bit or float maths, we just skip drawing anything that seems completely unreasonable --- src/r_segs.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 660b91494..a53d40ec4 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1222,6 +1222,15 @@ static void R_RenderSegLoop(drawcolumndata_t* dc) if (yl < top) yl = top; + // insanely shitty hack to fix flickering on some maps + // for god knows why, on secret slide the renderer assumes some double sided linedefs have insanely tall walls + // since such tall walls are effectively nonsense in any case + // just skip them + if (yl > FRACUNIT*3) + { + continue; + } + if (markceiling) { bottom = yl > floorclip[rw_x] ? floorclip[rw_x] : yl; From 1aa37be676f67307f755bd4fc2dcae3c2cf55e55 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 10 Feb 2026 16:41:46 +0100 Subject: [PATCH 215/589] p_user: cache kartspeed value within P_3dMovement its result shouldnt change there, so no need to always recompute stuff, even if its not heavy work --- src/p_user.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 99566aa24..7c4756bfa 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1992,20 +1992,23 @@ static void P_3dMovement(player_t *player) K_MomentumToFacing(player); } + const fixed_t kartspd = K_GetKartSpeed(player, true); + // Sideways movement if (cmd->sidemove != 0 && !((player->exiting || mapreset) || player->kartstuff[k_spinouttimer])) { if (cmd->sidemove > 0) - movepushside = (cmd->sidemove * FRACUNIT/128) + FixedDiv(player->speed, K_GetKartSpeed(player, true)); + movepushside = (cmd->sidemove * FRACUNIT/128) + FixedDiv(player->speed, kartspd); else - movepushside = (cmd->sidemove * FRACUNIT/128) - FixedDiv(player->speed, K_GetKartSpeed(player, true)); + movepushside = (cmd->sidemove * FRACUNIT/128) - FixedDiv(player->speed, kartspd); totalthrust.x += P_ReturnThrustX(player->mo, movepushsideangle, movepushside); totalthrust.y += P_ReturnThrustY(player->mo, movepushsideangle, movepushside); } if ((totalthrust.x || totalthrust.y) - && player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && abs(player->mo->standingslope->zdelta) > FRACUNIT/2) { + && player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && abs(player->mo->standingslope->zdelta) > FRACUNIT/2) + { // Factor thrust to slope, but only for the part pushing up it! // The rest is unaffected. angle_t thrustangle = R_PointToAngle2(0, 0, totalthrust.x, totalthrust.y)-player->mo->standingslope->xydirection; @@ -2041,11 +2044,11 @@ static void P_3dMovement(player_t *player) // -Shadow Hog newMagnitude = R_PointToDist2(player->mo->momx - player->cmomx, player->mo->momy - player->cmomy, 0, 0); - if (newMagnitude > K_GetKartSpeed(player, true)) //topspeed) + if (newMagnitude > kartspd) //topspeed) { fixed_t tempmomx, tempmomy; - if (oldMagnitude > K_GetKartSpeed(player, true) && onground) // SRB2Kart: onground check for air speed cap + if (oldMagnitude > kartspd && onground) // SRB2Kart: onground check for air speed cap { if (newMagnitude > oldMagnitude) { @@ -2058,8 +2061,8 @@ static void P_3dMovement(player_t *player) } else { - tempmomx = FixedMul(FixedDiv(player->mo->momx - player->cmomx, newMagnitude), K_GetKartSpeed(player, true)); //topspeed) - tempmomy = FixedMul(FixedDiv(player->mo->momy - player->cmomy, newMagnitude), K_GetKartSpeed(player, true)); //topspeed) + tempmomx = FixedMul(FixedDiv(player->mo->momx - player->cmomx, newMagnitude), kartspd); //topspeed) + tempmomy = FixedMul(FixedDiv(player->mo->momy - player->cmomy, newMagnitude), kartspd); //topspeed) player->mo->momx = tempmomx + player->cmomx; player->mo->momy = tempmomy + player->cmomy; } @@ -2474,9 +2477,10 @@ static void P_MovePlayer(player_t *player) const fixed_t runnyspeed = 20*FRACUNIT; speed = R_PointToDist2(player->rmomx, player->rmomy, 0, 0); + const fixed_t kartspd = K_GetKartSpeed(player, false); - if (speed > K_GetKartSpeed(player, false)-(5< kartspd-(5<= runnyspeed) player->fovadd = speed-runnyspeed; @@ -4584,7 +4588,7 @@ void P_PlayerThink(player_t *player) } #ifdef SEENAMES - if (netgame && player == &players[displayplayers[0]] && !(leveltime % (TICRATE/5)) && !splitscreen) + if (netgame && !splitscreen && player == &players[displayplayers[0]] && !(leveltime % (TICRATE/5))) { seenplayer = NULL; From 9087fd8377ee2e8947aef59fa43741055b4d76dd Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 26 Jan 2026 17:30:09 +0100 Subject: [PATCH 216/589] lua hooklib: use NUMMOBJTYPES to detect mobj hooks removes the "force_mobj" field, gives a suprising perf boost from my timedemo testing +6-7fps (164 - 169/170fps) this does however will prevent the generic hook from being called if the mobj being passed ever should be NULL This shouldnt ever happen, vanilla assumes this aswell and way worse things would happen there, but just wanted to note --- src/lua_hooklib.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 59d1bc1f8..af15120ba 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -199,7 +199,7 @@ FUNCINLINE static ATTRINLINE void add_hook(hook_t *map) FUNCINLINE static ATTRINLINE void add_mobj_hook(lua_State *L, int hook_type) { - mobjtype_t mobj_type = luaL_optnumber(L, 3, MT_NULL); + mobjtype_t mobj_type = luaL_optnumber(L, 3, MT_NULL); luaL_argcheck(L, mobj_type < NUMMOBJTYPES, 3, "invalid mobjtype_t"); @@ -296,8 +296,7 @@ struct Hook_State { INT32 status;/* return status to calling function */ void * userdata; int hook_type; - mobjtype_t mobj_type;/* >0 if mobj hook */ - boolean force_mobj;// allows mobj_type equal 0 + mobjtype_t mobj_type;/* force_mobj = false; - return init_hook_type(hook, default_status, - hook_type, 0, NULL, + hook_type, NUMMOBJTYPES, NULL, hookIds[hook_type].numHooks); } @@ -381,8 +378,6 @@ FUNCINLINE static ATTRINLINE boolean prepare_mobj_hook const mobjtype_t mobj_type = primary_mobj ? primary_mobj->type : NUMMOBJTYPES; - hook->force_mobj = true; - return init_hook_type(hook, default_status, hook_type, mobj_type, NULL, mobj_hook_available(hook_type, mobj_type)); @@ -395,10 +390,8 @@ FUNCINLINE static ATTRINLINE boolean prepare_string_hook int hook_type, const char * string ){ - hook->force_mobj = false; - if (init_hook_type(hook, default_status, - hook_type, 0, string, + hook_type, NUMMOBJTYPES, string, stringHooks[hook_type].ref)) { lua_pushstring(gL, string); @@ -414,7 +407,7 @@ FUNCINLINE static ATTRINLINE boolean prepare_hud_hook int hook_type ){ return init_hook_type(hook, 0, - hook_type, 0, NULL, + hook_type, NUMMOBJTYPES, NULL, hudHookIds[hook_type].numHooks); } @@ -554,14 +547,11 @@ static int call_hooks { calls += call_string_hooks(hook); } - else if (hook->force_mobj) + else if (hook->mobj_type < NUMMOBJTYPES) { /* call generic mobj hooks first */ calls += call_mobj_type_hooks(hook, MT_NULL); - - if (hook->mobj_type < NUMMOBJTYPES) - calls += call_mobj_type_hooks(hook, hook->mobj_type); - + calls += call_mobj_type_hooks(hook, hook->mobj_type); ps_lua_mobjhooks.value.i += calls; } else From e4e51f0f80fb7deb9213c72bb374d0a7e4c3f03b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 18:05:51 +0100 Subject: [PATCH 217/589] Blua: implementation of fast track for gettable operations https://github.com/lua/lua/commit/e247c3ada3ff47a1352927e797263137f4e02e0e lets hope i converted this properly lul --- src/blua/lapi.c | 26 ++++++++++++++++++-------- src/blua/lvm.c | 39 ++++++++++++++++++++------------------- src/blua/lvm.h | 27 +++++++++++++++++++++++++-- 3 files changed, 63 insertions(+), 29 deletions(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index 6a33983fe..990e17b6e 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -519,6 +519,23 @@ LUA_API int lua_pushthread (lua_State *L) { ** get functions (Lua -> stack) */ +static void auxgetstr (lua_State *L, TValue *t, const char *k) { + TValue *aux; + TValue key; + TString *str = luaS_new(L, k); + api_checkvalidindex(L, t); + if (luaV_fastget(L, t, str, aux, luaH_getstr)) { + setobj2s(L, L->top, aux); + api_incr_top(L); + } + else { + setsvalue(L, &key, str); + luaV_finishget(L, t, L->top, L->top, aux); + api_incr_top(L); + } + lua_unlock(L); +} + LUA_API void lua_gettable (lua_State *L, int idx) { StkId t; @@ -531,15 +548,8 @@ LUA_API void lua_gettable (lua_State *L, int idx) { LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { - StkId t; - TValue key; lua_lock(L); - t = index2adr(L, idx); - api_checkvalidindex(L, t); - setsvalue(L, &key, luaS_new(L, k)); - luaV_gettable(L, t, &key, L->top); - api_incr_top(L); - lua_unlock(L); + auxgetstr(L, index2adr(L, idx), k); } diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 7afbbd572..64e670d2f 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -105,32 +105,33 @@ static void callTM (lua_State *L, const TValue *f, const TValue *p1, } -void luaV_gettable (lua_State *L, TValue *t, TValue *key, StkId val) { - int loop; +/* +** Complete a table access: if 't' is a table, 'tm' has its metamethod; +** otherwise, 'tm' is NULL. +*/ +void luaV_finishget (lua_State *L, TValue *t, TValue *key, StkId val, + TValue *tm) { + int loop; /* counter to avoid infinite loops */ + lua_assert(tm != NULL || !ttistable(t)); for (loop = 0; loop < MAXTAGLOOP; loop++) { - TValue *tm; - if (ttistable(t)) { /* `t' is a table? */ - Table *h = hvalue(t); - const TValue *res = luaH_get(h, key); /* do a primitive get */ - if (!ttisnil(res) || /* result is no nil? */ - (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ - setobj2s(L, val, res); - return; - } - /* else will try the tag method */ + if (tm == NULL) { /* no metamethod (from a table)? */ + if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))) + luaG_typeerror(L, t, "index"); /* no metamethod */ } - else if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))) - luaG_typeerror(L, t, "index"); - if (ttisfunction(tm)) { - callTMres(L, val, tm, t, key); + if (ttisfunction(tm)) { /* metamethod is a function */ + callTMres(L, val, tm, t, key); /* call it */ return; } - t = tm; /* else repeat with `tm' */ + t = tm; /* else repeat access over 'tm' */ + if (luaV_fastget(L,t,key,tm,luaH_get)) { /* try fast track */ + setobj2s(L, val, tm); /* done */ + return; + } + /* else repeat */ } - luaG_runerror(L, "loop in gettable"); + luaG_runerror(L, "gettable chain too long; possible loop"); } - void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val) { int loop; for (loop = 0; loop < MAXTAGLOOP; loop++) { diff --git a/src/blua/lvm.h b/src/blua/lvm.h index f9226ee5d..2ffc80ace 100644 --- a/src/blua/lvm.h +++ b/src/blua/lvm.h @@ -22,12 +22,35 @@ (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) +/* +** fast track for 'gettable': 1 means 'aux' points to resulted value; +** 0 means 'aux' is metamethod (if 't' is a table) or NULL. 'f' is +** the raw get function to use. +*/ +#define luaV_fastget(L,t,k,aux,f) \ + (!ttistable(t) \ + ? (aux = NULL, 0) /* not a table; 'aux' is NULL and result is 0 */ \ + : (aux = f(hvalue(t), k), /* else, do raw access */ \ + !ttisnil(aux) ? 1 /* result not nil? 'aux' has it */ \ + : (aux = fasttm(L, hvalue(t)->metatable, TM_INDEX), /* get metamethod */\ + aux != NULL ? 0 /* has metamethod? must call it */ \ + : (aux = luaO_nilobject, 1)))) /* else, final result is nil */ + +/* +** standard implementation for 'gettable' +*/ +#define luaV_gettable(L,t,k,v) { TValue *aux; \ + if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ + else luaV_finishget(L,t,k,v,aux); } + + + LUAI_FUNC int luaV_lessthan (lua_State *L, TValue *l, TValue *r); LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); -LUAI_FUNC void luaV_gettable (lua_State *L, TValue *t, TValue *key, - StkId val); +LUAI_FUNC void luaV_finishget (lua_State *L, TValue *t, TValue *key, + StkId val, TValue *tm); LUAI_FUNC void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val); LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); From 84be9096b134e1f8d17b5f444ee4c516943f4beb Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 19:00:29 +0100 Subject: [PATCH 218/589] Blua: fast track for 'settable' https://github.com/lua/lua/commit/3b795541c488c7e633567897c9112312007a20a0 https://github.com/lua/lua/commit/b91bc93fd33f2158745b37c9e091c6fa4d1a4fd5 had to adjust some things, hope this doesent explode lmao --- src/blua/lapi.c | 29 ++++++++++++++++++++--------- src/blua/lvm.c | 36 +++++++++++++++++++++++++----------- src/blua/lvm.h | 30 ++++++++++++++++++++++++++++-- 3 files changed, 73 insertions(+), 22 deletions(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index 990e17b6e..420e4e20b 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -641,6 +641,25 @@ LUA_API void lua_getfenv (lua_State *L, int idx) { */ +static void auxsetstr (lua_State *L, TValue *t, const char *k) { + TValue key; + TValue *aux; + TString *str = luaS_new(L, k); + api_checknelems(L, 1); + api_checkvalidindex(L, t); + if (luaV_fastset(L, t, str, aux, luaH_setstr, L->top)) { + setobj2t(L, cast(TValue *, aux), L->top - 1); + L->top--; /* pop value */ + } + else { + setsvalue2s(L, &key, str); + luaV_finishset(L, t, &key, L->top - 1, aux); + L->top--; /* pop value */ + } + lua_unlock(L); +} + + LUA_API void lua_settable (lua_State *L, int idx) { StkId t; lua_lock(L); @@ -654,16 +673,8 @@ LUA_API void lua_settable (lua_State *L, int idx) { LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { - StkId t; - TValue key; lua_lock(L); - api_checknelems(L, 1); - t = index2adr(L, idx); - api_checkvalidindex(L, t); - setsvalue(L, &key, luaS_new(L, k)); - luaV_settable(L, t, &key, L->top - 1); - L->top--; /* pop value */ - lua_unlock(L); + auxsetstr(L, index2adr(L, idx), k); } diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 64e670d2f..484329825 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -132,31 +132,45 @@ void luaV_finishget (lua_State *L, TValue *t, TValue *key, StkId val, luaG_runerror(L, "gettable chain too long; possible loop"); } -void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val) { - int loop; + +/* +** Main function for table assignment (invoking metamethods if needed). +** Compute 't[key] = val' +*/ +void luaV_finishset (lua_State *L, TValue *t, TValue *key, + StkId val, TValue *oldval) { + int loop; /* counter to avoid infinite loops */ for (loop = 0; loop < MAXTAGLOOP; loop++) { - TValue *tm = NULL; - if (ttistable(t)) { /* `t' is a table? */ + TValue *tm; + if (oldval != NULL) { + lua_assert(ttistable(t) && ttisnil(oldval)); Table *h = hvalue(t); - TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ + /* must check the metamethod */ /* oldval is nil=> look for newindex, oldval is not nil => look for usedindex */ if (!((ttisnil(oldval) && ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) != NULL)) || ((!ttisnil(oldval)) && ((tm = fasttm(L, h->metatable, TM_USEDINDEX)) != NULL)))) { - setobj2t(L, oldval, val); + /* no metamethod and (now) there is an entry with given key */ + setobj2t(L, cast(TValue *, oldval), val); luaC_barriert(L, h, val); return; } - /* else will try the tag method */ + /* else will try the metamethod */ } - else if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))) - luaG_typeerror(L, t, "index"); + else { /* not a table; check metamethod */ + if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))) + luaG_typeerror(L, t, "index"); + } + /* try the metamethod */ if (ttisfunction(tm)) { callTM(L, tm, t, key, val); return; } - t = tm; /* else repeat with `tm' */ + t = tm; /* else repeat assignment over 'tm' */ + if (luaV_fastset(L, t, key, oldval, luaH_set, val)) + return; /* done */ + /* else loop */ } - luaG_runerror(L, "loop in settable"); + luaG_runerror(L, "settable chain too long; possible loop"); } diff --git a/src/blua/lvm.h b/src/blua/lvm.h index 2ffc80ace..2f65098f0 100644 --- a/src/blua/lvm.h +++ b/src/blua/lvm.h @@ -44,6 +44,32 @@ else luaV_finishget(L,t,k,v,aux); } +/* +** Fast track for set table. If 't' is a table and 't[k]' is not nil, +** call GC barrier, do a raw 't[k]=v', and return true; otherwise, +** return false with 'slot' equal to NULL (if 't' is not a table) or +** 'nil'. (This is needed by 'luaV_finishget'.) Note that, if the macro +** returns true, there is no need to 'invalidateTMcache', because the +** call is not creating a new entry. +*/ +#define luaV_fastset(L,t,k,slot,f,v) \ + (!ttistable(t) \ + ? (slot = NULL, 0) \ + : (slot = f(L, hvalue(t), k), \ + ttisnil(slot) ? 0 \ + : (__extension__ ({ \ + if (valiswhite(v) && isblack(obj2gco(hvalue(t)))) \ + luaC_barrierback(L, hvalue(t)); \ + setobj2t(L, cast(TValue *,slot), v); \ + 1; \ + })))) + + +#define luaV_settable(L,t,k,v) { TValue *slot; \ + if (!luaV_fastset(L,t,k,slot,luaH_set,v)) \ + luaV_finishset(L,t,k,v,slot); } + + LUAI_FUNC int luaV_lessthan (lua_State *L, TValue *l, TValue *r); LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); @@ -51,8 +77,8 @@ LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); LUAI_FUNC void luaV_finishget (lua_State *L, TValue *t, TValue *key, StkId val, TValue *tm); -LUAI_FUNC void luaV_settable (lua_State *L, TValue *t, TValue *key, - StkId val); +LUAI_FUNC void luaV_finishset (lua_State *L, TValue *t, TValue *key, + StkId val, TValue *oldval); LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); From fdccc8026061806cef9c6f5cc2a4d9f752b4d00d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 19:12:59 +0100 Subject: [PATCH 219/589] Blua: 'Protect' in table operations is not needed in the fast track https://github.com/lua/lua/commit/df8b996bccd3830d6fe9d7ba80e8fccd6ac3cabf --- src/blua/lvm.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 484329825..7540bcdec 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -393,6 +393,21 @@ static void Arith (lua_State *L, StkId ra, TValue *rb, } +/* +** copy of 'luaV_gettable', but protecting call to potential metamethod +** (which can reallocate the stack) +*/ +#define gettableProtected(L,t,k,v) { TValue *aux; \ + if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ + else Protect(luaV_finishget(L,t,k,v,aux)); } + + +/* same for 'luaV_settable' */ +#define settableProtected(L,t,k,v) { TValue *slot; \ + if (!luaV_fastset(L,t,k,slot,luaH_set,v)) \ + Protect(luaV_finishset(L,t,k,v,slot)); } + + void luaV_execute (lua_State *L, int nexeccalls) { LClosure *cl; @@ -402,9 +417,9 @@ void luaV_execute (lua_State *L, int nexeccalls) { reentry: /* entry point */ lua_assert(isLua(L->ci)); pc = L->savedpc; - cl = &clvalue(L->ci->func)->l; - base = L->base; - k = cl->p->k; + cl = &clvalue(L->ci->func)->l; /* local reference to function's closure */ + k = cl->p->k; /* local reference to function's constant table */ + base = L->base; /* local copy of function's base */ /* main loop of interpreter */ for (;;) { const Instruction i = *pc++; @@ -464,7 +479,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { StkId ra = RA(i); StkId rb = RB(i); TValue *rc = RKC(i); - Protect(luaV_gettable(L, rb, rc, ra)); + gettableProtected(L, rb, rc, ra); continue; } case OP_SETGLOBAL: { @@ -486,7 +501,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { StkId ra = RA(i); TValue *rb = RKB(i); TValue *rc = RKC(i); - Protect(luaV_settable(L, ra, rb, rc)); + settableProtected(L, ra, rb, rc); continue; } case OP_NEWTABLE: { @@ -500,8 +515,9 @@ void luaV_execute (lua_State *L, int nexeccalls) { case OP_SELF: { StkId ra = RA(i); StkId rb = RB(i); - setobjs2s(L, ra+1, rb); - Protect(luaV_gettable(L, rb, RKC(i), ra)); + TValue *rc = RKC(i); + setobjs2s(L, ra + 1, rb); + gettableProtected(L, rb, rc, ra); continue; } case OP_ADD: { From c418fe3ef8419e1c626b8f894d93d210e35b94ec Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 19:21:36 +0100 Subject: [PATCH 220/589] Blua: 'luaV_fastget' only treats the real fast case (table with a non-nil value at given key, so that it does not need to check metamethods) https://github.com/lua/lua/commit/1a44e822009752513ce895b9eabc51a4ee4a195a --- src/blua/lapi.c | 16 ++++++------ src/blua/lvm.c | 66 ++++++++++++++++++++++++++++++------------------- src/blua/lvm.h | 25 +++++++++---------- 3 files changed, 61 insertions(+), 46 deletions(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index 420e4e20b..bca24a90f 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -520,17 +520,17 @@ LUA_API int lua_pushthread (lua_State *L) { */ static void auxgetstr (lua_State *L, TValue *t, const char *k) { - TValue *aux; + TValue *slot; TValue key; TString *str = luaS_new(L, k); api_checkvalidindex(L, t); - if (luaV_fastget(L, t, str, aux, luaH_getstr)) { - setobj2s(L, L->top, aux); + if (luaV_fastget(L, t, str, slot, luaH_getstr)) { + setobj2s(L, L->top, slot); api_incr_top(L); } else { setsvalue(L, &key, str); - luaV_finishget(L, t, L->top, L->top, aux); + luaV_finishget(L, t, L->top, L->top, slot); api_incr_top(L); } lua_unlock(L); @@ -643,17 +643,17 @@ LUA_API void lua_getfenv (lua_State *L, int idx) { static void auxsetstr (lua_State *L, TValue *t, const char *k) { TValue key; - TValue *aux; + TValue *slot; TString *str = luaS_new(L, k); api_checknelems(L, 1); api_checkvalidindex(L, t); - if (luaV_fastset(L, t, str, aux, luaH_setstr, L->top)) { - setobj2t(L, cast(TValue *, aux), L->top - 1); + if (luaV_fastset(L, t, str, slot, luaH_setstr, L->top)) { + setobj2t(L, cast(TValue *, slot), L->top - 1); L->top--; /* pop value */ } else { setsvalue2s(L, &key, str); - luaV_finishset(L, t, &key, L->top - 1, aux); + luaV_finishset(L, t, &key, L->top - 1, slot); L->top--; /* pop value */ } lua_unlock(L); diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 7540bcdec..9db792fd6 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -106,51 +106,67 @@ static void callTM (lua_State *L, const TValue *f, const TValue *p1, /* -** Complete a table access: if 't' is a table, 'tm' has its metamethod; -** otherwise, 'tm' is NULL. +** Finish the table access 'val = t[key]'. +** if 'slot' is NULL, 't' is not a table; otherwise, 'slot' points to +** t[k] entry (which must be nil). */ void luaV_finishget (lua_State *L, TValue *t, TValue *key, StkId val, - TValue *tm) { + TValue *slot) { int loop; /* counter to avoid infinite loops */ - lua_assert(tm != NULL || !ttistable(t)); + TValue *tm; /* metamethod */ for (loop = 0; loop < MAXTAGLOOP; loop++) { - if (tm == NULL) { /* no metamethod (from a table)? */ - if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))) + if (slot == NULL) { /* 't' is not a table? */ + lua_assert(!ttistable(t)); + tm = luaT_gettmbyobj(L, t, TM_INDEX); + if (l_unlikely(ttisnil(tm))) luaG_typeerror(L, t, "index"); /* no metamethod */ + /* else will try the metamethod */ } - if (ttisfunction(tm)) { /* metamethod is a function */ + else { /* 't' is a table */ + lua_assert(ttisnil(slot)); + tm = fasttm(L, hvalue(t)->metatable, TM_INDEX); /* table's metamethod */ + if (tm == NULL) { /* no metamethod? */ + setnilvalue(val); /* result is nil */ + return; + } + /* else will try the metamethod */ + } + if (ttisfunction(tm)) { /* is metamethod a function? */ callTMres(L, val, tm, t, key); /* call it */ return; } - t = tm; /* else repeat access over 'tm' */ - if (luaV_fastget(L,t,key,tm,luaH_get)) { /* try fast track */ - setobj2s(L, val, tm); /* done */ + t = tm; /* else try to access 'tm[key]' */ + if (luaV_fastget(L,t,key,slot,luaH_get)) { /* fast track? */ + setobj2s(L, val, slot); /* done */ return; } - /* else repeat */ + /* else repeat (tail call 'luaV_finishget') */ } - luaG_runerror(L, "gettable chain too long; possible loop"); + luaG_runerror(L, "'__index' chain too long; possible loop"); } /* -** Main function for table assignment (invoking metamethods if needed). -** Compute 't[key] = val' +** Finish a table assignment 't[key] = val'. +** If 'slot' is NULL, 't' is not a table. Otherwise, 'slot' points +** to the entry 't[key]', or to 'luaO_nilobject' if there is no such +** entry. (The value at 'slot' must be nil, otherwise 'luaV_fastset' +** would have done the job.) */ void luaV_finishset (lua_State *L, TValue *t, TValue *key, - StkId val, TValue *oldval) { + StkId val, TValue *slot) { int loop; /* counter to avoid infinite loops */ for (loop = 0; loop < MAXTAGLOOP; loop++) { TValue *tm; - if (oldval != NULL) { - lua_assert(ttistable(t) && ttisnil(oldval)); + if (slot != NULL) { + lua_assert(ttistable(t) && ttisnil(slot)); Table *h = hvalue(t); /* must check the metamethod */ - /* oldval is nil=> look for newindex, oldval is not nil => look for usedindex */ - if (!((ttisnil(oldval) && ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) != NULL)) || - ((!ttisnil(oldval)) && ((tm = fasttm(L, h->metatable, TM_USEDINDEX)) != NULL)))) { + /* slot is nil=> look for newindex, slot is not nil => look for usedindex */ + if (!((ttisnil(slot) && ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) != NULL)) || + ((!ttisnil(slot)) && ((tm = fasttm(L, h->metatable, TM_USEDINDEX)) != NULL)))) { /* no metamethod and (now) there is an entry with given key */ - setobj2t(L, cast(TValue *, oldval), val); + setobj2t(L, cast(TValue *, slot), val); luaC_barriert(L, h, val); return; } @@ -166,7 +182,7 @@ void luaV_finishset (lua_State *L, TValue *t, TValue *key, return; } t = tm; /* else repeat assignment over 'tm' */ - if (luaV_fastset(L, t, key, oldval, luaH_set, val)) + if (luaV_fastset(L, t, key, slot, luaH_set, val)) return; /* done */ /* else loop */ } @@ -397,9 +413,9 @@ static void Arith (lua_State *L, StkId ra, TValue *rb, ** copy of 'luaV_gettable', but protecting call to potential metamethod ** (which can reallocate the stack) */ -#define gettableProtected(L,t,k,v) { TValue *aux; \ - if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ - else Protect(luaV_finishget(L,t,k,v,aux)); } +#define gettableProtected(L,t,k,v) { TValue *slot; \ + if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ + else Protect(luaV_finishget(L,t,k,v,slot)); } /* same for 'luaV_settable' */ diff --git a/src/blua/lvm.h b/src/blua/lvm.h index 2f65098f0..0c4c877f2 100644 --- a/src/blua/lvm.h +++ b/src/blua/lvm.h @@ -23,25 +23,24 @@ /* -** fast track for 'gettable': 1 means 'aux' points to resulted value; -** 0 means 'aux' is metamethod (if 't' is a table) or NULL. 'f' is -** the raw get function to use. +** fast track for 'gettable': if 't' is a table and 't[k]' is not nil, +** return 1 with 'slot' pointing to 't[k]' (final result). Otherwise, +** return 0 (meaning it will have to check metamethod) with 'slot' +** pointing to a nil 't[k]' (if 't' is a table) or NULL (otherwise). +** 'f' is the raw get function to use. */ -#define luaV_fastget(L,t,k,aux,f) \ +#define luaV_fastget(L,t,k,slot,f) \ (!ttistable(t) \ - ? (aux = NULL, 0) /* not a table; 'aux' is NULL and result is 0 */ \ - : (aux = f(hvalue(t), k), /* else, do raw access */ \ - !ttisnil(aux) ? 1 /* result not nil? 'aux' has it */ \ - : (aux = fasttm(L, hvalue(t)->metatable, TM_INDEX), /* get metamethod */\ - aux != NULL ? 0 /* has metamethod? must call it */ \ - : (aux = luaO_nilobject, 1)))) /* else, final result is nil */ + ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ + : (slot = f(hvalue(t), k), /* else, do raw access */ \ + !ttisnil(slot))) /* result not nil? */ /* ** standard implementation for 'gettable' */ -#define luaV_gettable(L,t,k,v) { TValue *aux; \ - if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ - else luaV_finishget(L,t,k,v,aux); } +#define luaV_gettable(L,t,k,v) { TValue *slot; \ + if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ + else luaV_finishget(L,t,k,v,slot); } /* From 0fb752b7459673d8a3b38c917f9593602b03c4a0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 19:23:45 +0100 Subject: [PATCH 221/589] Blua: OP_SELF can use 'luaV_fastget' specialized for strings, as it is applied only to string keys https://github.com/lua/lua/commit/257961c601fdec1ea1f9640d460e0d31c39333a1 --- src/blua/lvm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 9db792fd6..4d617d62c 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -529,11 +529,16 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_SELF: { + TValue *slot; StkId ra = RA(i); StkId rb = RB(i); TValue *rc = RKC(i); + TString *key = rawtsvalue(rc); /* key must be a string */ setobjs2s(L, ra + 1, rb); - gettableProtected(L, rb, rc, ra); + if (luaV_fastget(L, rb, key, slot, luaH_getstr)) { + setobj2s(L, ra, slot); + } + else Protect(luaV_finishget(L, rb, rc, ra, slot)); continue; } case OP_ADD: { From 7684e6aa0750744e61cee0a29b948209c140d717 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 3 Dec 2025 19:28:57 +0100 Subject: [PATCH 222/589] Blua: opcode OP_SELF operate only with string keys, so they can use fast-track table access https://github.com/lua/lua/commit/cb3d5dce30089512085f78a0bef79e30ef732e30 --- src/blua/lcode.c | 12 ++++++++++++ src/blua/lopcodes.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/blua/lcode.c b/src/blua/lcode.c index 567b88500..562ad3506 100644 --- a/src/blua/lcode.c +++ b/src/blua/lcode.c @@ -626,8 +626,20 @@ static void codenot (FuncState *fs, expdesc *e) { removevalues(fs, e->t); } +/* +** Check whether expression 'e' is a literal string +*/ +static int isKstr (FuncState *fs, expdesc *e) { + return (e->k == VK && ttisstring(&fs->f->k[e->u.s.info])); +} +/* +** Create expression 't[k]'. 't' must have its final result already in a +** register or upvalue. Upvalues can only be indexed by literal strings. +*/ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { + if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non string? */ + luaK_exp2anyreg(fs, t); /* put it in a register */ t->u.s.aux = luaK_exp2RK(fs, k); t->k = VINDEXED; } diff --git a/src/blua/lopcodes.h b/src/blua/lopcodes.h index 8b08b04e0..aa84da8d0 100644 --- a/src/blua/lopcodes.h +++ b/src/blua/lopcodes.h @@ -232,6 +232,8 @@ OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ (*) In OP_SETLIST, if (B == 0) then B = `top'; if (C == 0) then next `instruction' is real C + (*) In OP_SELF, the index must be a string. + (*) For comparisons, A specifies what condition the test should accept (true or false). From a0dffd0670b579b25b78ca2fdb486975bb7ef66e Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 16 Mar 2026 04:07:42 +0300 Subject: [PATCH 223/589] Fix listemotes calculating incorrect number of pages --- src/m_emotes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_emotes.cpp b/src/m_emotes.cpp index 515799af3..fe90c9a11 100644 --- a/src/m_emotes.cpp +++ b/src/m_emotes.cpp @@ -278,7 +278,7 @@ void M_DrawScaledEmote(fixed_t x, fixed_t y, fixed_t scale, emote_t *emote, INT3 static void Command_ListEmotes_f(void) { const int EMOTES_PER_PAGE = 24; - const int NUMPAGES = std::max(emotes.size()/EMOTES_PER_PAGE, 1); + const int NUMPAGES = emotes.size()/EMOTES_PER_PAGE + (emotes.size() % EMOTES_PER_PAGE != 0 ? 1 : 0); int page = 1; if (COM_Argc() > 1) From e13cb1ca9274c982ac2fd6588b0572371f4af8d7 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 17 Mar 2026 19:00:38 +0300 Subject: [PATCH 224/589] Remove few remaining flashpal things in opengl menu --- src/m_menu.c | 1 - src/m_menudefs.c | 3 --- 2 files changed, 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index ca408dc79..26b7213ab 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2075,7 +2075,6 @@ void M_Init(void) OP_OpenGLOptionsMenu[op_gl_shader].status = IT_GRAYEDOUT; OP_OpenGLOptionsMenu[op_gl_lightdither].status = IT_GRAYEDOUT; OP_OpenGLOptionsMenu[op_gl_palrender].status = IT_GRAYEDOUT; - OP_OpenGLOptionsMenu[op_gl_flashpal].status = IT_GRAYEDOUT; OP_ExpOptionsMenu[op_exp_paldepth].status = IT_GRAYEDOUT; } diff --git a/src/m_menudefs.c b/src/m_menudefs.c index aa3f186c8..e734021eb 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1043,7 +1043,6 @@ static const char* OP_OpenGLTooltips[] = "Fallback 3D model for characters that don't have any.", "Graphical Shaders.", "Recreates the look of software mode.", - "Flash palettes for palette rendering.", "Bit-depth of textures.", "Filter to use on textures.", "Anisotropic filtering.", @@ -1062,7 +1061,6 @@ enum op_gl_falbckmdls, op_gl_shader, op_gl_palrender, - op_gl_flashpal, op_gl_scrdepth, op_gl_filter, op_gl_anis, @@ -2772,6 +2770,5 @@ void M_UpdateOGLMenu(void) OP_OpenGLOptionsMenu[op_gl_lightdither].status = (!HWR_UseShader()) ? IT_GRAYEDOUT : IT_STRING | IT_CVAR; OP_OpenGLOptionsMenu[op_gl_palrender].status = (cv_glscreentextures.value != 2 || !HWR_UseShader()) ? IT_GRAYEDOUT : IT_STRING | IT_CVAR; - OP_OpenGLOptionsMenu[op_gl_flashpal].status = (!HWR_ShouldUsePaletteRendering()) ? IT_GRAYEDOUT : IT_STRING | IT_CVAR; } #endif From bb3414d603313d6468c413e0ee6847a7a05fa447 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 21 Mar 2026 23:10:48 +0300 Subject: [PATCH 225/589] Fix /pm and emote suggestions overlapping --- src/hu_stuff.c | 126 ++++++++++++++++++++++++++----------------------- 1 file changed, 66 insertions(+), 60 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 6ede89fc6..72203c8fe 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -97,7 +97,6 @@ static textinput_t w_chat; static boolean headsupactive = false; boolean hu_showscores = false; // draw rankings static char hu_tick; -static tic_t hu_emoteanim = 0; emote_autocomplete_t emote_autocomplete = {0}; static huddrawlist_h luahuddrawlist_scores = NULL; @@ -1095,7 +1094,6 @@ void HU_Ticker(void) return; hu_tick++; - hu_emoteanim++; hu_tick &= 7; // currently only to blink chat input cursor if (PLAYER1INPUTDOWN(gc_scores)) @@ -1810,6 +1808,7 @@ static void HU_DrawChat(void) INT32 t = 0, c = 0, y = chaty - (typelines*charheight); UINT32 i = 0, saylen = strlen(w_chat_buf); // You learn new things everyday! INT32 cflag = 0; + INT32 pm_offset = 0; // for cases when you type emote while also doing /pm size_t select_start = 0, select_end = 0; const char *ntalk = "Say: ", *ttalk = "Team: "; const char *talk = ntalk; @@ -1921,64 +1920,6 @@ static void HU_DrawChat(void) } } - if (emote_autocomplete.emotestart != -1 && (emote_autocomplete.complete[0] || (w_chat.cursor - emote_autocomplete.emotestart) > 1)) - { - emote_t *suggest; - int skip = 0; - - const char *complete; - int complete_len; - - if (emote_autocomplete.complete[0]) - { - complete = emote_autocomplete.complete; - complete_len = strlen(complete); - } - else - { - complete = &w_chat_buf[emote_autocomplete.emotestart]; - complete_len = w_chat.cursor - emote_autocomplete.emotestart; - } - - // A bit of copy-paste from /pm code :p - INT32 suggesty = chaty - charheight - 1; - size_t longest_suggestion_length = 0; - - while ((suggest = M_FindEmote(complete, complete_len, skip)) != NULL) - { - longest_suggestion_length = max(longest_suggestion_length, strlen(suggest->name)); - ++skip; - } - - skip = 0; - -#ifdef NETSPLITSCREEN - if (splitscreen) - { - suggesty -= BASEVIDHEIGHT/2; - if (splitscreen > 1) - suggesty += 16; - } - else -#endif - suggesty -= (cv_kartspeedometer.value ? 16 : 0); - - while ((suggest = M_FindEmote(complete, complete_len, skip)) != NULL) - { - V_DrawFillConsoleMap(chatx + boxw + 2, suggesty - (7*skip), (longest_suggestion_length+2)*4 + EMOTEWIDTH, 6, V_SNAPTOBOTTOM|V_SNAPTOLEFT); - - // Highlight currently suggested emote - int hlflag = 0; - if (skip == emote_autocomplete.skip && emote_autocomplete.complete[0]) - hlflag = V_YELLOWMAP; - - V_DrawSmallString(chatx + boxw + 4 + EMOTEWIDTH, suggesty - (7*skip), hlflag|V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, va(":%s:", suggest->name)); - M_DrawEmote(chatx + boxw + 2, suggesty - skip*7, suggest, V_SNAPTOBOTTOM|V_SNAPTOLEFT); - - ++skip; - } - } - // handle /pm list. It's messy, horrible and I don't care. if (strnicmp(w_chat_buf, "/pm", 3) == 0 && vid.width >= 400 && !teamtalk) // 320x200 unsupported kthxbai { @@ -2059,9 +2000,74 @@ static void HU_DrawChat(void) if (count == 0) // no results. { + pm_offset = 48 + 2; V_DrawFillConsoleMap(chatx + boxw + 2, p_dispy - (6*count), 48, 6, 239 | V_SNAPTOBOTTOM | V_SNAPTOLEFT); // fill it like the chat so the text doesn't become hard to read because of the hud. V_DrawSmallString(chatx + boxw + 4, p_dispy - (6*count), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, "NO RESULT."); } + else + { + pm_offset = (longest_name_length+4)*4 + 2; + } + } + + if (emote_autocomplete.emotestart != -1 && (emote_autocomplete.complete[0] || (w_chat.cursor - emote_autocomplete.emotestart) > 1)) + { + emote_t *suggest; + int skip = 0; + + const char *complete; + int complete_len; + + if (emote_autocomplete.complete[0]) + { + complete = emote_autocomplete.complete; + complete_len = strlen(complete); + } + else + { + complete = &w_chat_buf[emote_autocomplete.emotestart]; + complete_len = w_chat.cursor - emote_autocomplete.emotestart; + } + + // A bit of copy-paste from /pm code :p + INT32 suggesty = chaty - charheight - 1; + size_t longest_suggestion_length = 0; + + while ((suggest = M_FindEmote(complete, complete_len, skip)) != NULL) + { + longest_suggestion_length = max(longest_suggestion_length, strlen(suggest->name)); + ++skip; + } + + INT32 emote_suggest_boxw = (longest_suggestion_length+2)*4 + EMOTEWIDTH; + + skip = 0; + +#ifdef NETSPLITSCREEN + if (splitscreen) + { + suggesty -= BASEVIDHEIGHT/2; + if (splitscreen > 1) + suggesty += 16; + } + else +#endif + suggesty -= (cv_kartspeedometer.value ? 16 : 0); + + while ((suggest = M_FindEmote(complete, complete_len, skip)) != NULL) + { + V_DrawFillConsoleMap(chatx + boxw + pm_offset + 2, suggesty - (7*skip), emote_suggest_boxw, 6, V_SNAPTOBOTTOM|V_SNAPTOLEFT); + + // Highlight currently suggested emote + int hlflag = 0; + if (skip == emote_autocomplete.skip && emote_autocomplete.complete[0]) + hlflag = V_YELLOWMAP; + + V_DrawSmallString(chatx + boxw + pm_offset + 4 + EMOTEWIDTH, suggesty - (7*skip), hlflag|V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, va(":%s:", suggest->name)); + M_DrawEmote(chatx + boxw + pm_offset + 2, suggesty - skip*7, suggest, V_SNAPTOBOTTOM|V_SNAPTOLEFT); + + ++skip; + } } HU_drawChatLog(typelines - 1); // typelines is the # of lines we're typing. If there's more than 1 then the log should scroll up to give us more space. From 6721f534ccdd5c2950bfc67c3c1d31dc8cad164d Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 22 Mar 2026 22:16:55 +0300 Subject: [PATCH 226/589] Fix Got_Saycmd not skipping null terminator when message has maximum length --- src/hu_stuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 72203c8fe..91f9ca7d1 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -906,7 +906,7 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum) target = READSINT8(*p); flags = READUINT8(*p); msg = buf; - READSTRINGL(*p, msg, HU_MAXMSGLEN + 1); + READSTRINGN(*p, msg, HU_MAXMSGLEN + 1); if ((cv_mute.value || flags & (HU_CSAY|HU_SERVER_SAY)) && playernum != serverplayer && !(IsPlayerAdmin(playernum))) { From 1c74b3702610ed030cc68a729719c04a7b6c03f8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Mar 2026 22:13:37 +0100 Subject: [PATCH 227/589] unify console shift handling both the non AZERTY and AZERTY functions basically did the exact same thing so can just get rid of one also simplify some checks --- src/console.c | 56 +++++++---------------------------------------- src/console.h | 1 - src/d_main.c | 2 +- src/m_menu.c | 2 +- src/m_textinput.c | 4 ++-- 5 files changed, 12 insertions(+), 53 deletions(-) diff --git a/src/console.c b/src/console.c index 7276b59c8..d185858f9 100644 --- a/src/console.c +++ b/src/console.c @@ -638,68 +638,28 @@ INT32 CON_ShiftChar(INT32 ch) if (I_UseNativeKeyboard()) return ch; - if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) - { - if (cv_keyboardlayout.value == 3) - { - if (shiftdown ^ capslock) - ch = shiftxform[ch]; - else if (altdown & 0x2) - ch = french_altgrxform[ch]; - else - ch = HU_FallBackFrSpecialLetter(ch); - } - else - { - if (shiftdown ^ capslock) - ch = shiftxform[ch]; - } - } - else // if we're holding shift we should still shift non letter symbols - { - if (cv_keyboardlayout.value == 3) - { - if (shiftdown) - ch = shiftxform[ch]; - else if (altdown & 0x2) - ch = french_altgrxform[ch]; - else - ch = HU_FallBackFrSpecialLetter(ch); - } - else - { - if (shiftdown) - ch = shiftxform[ch]; - } - } - - return ch; -} - -INT32 CON_ShitAndAltGrChar(INT32 ch) -{ if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { if (shiftdown ^ capslock) ch = shiftxform[ch]; } - else // if we're holding shift we should still shift non letter symbols + else // if we're holding shift we should still shift non letter symbols { if (shiftdown) ch = shiftxform[ch]; - else if (altdown & 0x2) + else if (cv_keyboardlayout.value == 3) { - ch = french_altgrxform[ch]; - } - else - { - ch = HU_FallBackFrSpecialLetter(ch); + if (altdown & 0x2) + ch = french_altgrxform[ch]; + else + ch = HU_FallBackFrSpecialLetter(ch); } } return ch; } + // Clear time of console heads up messages // void CON_ClearHUD(void) @@ -892,7 +852,7 @@ boolean CON_Responder(event_t *ev) return true; // ctrl modifier -- changes behavior, adds shortcuts - if ((cv_keyboardlayout.value != 3 && ctrldown) || (cv_keyboardlayout.value == 3 && ctrldown && !altdown)) + if (ctrldown && (cv_keyboardlayout.value != 3 || (cv_keyboardlayout.value == 3 && !altdown))) { // show all cvars/commands that match what we have inputted if (key == KEY_TAB) diff --git a/src/console.h b/src/console.h index 3292bc6e3..abb506609 100644 --- a/src/console.h +++ b/src/console.h @@ -49,7 +49,6 @@ extern UINT8 *yellowmap, *purplemap, *greenmap, *bluemap, *graymap, *redmap, *or extern UINT8 *consolebgmap; INT32 CON_ShiftChar(INT32 ch); -INT32 CON_ShitAndAltGrChar(INT32 ch); void CON_SetupBackColormap(void); void CON_ClearHUD(void); // clear heads up messages diff --git a/src/d_main.c b/src/d_main.c index 0ecce2047..ccfa61f4e 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1208,7 +1208,7 @@ void D_AddPostloadFiles(void) static boolean AddIWAD(const char * file, const char *dir) { - char * path = va(pandf, dir, file); + char *path = va(pandf, dir, file); if (FIL_ReadFileOK(path)) { diff --git a/src/m_menu.c b/src/m_menu.c index 26b7213ab..3128b1e15 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7950,7 +7950,7 @@ static void M_DrawSetupMultiPlayerMenu(void) patch_t *statbg = (patch_t *)W_CachePatchName("K_STATBG", PU_PATCH); patch_t *statlr = (patch_t *)W_CachePatchName("K_STATLR", PU_PATCH); patch_t *statud = (patch_t *)W_CachePatchName("K_STATUD", PU_PATCH); - patch_t *statdot = (patch_t *)W_CachePatchName("K_SDOT0", PU_PATCH); + patch_t *statdot = (patch_t *)W_CachePatchName("K_SDOT0" , PU_PATCH); patch_t *patch; UINT8 frame; UINT8 speed; diff --git a/src/m_textinput.c b/src/m_textinput.c index 7d050dfc7..c49294094 100644 --- a/src/m_textinput.c +++ b/src/m_textinput.c @@ -256,7 +256,7 @@ static boolean M_TextInputHandleBase(textinput_t *input, INT32 key, boolean emot return true; } - if ((cv_keyboardlayout.value != 3 && ctrldown) || (cv_keyboardlayout.value == 3 && ctrldown && !altdown)) + if (ctrldown && (cv_keyboardlayout.value != 3 || (cv_keyboardlayout.value == 3 && !altdown))) { if (key == 'x' || key == 'X') { @@ -392,7 +392,7 @@ static boolean M_TextInputHandleBase(textinput_t *input, INT32 key, boolean emot key = '/'; // same capslock code as hu_stuff.c's HU_responder. Check there for details. - key = cv_keyboardlayout.value == 3 ? CON_ShitAndAltGrChar(key) : CON_ShiftChar(key); + key = CON_ShiftChar(key); // enter a char into the command prompt if (key < 32 || key > 127) From 0d20ebb01f654caa80d5e4af6ba13b2ca83240e9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Mar 2026 22:17:36 +0100 Subject: [PATCH 228/589] delet P_CyclePlayerMobjState P_SetMobjState already handles player case and forwards it to P_SetPlayerMobjState so this is just duped code --- src/p_mobj.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 01b3977d0..552ef4eff 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -122,27 +122,6 @@ static void P_CycleMobjState(mobj_t *mobj) } } -// -// P_CycleMobjState for players. -// -static void P_CyclePlayerMobjState(mobj_t *mobj) -{ - // state animations - P_CycleStateAnimation(mobj); - - // cycle through states, - // calling action functions at transitions - if (mobj->tics != -1) - { - mobj->tics--; - - // you can cycle through multiple states in a tic - if (!mobj->tics && mobj->state) - if (!P_SetPlayerMobjState(mobj, mobj->state->nextstate)) - return; // freed itself - } -} - #define MAX_RECURSION 20 // @@ -9221,10 +9200,7 @@ void P_MobjThinker(mobj_t *mobj) } // Can end up here if a player dies. - if (mobj->player) - P_CyclePlayerMobjState(mobj); - else - P_CycleMobjState(mobj); + P_CycleMobjState(mobj); if (P_MobjWasRemoved(mobj)) return; From 8af43a55c9d54c05f7cf104ae3fcd11b7fe40eae Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Mar 2026 22:29:10 +0100 Subject: [PATCH 229/589] split CONS_Printf so both CONS_Alert and CONS_Debug dont have to handle and copy the varargs twice probably makes no actual difference in practice, but i prefer it to not do pointless work --- src/console.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/console.c b/src/console.c index d185858f9..df7fc299d 100644 --- a/src/console.c +++ b/src/console.c @@ -1182,19 +1182,10 @@ void CON_LogMessage(const char *msg) // Console print! Wahooo! Lots o fun! // -void CONS_Printf(const char *fmt, ...) +static inline void CONS_PrintMsg(char *txt) { - va_list argptr; - static char *txt = NULL; boolean startup; - if (txt == NULL) - txt = malloc(8192); - - va_start(argptr, fmt); - vsnprintf(txt, 8192, fmt, argptr); - va_end(argptr); - // echo console prints to log file DEBFILE(txt); @@ -1220,6 +1211,21 @@ void CONS_Printf(const char *fmt, ...) } } +void CONS_Printf(const char *fmt, ...) +{ + va_list argptr; + static char *txt = NULL; + + if (txt == NULL) + txt = malloc(8192); + + va_start(argptr, fmt); + vsnprintf(txt, 8192, fmt, argptr); + va_end(argptr); + + CONS_PrintMsg(txt); +} + void CONS_Alert(alerttype_t level, const char *fmt, ...) { va_list argptr; @@ -1248,9 +1254,7 @@ void CONS_Alert(alerttype_t level, const char *fmt, ...) break; } - // I am lazy and I feel like just letting CONS_Printf take care of things. - // Is that okay? - CONS_Printf("%s", txt); + CONS_PrintMsg(txt); } void CONS_Debug(INT32 debugflags, const char *fmt, ...) @@ -1268,11 +1272,9 @@ void CONS_Debug(INT32 debugflags, const char *fmt, ...) vsnprintf(txt, 8192, fmt, argptr); va_end(argptr); - // Again I am lazy, oh well - CONS_Printf("%s", txt); + CONS_PrintMsg(txt); } - // Print an error message, and wait for ENTER key to continue. // To make sure the user has seen the message // From 654895dcff451c7c63c8621c9f58dc5de7fdd6d8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Mar 2026 19:04:44 +0100 Subject: [PATCH 230/589] fix timedemo not accounting for level and addon loading apparently demos used to send a mapcmd before instead of directly calling G_InitNew, so this function was never called which meant that timedemos always returned a wrong result first time --- src/g_demo.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/g_demo.c b/src/g_demo.c index 9662ce517..0b8921c69 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -3090,6 +3090,9 @@ post_compat: if (cv_director.value) CV_SetValue(&cv_director, 0); + if (demo.timing) + G_DoneLevelLoad(); + demo.deferstart = true; } #undef SKIPERRORS From 4f28f574bbe784b6a60229dcc8119348b4384916 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 24 Mar 2026 00:19:47 +0300 Subject: [PATCH 231/589] Fix rare crash in R_DoPlayerFade when viewplayerdist is too low --- src/r_things.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/r_things.cpp b/src/r_things.cpp index 310896a68..d59d6f76f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2970,10 +2970,16 @@ fixed_t R_DoPlayerFade(mobj_t *thing) { if (playerdist < viewplayerdist / 2) // stronger fade when very close { + if (viewplayerdist < 2) + return fadealpha; // avoid zero division + fadealpha = (playerdist * FRACUNIT) / (viewplayerdist / 2) / 3; } else { + if (viewplayerdist == 0) + return fadealpha; // avoid zero division + fadealpha = (playerdist * FRACUNIT) / viewplayerdist; } } From 404d88a536ad22a308bf2a4a21b2699453435b4b Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 24 Mar 2026 01:06:50 +0100 Subject: [PATCH 232/589] remove some dead code --- src/dehacked.c | 98 +++++++++++-------------------------------- src/doomstat.h | 42 ++----------------- src/g_game.c | 2 - src/lua_maplib.c | 15 +++---- src/m_cond.c | 25 ++--------- src/m_cond.h | 10 ----- src/p_mobj.c | 26 ------------ src/p_mobj.h | 2 - src/p_setup.c | 105 ----------------------------------------------- src/p_setup.h | 7 ---- src/p_slopes.c | 4 +- src/r_draw.cpp | 2 +- 12 files changed, 38 insertions(+), 300 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 6b09f0d5b..59e9d8276 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -272,7 +272,6 @@ static void clear_levels(void) // (no need to set num to 0, we're freeing the entire header shortly) Z_Free(mapheaderinfo[i]->customopts); - P_DeleteGrades(i); Z_Free(mapheaderinfo[i]); mapheaderinfo[i] = NULL; } @@ -836,22 +835,8 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) // Now go to uppercase strupr(word2); - // NiGHTS grades - if (fastncmp(word, "GRADES", 6)) - { - UINT8 mare = (UINT8)atoi(word + 6); - - if (mare <= 0 || mare > 8) - { - deh_warning("Level header %d: unknown word '%s'", num, word); - continue; - } - - P_AddGradesForMare((INT16)(num-1), mare-1, word2); - } - // Strings that can be truncated - else if (fastcmp(word, "SCRIPTNAME")) + if (fastcmp(word, "SCRIPTNAME")) { deh_strlcpy(mapheaderinfo[num-1]->scriptname, word2, sizeof(mapheaderinfo[num-1]->scriptname), va("Level header %d: scriptname", num)); @@ -863,10 +848,6 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) } else if (fastcmp(word, "ACT")) { - /*if (i >= 0 && i < 20) // 0 for no act number, TTL1 through TTL19 - mapheaderinfo[num-1]->actnum = (UINT8)i; - else - deh_warning("Level header %d: invalid act number %d", num, i);*/ deh_strlcpy(mapheaderinfo[num-1]->actnum, word2, sizeof(mapheaderinfo[num-1]->actnum), va("Level header %d: actnum", num)); } @@ -931,11 +912,7 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) mapheaderinfo[num-1]->mustrack = ((UINT16)i - 1); else if (fastcmp(word, "MUSICPOS")) mapheaderinfo[num-1]->muspos = (UINT32)get_number(word2); - else if (fastcmp(word, "MUSICINTERFADEOUT")) - mapheaderinfo[num-1]->musinterfadeout = (UINT32)get_number(word2); - else if (fastcmp(word, "MUSICINTER")) - deh_strlcpy(mapheaderinfo[num-1]->musintername, word2, - sizeof(mapheaderinfo[num-1]->musintername), va("Level header %d: intermission music", num)); + else if (fastcmp(word, "FORCECHARACTER")) { strlcpy(mapheaderinfo[num-1]->forcecharacter, word2, SKINNAMESIZE+1); @@ -977,44 +954,12 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) else if (fastcmp(word, "SKYBOXSCALEZ")) mapheaderinfo[num-1]->skybox_scalez = (INT16)i; - else if (fastcmp(word, "BONUSTYPE")) - { - if (fastcmp(word2, "NONE")) i = -1; - else if (fastcmp(word2, "NORMAL")) i = 0; - else if (fastcmp(word2, "BOSS")) i = 1; - else if (fastcmp(word2, "ERZ3")) i = 2; - - if (i >= -1 && i <= 2) // -1 for no bonus. Max is 2. - mapheaderinfo[num-1]->bonustype = (SINT8)i; - else - deh_warning("Level header %d: invalid bonus type number %d", num, i); - } - - else if (fastcmp(word, "SAVEOVERRIDE")) - { - if (fastcmp(word2, "DEFAULT")) i = SAVE_DEFAULT; - else if (fastcmp(word2, "ALWAYS")) i = SAVE_ALWAYS; - else if (fastcmp(word2, "NEVER")) i = SAVE_NEVER; - - if (i >= SAVE_NEVER && i <= SAVE_ALWAYS) - mapheaderinfo[num-1]->saveoverride = (SINT8)i; - else - deh_warning("Level header %d: invalid save override number %d", num, i); - } - else if (fastcmp(word, "LEVELFLAGS")) mapheaderinfo[num-1]->levelflags = get_number(word2); else if (fastcmp(word, "MENUFLAGS")) mapheaderinfo[num-1]->menuflags = get_number(word2); // SRB2Kart - /*else if (fastcmp(word, "AUTOMAP")) - { - if (i || word2[0] == 'T' || word2[0] == 'Y') - mapheaderinfo[num-1]->automap = true; - else - mapheaderinfo[num-1]->automap = false; - }*/ else if (fastcmp(word, "MOBJSCALE")) mapheaderinfo[num-1]->mobj_scale = get_number(word2); else if (fastcmp(word, "LIGHTCONTRAST") || fastcmp(word, "ENCORELIGHTCONTRAST")) @@ -1127,6 +1072,26 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) else mapheaderinfo[num-1]->menuflags &= ~LF2_NOVISITNEEDED; } + else if (fastcmp(word, "MUSICINTERFADEOUT")) + { + continue; // unused + } + else if (fastcmp(word, "MUSICINTER")) + { + continue; // unused + } + else if (fastcmp(word, "BONUSTYPE")) + { + continue; // unused + } + else if (fastcmp(word, "SAVEOVERRIDE")) + { + continue; // unused + } + else if (fastncmp(word, "GRADES", 6)) // NiGHTS grades + { + continue; // unused + } else deh_warning("Level header %d: unknown word '%s'", num, word); } @@ -1217,7 +1182,6 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) i = atoi(word2); usi = (UINT16)i; - if (fastcmp(word, "NUMBEROFPICS")) { cutscenes[num]->scene[scenenum].numpics = (UINT8)i; @@ -1898,16 +1862,8 @@ static void reademblemdata(MYFILE *f, INT32 num) emblemlocations[num-1].type = ET_GLOBAL; else if (fastcmp(word2, "SKIN")) emblemlocations[num-1].type = ET_SKIN; - /*else if (fastcmp(word2, "SCORE")) - emblemlocations[num-1].type = ET_SCORE;*/ else if (fastcmp(word2, "TIME")) emblemlocations[num-1].type = ET_TIME; - /*else if (fastcmp(word2, "RINGS")) - emblemlocations[num-1].type = ET_RINGS; - else if (fastcmp(word2, "NGRADE")) - emblemlocations[num-1].type = ET_NGRADE; - else if (fastcmp(word2, "NTIME")) - emblemlocations[num-1].type = ET_NTIME;*/ else emblemlocations[num-1].type = (UINT8)value; } @@ -2196,14 +2152,11 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) } else if ((offset=0) || fastcmp(params[0], "GAMECLEAR") || (++offset && fastcmp(params[0], "ALLEMERALDS"))) - //|| (++offset && fastcmp(params[0], "ULTIMATECLEAR"))) { ty = UC_GAMECLEAR + offset; re = (params[1]) ? atoi(params[1]) : 1; } else if ((offset=0) || fastcmp(params[0], "OVERALLTIME")) - //|| (++offset && fastcmp(params[0], "OVERALLSCORE")) - //|| (++offset && fastcmp(params[0], "OVERALLRINGS"))) { PARAMCHECK(1); ty = UC_OVERALLTIME + offset; @@ -2212,8 +2165,6 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) else if ((offset=0) || fastcmp(params[0], "MAPVISITED") || (++offset && fastcmp(params[0], "MAPBEATEN")) || (++offset && fastcmp(params[0], "MAPALLEMERALDS"))) - //|| (++offset && fastcmp(params[0], "MAPULTIMATE")) - //|| (++offset && fastcmp(params[0], "MAPPERFECT"))) { PARAMCHECK(1); ty = UC_MAPVISITED + offset; @@ -2231,8 +2182,6 @@ static void readcondition(UINT8 set, UINT32 id, char *word2) } } else if ((offset=0) || fastcmp(params[0], "MAPTIME")) - //|| (++offset && fastcmp(params[0], "MAPSCORE")) - //|| (++offset && fastcmp(params[0], "MAPRINGS"))) { PARAMCHECK(2); ty = UC_MAPTIME + offset; @@ -2615,7 +2564,7 @@ static void readmaincfg(MYFILE *f) } else if (fastcmp(word, "MAXXTRALIFE")) { - maxXtraLife = (UINT8)get_number(word2); + continue; // unused } else if (fastcmp(word, "GAMEDATA")) { @@ -2645,6 +2594,7 @@ static void readmaincfg(MYFILE *f) strcatbf(savegamename, srb2home, PATHSEP); refreshdirmenu |= REFRESHDIR_GAMEDATA;*/ + continue; } else if (fastcmp(word, "RESETDATA")) { diff --git a/src/doomstat.h b/src/doomstat.h index 80f86b974..f8216cc1e 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -205,12 +205,6 @@ extern struct quake fixed_t radius, intensity; } quake; -// NiGHTS grades -typedef struct -{ - UINT32 grade[6]; // D, C, B, A, S, X (F: failed to reach any of these) -} nightsgrades_t; - // Custom Lua values // (This is not ifdeffed so the map header structure can stay identical, just in case.) typedef struct @@ -261,28 +255,16 @@ typedef struct UINT8 numlaps; ///< Number of laps in circuit mode, unless overridden. SINT8 unlockrequired; ///< Is an unlockable required to play this level? -1 if no. UINT8 levelselect; ///< Is this map available in the level select? If so, which map list is it available in? - SINT8 bonustype; ///< What type of bonus does this level have? (-1 for null.) - SINT8 saveoverride; ///< Set how the game is allowed to save (1 for always, -1 for never, 0 is 2.1 default) - UINT8 levelflags; ///< LF_flags: merged eight booleans into one UINT8 for space, see below UINT8 menuflags; ///< LF2_flags: options that affect record attack / nights mode menus - // NiGHTS stuff. - UINT8 numGradedMares; ///< Internal. For grade support. - nightsgrades_t *grades; ///< NiGHTS grades. Allocated dynamically for space reasons. Be careful. - // SRB2kart - //boolean automap; ///< Displays a level's white map outline in modified games 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 boolean use_encore_lighting; ///< Whether to use separate Encore lighting - // Music stuff. - UINT32 musinterfadeout; ///< Fade out level music on intermission screen in milliseconds - char musintername[7]; ///< Intermission screen music. - // Lua stuff. // (This is not ifdeffed so the map header structure can stay identical, just in case.) UINT8 numCustomOptions; ///< Internal. For Lua custom value support. @@ -379,8 +361,6 @@ typedef struct { tic_t time; ///< Time in which the level was finished. tic_t lap; ///< Best lap time for this level. - //UINT32 score; ///< Score when the level was finished. - //UINT16 rings; ///< Rings when the level was finished. } recorddata_t; /** Setup for one NiGHTS map. @@ -394,34 +374,19 @@ typedef struct #define GRADE_A 5 #define GRADE_S 6 -/*typedef struct -{ - // 8 mares, 1 overall (0) - UINT8 nummares; - UINT32 score[9]; - UINT8 grade[9]; - tic_t time[9]; -} nightsdata_t;*/ - -//extern nightsdata_t *nightsrecords[NUMMAPS]; extern recorddata_t *mainrecords[NUMMAPS]; // mapvisited is now a set of flags that says what we've done in the map. #define MV_VISITED 1 #define MV_BEATEN 2 #define MV_ALLEMERALDS 4 -//#define MV_ULTIMATE 8 -//#define MV_PERFECT 16 #define MV_MAX 7 // used in gamedata check extern UINT8 mapvisited[NUMMAPS]; -// Temporary holding place for nights data for the current map -//nightsdata_t ntemprecords; - -extern UINT32 token; ///< Number of tokens collected in a level +extern UINT32 token; ///< Number of tokens collected in a level extern UINT32 tokenlist; ///< List of tokens collected -extern INT32 tokenbits; ///< Used for setting token bits -extern INT32 sstimer; ///< Time allotted in the special stage +extern INT32 tokenbits; ///< Used for setting token bits +extern INT32 sstimer; ///< Time allotted in the special stage extern UINT32 bluescore; ///< Blue Team Scores extern UINT32 redscore; ///< Red Team Scores @@ -461,7 +426,6 @@ extern UINT8 introtoplay; extern UINT8 creditscutscene; extern UINT8 use1upSound; -extern UINT8 maxXtraLife; // Max extra lives from rings extern mobj_t *hunt1, *hunt2, *hunt3; // Emerald hunt locations diff --git a/src/g_game.c b/src/g_game.c index ff660e6bf..6b01b2bdc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -97,7 +97,6 @@ boolean savemoddata = false; UINT8 paused = 0; UINT8 modeattacking = ATTACKING_NONE; boolean imcontinuing = false; -boolean runemeraldmanager = false; boolean netgame = false; // only true if packets are broadcast boolean multiplayer = false; @@ -210,7 +209,6 @@ const INT32 wantedfrequency = 10*TICRATE; INT32 gameovertics = 15*TICRATE; UINT8 use1upSound = 0; -UINT8 maxXtraLife = 2; // Max extra lives from rings UINT8 introtoplay = 0; UINT8 creditscutscene = 0; diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 2931e9a16..606d54383 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1506,7 +1506,6 @@ enum mapheaderinfo_e mapheaderinfo_saveoverride, mapheaderinfo_levelflags, mapheaderinfo_menuflags, - //mapheaderinfo_automap, mapheaderinfo_mobj_scale, }; @@ -1542,7 +1541,6 @@ static const char *const mapheaderinfo_opt[] = { "saveoverride", "levelflags", "menuflags", - //"automap", "mobj_scale", NULL, }; @@ -1584,10 +1582,11 @@ static int mapheaderinfo_get(lua_State *L) lua_pushinteger(L, header->muspos); break; case mapheaderinfo_musinterfadeout: - lua_pushinteger(L, header->musinterfadeout); + lua_pushinteger(L, 0); // unused break; case mapheaderinfo_musintername: - lua_pushstring(L, header->musintername); + // uhh psure its fine to just push nil instead of empty string? + lua_pushstring(L, NULL); break; case mapheaderinfo_forcecharacter: lua_pushstring(L, header->forcecharacter); @@ -1641,10 +1640,10 @@ static int mapheaderinfo_get(lua_State *L) lua_pushinteger(L, header->levelselect); break; case mapheaderinfo_bonustype: - lua_pushinteger(L, header->bonustype); + lua_pushinteger(L, 0); // unused break; case mapheaderinfo_saveoverride: - lua_pushinteger(L, header->saveoverride); + lua_pushinteger(L, SAVE_DEFAULT); // unused break; case mapheaderinfo_levelflags: lua_pushinteger(L, header->levelflags); @@ -1652,13 +1651,9 @@ static int mapheaderinfo_get(lua_State *L) case mapheaderinfo_menuflags: lua_pushinteger(L, header->menuflags); break; - /*case mapheaderinfo_automap: - lua_pushstring(L, header->selectheading); - break;*/ case mapheaderinfo_mobj_scale: lua_pushfixed(L, header->mobj_scale); break; - // TODO add support for reading numGradedMares and grades default: { // Read custom vars now diff --git a/src/m_cond.c b/src/m_cond.c index c22c966f3..85c0b5ee2 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -479,32 +479,13 @@ UINT8 M_CheckLevelEmblems(void) // Update Score, Time, Rings emblems for (i = 0; i < numemblems; ++i) { - if (emblemlocations[i].type <= ET_SKIN || emblemlocations[i].collected) + // Requires time on map <= x + if (emblemlocations[i].type != ET_TIME || emblemlocations[i].collected) continue; levelnum = emblemlocations[i].level; valToReach = emblemlocations[i].var; - - switch (emblemlocations[i].type) - { - /*case ET_SCORE: // Requires score on map >= x - res = (G_GetBestScore(levelnum) >= (unsigned)valToReach); - break;*/ - case ET_TIME: // Requires time on map <= x - res = (G_GetBestTime(levelnum) <= (unsigned)valToReach); - break; - /*case ET_RINGS: // Requires rings on map >= x - res = (G_GetBestRings(levelnum) >= valToReach); - break; - case ET_NGRADE: // Requires NiGHTS grade on map >= x - res = (G_GetBestNightsGrade(levelnum, 0) >= valToReach); - break; - case ET_NTIME: // Requires NiGHTS time on map <= x - res = (G_GetBestNightsTime(levelnum, 0) <= (unsigned)valToReach); - break;*/ - default: // unreachable but shuts the compiler up. - continue; - } + res = (G_GetBestTime(levelnum) <= (unsigned)valToReach); emblemlocations[i].collected = res; if (res) diff --git a/src/m_cond.h b/src/m_cond.h index 06bf30faf..48ff8b9c5 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -27,21 +27,11 @@ typedef enum UC_MATCHESPLAYED, // SRB2Kart: MATCHESPLAYED [x played] UC_GAMECLEAR, // GAMECLEAR UC_ALLEMERALDS, // ALLEMERALDS - //UC_ULTIMATECLEAR, // ULTIMATECLEAR - //UC_OVERALLSCORE, // OVERALLSCORE [score to beat] UC_OVERALLTIME, // OVERALLTIME [time to beat, tics] - //UC_OVERALLRINGS, // OVERALLRINGS [rings to beat] UC_MAPVISITED, // MAPVISITED [map number] UC_MAPBEATEN, // MAPBEATEN [map number] UC_MAPALLEMERALDS, // MAPALLEMERALDS [map number] - //UC_MAPULTIMATE, // MAPULTIMATE [map number] - //UC_MAPPERFECT, // MAPPERFECT [map number] - //UC_MAPSCORE, // MAPSCORE [map number] [score to beat] UC_MAPTIME, // MAPTIME [map number] [time to beat, tics] - //UC_MAPRINGS, // MAPRINGS [map number] [rings to beat] - //UC_NIGHTSSCORE, // NIGHTSSCORE [map number] [score to beat] - //UC_NIGHTSTIME, // NIGHTSTIME [map number] [time to beat, tics] - //UC_NIGHTSGRADE, // NIGHTSGRADE [map number] [grade] UC_TRIGGER, // TRIGGER [trigger number] UC_TOTALEMBLEMS, // TOTALEMBLEMS [number of emblems] UC_EMBLEM, // EMBLEM [emblem number] diff --git a/src/p_mobj.c b/src/p_mobj.c index 552ef4eff..daef6d1e9 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3189,30 +3189,6 @@ static boolean P_CameraCheckWater(camera_t *thiscam) return false; } -void P_DestroyRobots(void) -{ - // Search through all the thinkers for enemies. - mobj_t *mo; - thinker_t *think; - - for (think = thinkercap.next; think != &thinkercap; think = think->next) - { - if (think->function != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker - - mo = (mobj_t *)think; - - if (mo->health <= 0 || !(mo->flags & MF_ENEMY || mo->flags & MF_BOSS)) - continue; // not a valid enemy - - if (mo->type == MT_PLAYER) // Don't chase after other players! - continue; - - // Found a target enemy - P_KillMobj(mo, players[consoleplayer].mo, players[consoleplayer].mo); - } -} - // the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { @@ -11094,8 +11070,6 @@ void P_SpawnMapThing(mapthing_t *mthing) { if (!cv_powerstones.value || !G_BattleGametype()) return; - - runemeraldmanager = true; } if (!G_RaceGametype()) // No enemies in match or CTF modes diff --git a/src/p_mobj.h b/src/p_mobj.h index 278c40d18..892ffdad4 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -499,7 +499,6 @@ void P_SpawnPrecipitation(void); void P_SpawnParaloop(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, statenum_t nstate, angle_t rotangle, boolean spawncenter); boolean P_BossTargetPlayer(mobj_t *actor, boolean closest); boolean P_SupermanLook4Players(mobj_t *actor); -void P_DestroyRobots(void); boolean P_PrecipThinker(precipmobj_t *mobj); void P_NullPrecipThinker(precipmobj_t *mobj); void P_FreePrecipMobj(precipmobj_t *mobj); @@ -510,7 +509,6 @@ void P_EmeraldManager(void); #define MAXHUNTEMERALDS 64 extern mapthing_t *huntemeralds[MAXHUNTEMERALDS]; extern INT32 numhuntemeralds; -extern boolean runemeraldmanager; extern INT32 numstarposts; #ifdef __cplusplus diff --git a/src/p_setup.c b/src/p_setup.c index 3f3759bf9..0d432e747 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -218,8 +218,6 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->musname[6] = 0; mapheaderinfo[num]->mustrack = 0; mapheaderinfo[num]->muspos = 0; - mapheaderinfo[num]->musinterfadeout = 0; - mapheaderinfo[num]->musintername[0] = '\0'; mapheaderinfo[num]->forcecharacter[0] = '\0'; mapheaderinfo[num]->weather = 0; mapheaderinfo[num]->skynum = 1; @@ -237,16 +235,10 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->numlaps = NUMLAPS_DEFAULT; mapheaderinfo[num]->unlockrequired = -1; mapheaderinfo[num]->levelselect = 0; - mapheaderinfo[num]->bonustype = 0; - 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; mapheaderinfo[num]->customopts = NULL; @@ -266,107 +258,11 @@ void P_AllocMapHeader(INT16 i) if (!mapheaderinfo[i]) { mapheaderinfo[i] = Z_Malloc(sizeof(mapheader_t), PU_STATIC, NULL); - mapheaderinfo[i]->grades = NULL; } P_ClearSingleMapHeaderInfo(i + 1); } -/** NiGHTS Grades are a special structure, - * we initialize them here. - * - * \param i Index of header to allocate grades for - * \param mare The mare we're adding grades for - * \param grades the string from DeHackEd, we work with it ourselves - */ -void P_AddGradesForMare(INT16 i, UINT8 mare, char *gtext) -{ - INT32 g; - char *spos = gtext; - - CONS_Debug(DBG_SETUP, "Map %d Mare %d: ", i+1, (UINT16)mare+1); - - if (mapheaderinfo[i]->numGradedMares < mare+1) - { - mapheaderinfo[i]->numGradedMares = mare+1; - mapheaderinfo[i]->grades = Z_Realloc(mapheaderinfo[i]->grades, sizeof(nightsgrades_t) * mapheaderinfo[i]->numGradedMares, PU_STATIC, NULL); - } - - for (g = 0; g < 6; ++g) - { - // Allow "partial" grading systems - if (spos != NULL) - { - mapheaderinfo[i]->grades[mare].grade[g] = atoi(spos); - CONS_Debug(DBG_SETUP, "%u ", atoi(spos)); - // Grab next comma - spos = strchr(spos, ','); - if (spos) - ++spos; - } - else - { - // Grade not reachable - mapheaderinfo[i]->grades[mare].grade[g] = UINT32_MAX; - } - } - - CONS_Debug(DBG_SETUP, "\n"); -} - -/** And this removes the grades safely. - * - * \param i The header to remove grades from - */ -void P_DeleteGrades(INT16 i) -{ - Z_Free(mapheaderinfo[i]->grades); - mapheaderinfo[i]->grades = NULL; - mapheaderinfo[i]->numGradedMares = 0; -} - -/** And this fetches the grades - * - * \param pscore The player's score. - * \param map The game map. - * \param mare The mare to test. - */ -UINT8 P_GetGrade(UINT32 pscore, INT16 map, UINT8 mare) -{ - INT32 i; - - // Determining the grade - if (mapheaderinfo[map-1] && mapheaderinfo[map-1]->grades && mapheaderinfo[map-1]->numGradedMares >= mare + 1) - { - INT32 pgrade = 0; - for (i = 0; i < 6; ++i) - { - if (pscore >= mapheaderinfo[map-1]->grades[mare].grade[i]) - ++pgrade; - } - - return (UINT8)pgrade; - } - - return 0; -} - -UINT8 P_HasGrades(INT16 map, UINT8 mare) -{ - // Determining the grade - // Mare 0 is treated as overall and is true if ANY grades exist - return (mapheaderinfo[map-1] && mapheaderinfo[map-1]->grades - && (mare == 0 || mapheaderinfo[map-1]->numGradedMares >= mare)); -} - -UINT32 P_GetScoreForGrade(INT16 map, UINT8 mare, UINT8 grade) -{ - // Get the score for the grade... if it exists - if (grade == GRADE_F || grade > GRADE_S || !P_HasGrades(map, mare)) return 0; - - return mapheaderinfo[map-1]->grades[mare].grade[grade-1]; -} - // Loads the vertexes for a level. FUNCINLINE static ATTRINLINE void P_LoadVertices(UINT8 *data) { @@ -2047,7 +1943,6 @@ static void P_LevelInitStuff(boolean reloadinggamestate) // special stage tokens, emeralds, and ring total tokenbits = 0; - runemeraldmanager = false; nummaprings = nummapboxes = numgotboxes = 0; // emerald hunt diff --git a/src/p_setup.h b/src/p_setup.h index 7827ebbe6..c5ad15d44 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -114,13 +114,6 @@ size_t P_PrecacheLevelFlats(void); void P_AllocMapHeader(INT16 i); -// Needed for NiGHTS -void P_DeleteGrades(INT16 i); -void P_AddGradesForMare(INT16 i, UINT8 mare, char *gtext); -UINT8 P_GetGrade(UINT32 pscore, INT16 map, UINT8 mare); -UINT8 P_HasGrades(INT16 map, UINT8 mare); -UINT32 P_GetScoreForGrade(INT16 map, UINT8 mare, UINT8 grade); - #ifdef __cplusplus } // extern "C" #endif diff --git a/src/p_slopes.c b/src/p_slopes.c index b3f4592d6..627052236 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -76,8 +76,8 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope) */ light = FixedMul(nX, FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT)) - + FixedMul(nY, FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); - light = (light + FRACUNIT) / 2; + + FixedMul(nY, FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); + light = (light + FRACUNIT) / 2; } else { diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 97872aee1..2e7c47e87 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -400,7 +400,7 @@ static UINT8* RGetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 f case TC_ALLWHITE: skintableindex = ALLWHITE_TT_CACHE_INDEX; break; case TC_RAINBOW: skintableindex = RAINBOW_TT_CACHE_INDEX; break; case TC_BLINK: skintableindex = BLINK_TT_CACHE_INDEX; break; - default: skintableindex = skinnum; break; + default: skintableindex = skinnum; break; } } From ce3d17de6897bb57b850ee97de0e1751285bdb42 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 25 Mar 2026 20:24:37 +0300 Subject: [PATCH 233/589] Simplify R_DoPlayerFade crash fix a bit and rename playerdist to otherplayerdist --- src/r_things.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index d59d6f76f..2f7e1a992 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2963,24 +2963,21 @@ fixed_t R_DoPlayerFade(mobj_t *thing) if (thing->player == viewplayer || viewplayer->exiting || viewplayer->spectator || camera[R_GetViewNumber()].freecam || leveltime < countdownstarttime) return fadealpha; - const INT32 playerdist = (FixedMul((thing->x - viewx), viewcos) + FixedMul((thing->y - viewy), viewsin)) >> FRACBITS; - const INT32 viewplayerdist = (FixedMul((viewplayer->mo->x - viewx), viewcos) + FixedMul((viewplayer->mo->y - viewy), viewsin)) >> FRACBITS; + const INT32 otherplayerdist = (FixedMul((thing->x - viewx), viewcos) + FixedMul((thing->y - viewy), viewsin)) >> FRACBITS; + const INT32 viewplayerdist = (FixedMul((viewplayer->mo->x - viewx), viewcos) + FixedMul((viewplayer->mo->y - viewy), viewsin)) >> FRACBITS; - if (playerdist < viewplayerdist) + if (viewplayerdist < 2) + return fadealpha; // avoid zero division + + if (otherplayerdist < viewplayerdist) { - if (playerdist < viewplayerdist / 2) // stronger fade when very close + if (otherplayerdist < viewplayerdist / 2) // stronger fade when very close { - if (viewplayerdist < 2) - return fadealpha; // avoid zero division - - fadealpha = (playerdist * FRACUNIT) / (viewplayerdist / 2) / 3; + fadealpha = (otherplayerdist * FRACUNIT) / (viewplayerdist / 2) / 3; } else { - if (viewplayerdist == 0) - return fadealpha; // avoid zero division - - fadealpha = (playerdist * FRACUNIT) / viewplayerdist; + fadealpha = (otherplayerdist * FRACUNIT) / viewplayerdist; } } From 6c7db705c782d2a14c4c3a356b5d9a20b94a9278 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 25 Mar 2026 21:05:39 +0300 Subject: [PATCH 234/589] Strip colors from demo titles for replay search --- src/m_menu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 3128b1e15..7b098a810 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4123,6 +4123,9 @@ static void AddCheckedReplay(void) // Check up to maxnum replays if they match with query static void M_HutCheckReplays(size_t maxnum) { + // Stripped of color codes + char demo_title[sizeof(demolist_all[0].title)]; + if (!replaynamesloaded) return; @@ -4155,7 +4158,9 @@ static void M_HutCheckReplays(size_t maxnum) case MD_NOTLOADED: case MD_OUTDATED: case MD_LOADED: - if (demolist_all[replayquerycheck].title[0] && strcasestr(demolist_all[replayquerycheck].title, replayqueryinput.buffer) != NULL) + StripColors(demo_title, demolist_all[replayquerycheck].title, sizeof(demo_title)); + + if (demolist_all[replayquerycheck].title[0] && strcasestr(demo_title, replayqueryinput.buffer) != NULL) AddCheckedReplay(); // It matches, add it! else replayquerycheck++; // Doesn't match, moving on... From 6022966d69c1e9270072f0101cae957e2e6f9799 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Mar 2026 19:28:29 +0100 Subject: [PATCH 235/589] G_DoPlayDemo: fix demoname becoming garbage when replay restarts/rewinds only used in the error paths, which we shouldnt reach but im not a fan of having a chance of putting garbo in the console --- src/g_demo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 0b8921c69..0af73328d 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2616,7 +2616,7 @@ void G_DoPlayDemo(char *defdemoname) if (defdemoname == NULL) { demobuf.p = demobuf.buffer; - pdemoname = ZZ_Alloc(1); // Easier than adding checks for this everywhere it's freed + pdemoname = ZZ_Calloc(1); // Easier than adding checks for this everywhere it's freed } else { @@ -2628,7 +2628,7 @@ void G_DoPlayDemo(char *defdemoname) n++; pdemoname = ZZ_Alloc(strlen(n)+1); - strcpy(pdemoname,n); + strcpy(pdemoname, n); M_SetPlaybackMenuPointer(); From 9334b86f6eb5b41e2673ce3ff9d02b4008b22aa4 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Mar 2026 19:30:05 +0100 Subject: [PATCH 236/589] console print for playing demos from replayhut might be useful perhaps this should be put into g_doplaydemo instead? --- src/m_menu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 7b098a810..cfc854d36 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4920,6 +4920,7 @@ static void M_HutStartReplay(INT32 choice) demo.loadfiles = (itemOn == 0); demo.ignorefiles = (itemOn != 0); + CONS_Printf(M_GetText("Playing back demo '%s'.\n"), demolist[dir_on[menudepthleft]].filepath); G_DoPlayDemo(demolist[dir_on[menudepthleft]].filepath); } @@ -6481,7 +6482,7 @@ static void M_ChooseTimeAttack(INT32 choice) static void M_HandleStaffReplay(INT32 choice) { boolean exitmenu = false; // exit to previous menu - lumpnum_t l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(cv_nextmap.value),cv_dummystaff.value)); + lumpnum_t l = W_CheckNumForName(va("%sS%02u", G_BuildMapName(cv_nextmap.value), cv_dummystaff.value)); switch (choice) { @@ -6511,7 +6512,7 @@ static void M_HandleStaffReplay(INT32 choice) M_ClearMenus(true); modeattacking = ATTACKING_RECORD; demo.loadfiles = false; demo.ignorefiles = true; // Just assume that record attack replays have the files needed - G_DoPlayDemo(va("%sS%02u",G_BuildMapName(cv_nextmap.value),cv_dummystaff.value)); + G_DoPlayDemo(va("%sS%02u", G_BuildMapName(cv_nextmap.value), cv_dummystaff.value)); break; default: break; From ab209448d19c27dff9433fbedf2bfbf6a6d07b12 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Mar 2026 20:38:21 +0100 Subject: [PATCH 237/589] Introduce GNU constructor and destructor attributes The constructor attribute causes the function to be called automatically before execution enters main (). Similarly, the destructor attribute causes the function to be called automatically after main () has completed or exit () has been called. Functions with these attributes are useful for initializing data that will be used implicitly during the execution of the program. added "used" attribute aswell so compiler does not omit non referenced functions (i hope) gotta test this a bit but seems cool for stuff like verstable maps --- src/doomdef.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/doomdef.h b/src/doomdef.h index 445b6951f..1543e68a9 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -573,6 +573,13 @@ INT32 I_GetKey(void); // NOTE: you WILL have nasal troubles if the variable is not initialized #define CLEANUP(f) __attribute__((__cleanup__(f))) +// the GNU constructor and destructor attributes +// The constructor attribute causes the function to be called automatically before execution enters main (). +// Similarly, the destructor attribute causes the function to be called automatically after main () has completed or exit () has been called. +// Functions with these attributes are useful for initializing data that will be used implicitly during the execution of the program. +#define CONSTRUCTOR __attribute__((constructor, used)) +#define DESTRUCTOR __attribute__((destructor, used)) + // An assert-type mechanism. #ifdef PARANOIA #define I_Assert(e) ((e) ? (void)0 : I_Error("assert failed: %s, file %s, line %d", #e, __FILE__, __LINE__)) From f6a0430a408861d091d5cdfa26bbaa83560b1cc2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Mar 2026 20:39:16 +0100 Subject: [PATCH 238/589] use constructor for W_Startup never liked having this inside i_system --- src/dedicated/i_system.c | 1 - src/sdl/i_system.cpp | 2 -- src/w_wad.c | 5 ++--- src/w_wad.h | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index ddc17d6a5..f6450134c 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1384,7 +1384,6 @@ static void I_Fork(void) INT32 I_StartupSystem(void) { - W_Startup(); I_StartupConsole(); #ifdef NEWSIGNALHANDLER // This is useful when debugging. It lets GDB attach to diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 407e5c3a0..c30e93d90 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1887,8 +1887,6 @@ INT32 I_StartupSystem(void) SDL_VERSION(&SDLcompiled) SDL_GetVersion(&SDLlinked); - W_Startup(); - I_StartupConsole(); #ifdef NEWSIGNALHANDLER // This is useful when debugging. It lets GDB attach to diff --git a/src/w_wad.c b/src/w_wad.c index 2ac8ae68d..8c7494898 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -158,8 +158,7 @@ void W_Shutdown(void) } // the lumpnum cache needs to be initialized before use -// call this as early as possible! -void W_Startup(void) +CONSTRUCTOR static void W_Startup(void) { lumpnum_map_init(&lumpnumcache); lumpnum_map_reserve(&lumpnumcache, LUMPNUMCACHESIZE); @@ -367,7 +366,7 @@ static inline INT32 W_MakeFileMD5(const char *filename, void *resblock) { precise_t t = I_GetPreciseTime(); - CONS_Debug(DBG_SETUP, "Making MD5 for %s\n",filename); + CONS_Debug(DBG_SETUP, "Making MD5 for %s\n", filename); if (md5_stream(fhandle, resblock) == 1) { diff --git a/src/w_wad.h b/src/w_wad.h index ea4a98dd6..474f72c23 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -154,7 +154,6 @@ extern wadfile_t *wadfiles[MAX_WADFILES]; // ========================================================================= -void W_Startup(void); void W_Shutdown(void); // Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened From 7fb21c35ba822290ee5c7203491eeca1002f9e50 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Mar 2026 20:57:06 +0100 Subject: [PATCH 239/589] Experiment: speed up CV_FindVar and CV_FindNetVar oftentimes lua scripts call CV_FindVar a fuckton of times during runtime, with many cvars this can actually tank performance more than one might think ideally lua scripts should cache the result, but with so much stuff and servers we cant expect everyone to go through all scripts to do that using a hashtable for CV_FindNetVar might improve join times aswell, but needs further testing to confirm --- src/command.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/src/command.c b/src/command.c index c37b8f1d3..f19bb89c6 100644 --- a/src/command.c +++ b/src/command.c @@ -1165,6 +1165,39 @@ void VS_Print(vsbuf_t *buf, const char *data) // // ========================================================================= +#define NAME cvar_map_t +#define KEY_TY const char * +#define VAL_TY consvar_t * +#define HASH_FN vt_hash_string +#define CMPR_FN vt_cmpr_string +#include "verstable.h" + +#define NAME netvar_map_t +#define KEY_TY UINT16 +#define VAL_TY consvar_t * +#define HASH_FN vt_hash_integer +#define CMPR_FN vt_cmpr_integer +#include "verstable.h" + +static cvar_map_t cvar_map; +static netvar_map_t netvar_map; + +CONSTRUCTOR static void CV_InitMap(void) +{ + // ensure the map is initialized + cvar_map_t_init(&cvar_map); + cvar_map_t_reserve(&cvar_map, 512); + + netvar_map_t_init(&netvar_map); + netvar_map_t_reserve(&netvar_map, 256); +} + +DESTRUCTOR static void CV_DestroyMap(void) +{ + cvar_map_t_cleanup(&cvar_map); + netvar_map_t_cleanup(&netvar_map); +} + static const char *cv_null_string = ""; /** Searches if a variable has been registered. @@ -1175,11 +1208,17 @@ static const char *cv_null_string = ""; */ consvar_t *CV_FindVar(const char *name) { - consvar_t *cvar; + cvar_map_t_itr it = cvar_map_t_get(&cvar_map, name); + if (!cvar_map_t_is_end(it)) + return it.data->val; + // fallback linear search + /* + consvar_t *cvar; for (cvar = consvar_vars; cvar; cvar = cvar->next) if (fasticmp(name, cvar->name)) return cvar; + */ return NULL; } @@ -1213,11 +1252,17 @@ static inline UINT16 CV_ComputeNetid(const char *s) */ static consvar_t *CV_FindNetVar(UINT16 netid) { + netvar_map_t_itr it = netvar_map_t_get(&netvar_map, netid); + if (!netvar_map_t_is_end(it)) + return it.data->val; + + /* consvar_t *cvar; for (cvar = consvar_vars; cvar; cvar = cvar->next) if (cvar->netid == netid) return cvar; + */ if (netid == 44542) // ouch this hack return &cv_karteliminatelast; @@ -1283,6 +1328,11 @@ void CV_RegisterVar(consvar_t *variable) // the SetValue will set this bit variable->flags &= ~CV_MODIFIED; + + cvar_map_t_insert(&cvar_map, variable->name, variable); + + if (variable->flags & CV_NETVAR) + netvar_map_t_insert(&netvar_map, variable->netid, variable); } /** Finds the string value of a console variable. @@ -1588,9 +1638,21 @@ size_t CV_LoadNetVars(const UINT8 *bufstart) // prevent "invalid command received" serverloading = true; + // we can use our netvar map instead of going through all cvars each time + netvar_map_t_itr it; + for (it = netvar_map_t_first(&netvar_map); + !netvar_map_t_is_end(it); + it = netvar_map_t_next(it)) + { + cvar = it.data->val; + Setvalue(cvar, cvar->defaultvalue, true); + } + + /* for (cvar = consvar_vars; cvar; cvar = cvar->next) if (cvar->flags & CV_NETVAR) Setvalue(cvar, cvar->defaultvalue, true); + */ count = READUINT16(p); while (count--) From 43465c0e3f56d7402af8a3cd3bbfa54f8c923fbe Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 26 Mar 2026 18:29:31 +0100 Subject: [PATCH 240/589] add debug print for fallback flashpals --- src/v_video.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 940dd190d..d4788cf94 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -432,14 +432,17 @@ static void ApplyPaletteDelta(const RGBA_t *pal_in, RGBA_t *pal_out, const INT16 static void GenerateFlashPalettes(void) { - size_t i, palsize; + size_t i; + static const size_t palsize = (2*256); // two flashpals RGBA_t *pFlashPalGammaCorrectedPalette = NULL; // generate flashpalettes if the current palette does not provide any subpalettes if (currentPaletteSize >= (14 * (256 * 3))) // 14 palettes are in playpal + { return; + } - palsize = (2*256); + CONS_Debug(DBG_RENDER, "Current palette does not provide enough subpalettes for flashpalettes to work!\nCreating fallback palettes...\n"); pFallbackFlashPal = Z_Malloc(sizeof(*pFallbackFlashPal)*palsize, PU_STATIC, NULL); pFlashPalGammaCorrectedPalette = Z_Malloc(sizeof (*pFlashPalGammaCorrectedPalette)*palsize, PU_STATIC, NULL); From fded8cc5623f0cdf9b57498d364f13d0a2c9ba10 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 27 Mar 2026 22:05:11 +0300 Subject: [PATCH 241/589] Crash fix for super tiny resolutions Not really sure if anyone would actually want to play on something that is lower than 320x200 but this prevents zero division in V_Recalc at least --- src/v_video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index d4788cf94..29857dd74 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3845,12 +3845,12 @@ void V_Recalc(void) // Set dup based on width or height, whichever is less if (((vid.width*FRACUNIT) / BASEVIDWIDTH) < ((vid.height*FRACUNIT) / BASEVIDHEIGHT)) { - vid.dup = vid.width / BASEVIDWIDTH; + vid.dup = max(vid.width / BASEVIDWIDTH, 1); vid.fdup = (vid.width*FRACUNIT) / BASEVIDWIDTH; } else { - vid.dup = vid.height / BASEVIDHEIGHT; + vid.dup = max(vid.height / BASEVIDHEIGHT, 1); vid.fdup = (vid.height*FRACUNIT) / BASEVIDHEIGHT; } From 6a1c907aa4a3f560256a088afdd4938281073a37 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Mar 2026 00:45:15 +0100 Subject: [PATCH 242/589] bunch of random fixes -handle more memory allocation failures -fix null pointer dereferences -prevent writing out of bounds while writing filenames for D_ParseFileneeded -prevent reading out of bounds while checking for new target in director -fix Update_MS checking against an unitialized value in some cases -fix assert for AddLumpToCache since strlen on non null terminated strings is UB -cleanup and rearrange R_DrawColumn -cleanup musicdef parser a little all in one commit cause idk would be ugly if those were seperate ig --- src/d_main.c | 6 +++- src/d_netcmd.c | 2 +- src/d_netfil.c | 2 +- src/dehacked.c | 11 +------- src/filesrch.c | 4 ++- src/g_demo.c | 4 ++- src/hu_stuff.c | 11 ++++++-- src/k_director.c | 6 ++++ src/mserv.c | 5 ++++ src/p_enemy.c | 5 ++++ src/p_mobj.c | 8 ++++-- src/r_data.c | 6 ++-- src/r_draw_column.cpp | 66 +++++++++++++++++++++---------------------- src/s_sound.c | 25 +++++++--------- src/w_wad.c | 2 +- 15 files changed, 91 insertions(+), 72 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ccfa61f4e..a0b1f6fa4 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -2043,9 +2043,13 @@ void D_SRB2Main(void) if (M_CheckProtoParam("replay")) { const char *replayurl = M_GetProtoParam(); + + if (!replayurl) + I_Error("REPLAY: Invalid URL."); + gconst char *replayname = strrchr(replayurl, '/'); - if (!replayname || !replayurl) + if (!replayname) I_Error("REPLAY: Invalid URL."); #define REPLAYDIR "/DownloadedReplays/" diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d16b54be9..aee7f20d4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1631,7 +1631,7 @@ static void SendNameAndColor(UINT8 splitplayer) static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) { player_t *player = &players[playernum]; - char name[MAXPLAYERNAME+1]; + char name[MAXPLAYERNAME+1] = {}; UINT8 color, skin; #ifdef PARANOIA diff --git a/src/d_netfil.c b/src/d_netfil.c index 67fd28a82..aca8f35ba 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -225,7 +225,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi fileneeded[i].willsend = (UINT8)(filestatus >> 4); fileneeded[i].totalsize = READUINT32(p); // The four next bytes are the file size fileneeded[i].file = NULL; // The file isn't open yet - READSTRINGN(p, fileneeded[i].filename, MAX_WADPATH); // The next bytes are the file name + READSTRINGL(p, fileneeded[i].filename, MAX_WADPATH); // The next bytes are the file name READMEM(p, fileneeded[i].md5sum, 16); // The last 16 bytes are the file checksum } } diff --git a/src/dehacked.c b/src/dehacked.c index 59e9d8276..38f713092 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2812,12 +2812,6 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) deh_num_warning = 0; // save values for cross reference - /* - for (i = 0; i < NUMSTATES; i++) - saveactions[i] = states[i].action; - for (i = 0; i < NUMSPRITES; i++) - savesprnames[i] = sprnames[i]; - */ for (i = 0; i < NUMSFX; i++) savesfxnames[i] = S_sfx[i].name; @@ -3124,11 +3118,8 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) if (deh_num_warning) { CONS_Printf(M_GetText("%d warning%s in the SOC lump\n"), deh_num_warning, deh_num_warning == 1 ? "" : "s"); - if (devparm) { + if (devparm) I_Error("%s%s",va(M_GetText("%d warning%s in the SOC lump\n"), deh_num_warning, deh_num_warning == 1 ? "" : "s"), M_GetText("See log.txt for details.\n")); - //while (!I_GetKey()) - //I_OsPolling(); - } } deh_loaded = true; diff --git a/src/filesrch.c b/src/filesrch.c index 0ba117a1e..1647e1705 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -111,10 +111,12 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want char *searchname; int depthleft = maxsearchdepth; char searchpath[MAXFILEPATH]; - size_t *searchpathindex; + size_t *searchpathindex = NULL; dirhandle = (DIR**)malloc(maxsearchdepth * sizeof(DIR*)); searchpathindex = (size_t *)malloc(maxsearchdepth * sizeof(size_t)); + if (!searchpathindex) + I_Error("out of memory while searching for file %s\n", filename); strcpy(searchpath, startpath); searchpathindex[--depthleft] = strlen(searchpath) + 1; diff --git a/src/g_demo.c b/src/g_demo.c index 0af73328d..4acbba9f5 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1653,10 +1653,12 @@ void G_RecordDemo(const char *name) maxsize = cv_maxdemosize.value*1024*1024; demobuf.buffer = Z_Malloc(maxsize + 100*1024, PU_STATIC, NULL); - demoend = demobuf.buffer + maxsize; if (demobuf.buffer) + { + demoend = demobuf.buffer + maxsize; demo.recording = true; + } else CONS_Alert(CONS_ERROR, "Failed to allocate demo buffer\n"); } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 91f9ca7d1..0f54d7bf8 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -543,6 +543,8 @@ void HU_AddChatText(const char *text, boolean playsound) HU_removeChatText_Log(); chat_log[chat_nummsg_log] = malloc(HU_MSGBUFSIZE); + if (!chat_log[chat_nummsg_log]) + I_Error("HU_AddChatText: out of memory for chat log\n"); strcpy(chat_log[chat_nummsg_log], text); ++chat_nummsg_log; @@ -625,7 +627,10 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) // with that logic, characters 4 and 5 are our numbers: const char *newmsg; INT32 spc = 1; // used if nodenum[1] is a space. - CLEANUP(pfree) char *nodenum = (char*) malloc(3); + CLEANUP(pfree) char *nodenum = (char*)malloc(3); + if (!nodenum) + I_Error("DoSayCommand: out of memory for sending pm\n"); + memcpy(nodenum, msg+3, 2); nodenum[2] = '\0'; @@ -1230,7 +1235,9 @@ static void HU_SendChatMessage(void) { INT32 spc = 1; // used if nodenum[1] is a space. const char *newmsg; - CLEANUP(pfree) char *nodenum = (char*) malloc(3); + CLEANUP(pfree) char *nodenum = (char*)malloc(3); + if (!nodenum) + I_Error("HU_SendChatMessage: out of memory for sending pm\n"); // what we're gonna do now is check if the node exists // with that logic, characters 4 and 5 are our numbers: diff --git a/src/k_director.c b/src/k_director.c index 8fd5ab960..34bf367b6 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -446,6 +446,12 @@ void K_UpdateDirector(void) } } + // not sure if we should just stop here? + if (targetposition == MAXPLAYERS) + { + break; + } + target = directorinfo.sortedplayers[targetposition]; // stop here since we're already viewing this player diff --git a/src/mserv.c b/src/mserv.c index c91dacfcf..25ff733cb 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -599,9 +599,14 @@ Update_parameters (void) delayed = MSInProgress; if (delayed)/* do another update after the current one */ + { + registered = 0; MSUpdateAgain = true; + } else + { registered = MSRegistered; + } } Unlock_state(); diff --git a/src/p_enemy.c b/src/p_enemy.c index 3e83bec0c..d1c96d6f7 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -5344,6 +5344,11 @@ void A_MixUp(void *thing) } } + // idk if we ever really end up here + // but bad things would happen if we do without this + if (one == -1) + return; + //get this done first! tempthing = players[one].mo->tracer; P_SetTarget(&players[one].mo->tracer, players[two].mo->tracer); diff --git a/src/p_mobj.c b/src/p_mobj.c index daef6d1e9..28b85dea6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -5620,13 +5620,15 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale) void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on your target { fixed_t dist, ndist, speedmul; - fixed_t tx = dest->x; - fixed_t ty = dest->y; - fixed_t tz = dest->z + (dest->height/2); // Aim for center + fixed_t tx, ty, tz; if (!dest || dest->health <= 0 || !dest->player || !source->tracer) return; + tx = dest->x; + ty = dest->y; + tz = dest->z + (dest->height/2); // Aim for center + // change slope dist = P_AproxDistance(P_AproxDistance(tx - source->x, ty - source->y), tz - source->z); diff --git a/src/r_data.c b/src/r_data.c index f0a075217..43ff16cbb 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -1366,7 +1366,7 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap) colormap_p = colormap_p2 = colormaps; colormap_p += COLORMAP_REMAPOFFSET; - for (p = 0; p < 32; p++) + for (p = 0; p < LIGHTLEVELS; p++) { for (i = 0; i < 256; i++) { @@ -1588,7 +1588,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) // Calculate the palette index for each palette index, for each light level // (as well as the two unused colormap lines we inherited from Doom) - for (p = 0; p < 32; p++) + for (p = 0; p < LIGHTLEVELS; p++) { for (i = 0; i < 256; i++) { @@ -1622,7 +1622,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) { lighttable_t *colormap_p2 = extra_colormaps[mapnum].colormap; - for (p = 0; p < 32; p++) + for (p = 0; p < LIGHTLEVELS; p++) { for (i = 0; i < 256; i++) { diff --git a/src/r_draw_column.cpp b/src/r_draw_column.cpp index 67dbf94e3..526e136eb 100644 --- a/src/r_draw_column.cpp +++ b/src/r_draw_column.cpp @@ -204,7 +204,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc) intptr_t frac; // Looks familiar. const intptr_t fracstep = dc->iscale; - const intptr_t heightmask = dc->sourcelength-1; // CPhipps - specify type + intptr_t heightmask = dc->sourcelength-1; // CPhipps - specify type constexpr INT32 npow2min = -1; const INT32 npow2max = dc->sourcelength; @@ -237,10 +237,10 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc) // Determine scaling, which is the only mapping to be done. frac = (dc->texturemid + FixedMul((dc->yl << FRACBITS) - centeryfrac, fracstep)); - switch (heightmask) + switch (dc->sourcelength) { - case 255: - case 127: + case 256: + case 128: { while (count--) { @@ -251,7 +251,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc) } } break; - case npow2min: + case 0: { if (frac < 0) // adjust in case we underread @@ -269,42 +269,22 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc) break; default: { - if (!(dc->sourcelength & heightmask)) // power of 2 -- killough + if (dc->sourcelength & heightmask) // not a power of 2 -- killough { - while ((count -= 2) >= 0) // texture height is a power of 2 -- killough - { - *dest = R_DrawColumnPixel(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap); - - dest += stride; - frac += fracstep; - - *dest = R_DrawColumnPixel(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap); - - dest += stride; - frac += fracstep; - } - - if (count & 1) - { - *dest = R_DrawColumnPixel(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap); - } - } - else - { - const intptr_t fixed_heightmask = dc->texheight << FRACBITS; + heightmask = dc->texheight << FRACBITS; if (frac < 0) { - while ((frac += fixed_heightmask) < 0) + while ((frac += heightmask) < 0) { ; } } else { - while (frac >= fixed_heightmask) + while (frac >= heightmask) { - frac -= fixed_heightmask; + frac -= heightmask; } } @@ -324,7 +304,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc) // Avoid overflow. if (fracstep > 0x7FFFFFFF - frac) { - frac += fracstep - fixed_heightmask; + frac += fracstep - heightmask; } else #endif @@ -332,13 +312,33 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc) frac += fracstep; } - while (frac >= fixed_heightmask) + while (frac >= heightmask) { - frac -= fixed_heightmask; + frac -= heightmask; } } while (--count); } + else + { + while ((count -= 2) >= 0) // texture height is a power of 2 -- killough + { + *dest = R_DrawColumnPixel(dc, dest, ((frac>>FRACBITS) & heightmask), source, colormap); + + dest += stride; + frac += fracstep; + + *dest = R_DrawColumnPixel(dc, dest, ((frac>>FRACBITS) & heightmask), source, colormap); + + dest += stride; + frac += fracstep; + } + + if (count & 1) + { + *dest = R_DrawColumnPixel(dc, dest, ((frac>>FRACBITS) & heightmask), source, colormap); + } + } } break; } diff --git a/src/s_sound.c b/src/s_sound.c index 2c0466c46..9ca078cec 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1286,7 +1286,8 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde CONS_Alert(CONS_WARNING, "MUSICDEF: Field '%s' is missing name. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); - goto skip_lump; + (void)strtok(NULL, " "); + return true; } else { @@ -1304,14 +1305,10 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde (*defp) = def; } - -skip_lump: - stoken = strtok(NULL, " "); - line++; } else { - value = strtok(NULL, ""); + value = strtok(NULL, " "); if (value) { @@ -1324,7 +1321,8 @@ skip_lump: CONS_Alert(CONS_WARNING, "MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); - goto skip_field; + (void)strtok(NULL, " "); + return true; } else { @@ -1376,10 +1374,6 @@ skip_lump: else CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); #undef ADDDEF - -skip_field: - stoken = strtok(NULL, "= "); - line++; } } @@ -1404,7 +1398,8 @@ void S_LoadMusicDefs(UINT16 wadnum) for (int k = 0; k < 2; k++) { - lumpnum = W_CheckNumForNamePwad((k == 1 ? "MUSCINFO" : "MUSICDEF") , wadnum, 0); //check for MUSCINFO lump on 2nd iteration + const char *lumpname = (k == 1 ? "MUSCINFO" : "MUSICDEF"); + lumpnum = W_CheckNumForNamePwad(lumpname, wadnum, 0); //check for MUSCINFO lump on 2nd iteration if (lumpnum == INT16_MAX) continue; @@ -1430,7 +1425,7 @@ void S_LoadMusicDefs(UINT16 wadnum) nlf = 1; else nlf = 0; - *lf++ = '\0';/* now we can delimit to here */ + *lf++ = '\0'; /* now we can delimit to here */ } stoken = strtok(stoken, " "); @@ -1452,10 +1447,10 @@ void S_LoadMusicDefs(UINT16 wadnum) } while (nlf || ncr) ; - stoken = lf;/* now the next nonempty line */ + stoken = lf; /* now the next nonempty line */ } else - break;/* EOF */ + break; /* EOF */ } free(musdeftext); diff --git a/src/w_wad.c b/src/w_wad.c index 2ac8ae68d..3b4a5824f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1269,7 +1269,7 @@ FUNCINLINE static ATTRINLINE lumpnum_t CheckLumpInCache(const char *name) FUNCINLINE static ATTRINLINE void AddLumpToCache(lumpnum_t lumpnum, const char *name) { - I_Assert(strlen(name) <= 8); // we dont have longnames, so assume this is a non terminated string + I_Assert(strnlen(name, 9) <= 8); // we dont have longnames, so assume this is a non terminated string lumpnum_map_insert(&lumpnumcache, strdup(name), lumpnum); } From b44e003ab97f6f6508ba04fe1d119b0573d03721 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 29 Mar 2026 00:29:38 +0300 Subject: [PATCH 243/589] This is intended to be empty string, this way it reads the rest of the string including '=' :p --- src/s_sound.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index 9ca078cec..59f80ac5d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1308,7 +1308,7 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde } else { - value = strtok(NULL, " "); + value = strtok(NULL, ""); if (value) { @@ -1346,6 +1346,7 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde // turn _ into spaces. #define ADDDEF(field)\ + CONS_Printf("%s = %s\n",#field, textline); \ STRBUFCPY(def->field, textline);\ for (textline = def->field; *textline; textline++)\ if (*textline == '_') *textline = ' '; From 6760546bcd5facc000327e8be0c56d21022193d7 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 29 Mar 2026 00:34:11 +0300 Subject: [PATCH 244/589] I thought i reverted debug print aaaaaaaa --- src/s_sound.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index 59f80ac5d..5b959e063 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1346,7 +1346,6 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde // turn _ into spaces. #define ADDDEF(field)\ - CONS_Printf("%s = %s\n",#field, textline); \ STRBUFCPY(def->field, textline);\ for (textline = def->field; *textline; textline++)\ if (*textline == '_') *textline = ' '; From 06a9ab785e09c7b16d306d9572113ce135d1638b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Mar 2026 22:59:30 +0100 Subject: [PATCH 245/589] add misssing break K_SpawnBattlePoints oopsie, somehow this seems to never caused any issues? --- src/k_kart.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/k_kart.c b/src/k_kart.c index 3ba8ce8a2..8dc651ecc 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2372,6 +2372,7 @@ void K_SpawnBattlePoints(player_t *source, player_t *victim, UINT8 amount) break; case 3: st = S_BATTLEPOINT3A; + break; default: return; // NO STATE! } From cd766603146018b4aee18a12e7f55219f16dc19f Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Mar 2026 23:38:45 +0100 Subject: [PATCH 246/589] restore intended behavior for cvar menu categories for onchange functions --- src/lua_consolelib.c | 55 +++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index f9d36e2cf..0f6b74f88 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -358,7 +358,8 @@ static int lib_cvRegisterVar(lua_State *L) #define TYPEERROR(f, t) FIELDERROR(f, va("%s expected, got %s", lua_typename(L, t), luaL_typename(L, -1))) lua_pushnil(L); - while (lua_next(L, 1)) { + while (lua_next(L, 1)) + { // stack: cvar table, cvar userdata, key/index, value // 1 2 3 4 i = 0; @@ -368,26 +369,40 @@ static int lib_cvRegisterVar(lua_State *L) else if (lua_isstring(L, 3)) k = lua_tostring(L, 3); - if (i == 1 || (k && fasticmp(k, "name"))) { + if (i == 1 || (k && fasticmp(k, "name"))) + { if (!lua_isstring(L, 4)) TYPEERROR("name", LUA_TSTRING) + cvar->name = Z_StrDup(lua_tostring(L, 4)); - } else if (i == 2 || (k && fasticmp(k, "defaultvalue"))) { + } + else if (i == 2 || (k && fasticmp(k, "defaultvalue"))) + { if (!lua_isstring(L, 4)) TYPEERROR("defaultvalue", LUA_TSTRING) + cvar->defaultvalue = Z_StrDup(lua_tostring(L, 4)); - } else if (i == 3 || (k && fasticmp(k, "flags"))) { + } + else if (i == 3 || (k && fasticmp(k, "flags"))) + { if (!lua_isnumber(L, 4)) TYPEERROR("flags", LUA_TNUMBER) + cvar->flags = (INT32)lua_tointeger(L, 4); - } else if (i == 4 || (k && fasticmp(k, "PossibleValue"))) { - if (lua_islightuserdata(L, 4)) { + } + else if (i == 4 || (k && fasticmp(k, "PossibleValue"))) + { + if (lua_islightuserdata(L, 4)) + { CV_PossibleValue_t *pv = lua_touserdata(L, 4); + if (pv == CV_OnOff || pv == CV_YesNo || pv == CV_Unsigned || pv == CV_Natural) cvar->PossibleValue = pv; else FIELDERROR("PossibleValue", "CV_PossibleValue_t expected, got unrecognised pointer") - } else if (lua_istable(L, 4)) { + } + else if (lua_istable(L, 4)) + { // Accepts tables in the form of {MIN=0, MAX=9999} or {Red=0, Green=1, Blue=2} // and converts them to CV_PossibleValue_t {{0,"MIN"},{9999,"MAX"}} or {{0,"Red"},{1,"Green"},{2,"Blue"}} // @@ -398,7 +413,9 @@ static int lib_cvRegisterVar(lua_State *L) CV_PossibleValue_t *cvpv; lua_pushnil(L); - while (lua_next(L, 4)) { + + while (lua_next(L, 4)) + { count++; lua_pop(L, 1); } @@ -412,7 +429,9 @@ static int lib_cvRegisterVar(lua_State *L) i = 0; lua_pushnil(L); - while (lua_next(L, 4)) { + + while (lua_next(L, 4)) + { // stack: [...] PossibleValue table, index, value // 4 5 6 if (lua_type(L, 5) != LUA_TSTRING @@ -423,14 +442,19 @@ static int lib_cvRegisterVar(lua_State *L) i++; lua_pop(L, 1); } + cvpv[i].value = 0; cvpv[i].strvalue = NULL; cvar->PossibleValue = cvpv; - } else + } + else FIELDERROR("PossibleValue", va("%s or CV_PossibleValue_t expected, got %s", lua_typename(L, LUA_TTABLE), luaL_typename(L, -1))) - } else if (i == 5 || (k && fasticmp(k, "func"))) { + } + else if (i == 5 || (k && fasticmp(k, "func"))) + { if (!lua_isfunction(L, 4)) TYPEERROR("func", LUA_TFUNCTION) + lua_getfield(L, LUA_REGISTRYINDEX, "CV_OnChange"); I_Assert(lua_istable(L, 5)); lua_pushlightuserdata(L, cvar); @@ -438,9 +462,13 @@ static int lib_cvRegisterVar(lua_State *L) lua_rawset(L, 5); lua_pop(L, 1); cvar->func = Lua_OnChange; + + if (i == 5 && !(cvar->flags & CV_CALL)) + { + category = lua_isnoneornil(L, 4) ? NULL : lua_tostring(L, 4); + } } - else if (((i == 5 && !(cvar->flags & CV_CALL)) - || (cvar->flags & CV_CALL && i == 6)) + else if ((cvar->flags & CV_CALL && i == 6) || (k && fasticmp(k, "category"))) { category = lua_isnoneornil(L, 4) ? NULL : lua_tostring(L, 4); @@ -451,6 +479,7 @@ static int lib_cvRegisterVar(lua_State *L) { menu_name = lua_isnoneornil(L, 4) ? NULL : lua_tostring(L, 4); } + lua_pop(L, 1); } #undef FIELDERROR From 17d72e02fe6cf0f9f18ed5b3cf973a0cc497b499 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Mar 2026 23:39:17 +0100 Subject: [PATCH 247/589] cleanup some redundant/dead code --- src/command.c | 2 +- src/console.c | 2 +- src/d_clisrv.c | 18 ++++------ src/g_demo.c | 72 +++++++++++++++++---------------------- src/g_game.c | 1 - src/hardware/hw_draw.c | 4 +-- src/k_hud.c | 4 +-- src/k_kart.c | 11 ++---- src/lua_hudlib_drawlist.c | 57 +++++++++++++++---------------- src/m_menu.c | 2 +- src/m_textinput.c | 10 +++--- src/p_enemy.c | 8 ++--- src/p_inter.c | 22 +----------- src/p_local.h | 1 - src/p_user.c | 38 +++------------------ src/r_bsp.cpp | 1 - src/r_data.c | 44 +----------------------- src/r_data.h | 3 -- src/r_plane.cpp | 5 +-- src/r_things.h | 2 +- src/st_stuff.c | 2 +- src/y_inter.c | 10 ------ 22 files changed, 94 insertions(+), 225 deletions(-) diff --git a/src/command.c b/src/command.c index c37b8f1d3..be46e2505 100644 --- a/src/command.c +++ b/src/command.c @@ -1194,7 +1194,7 @@ consvar_t *CV_FindVar(const char *name) static inline UINT16 CV_ComputeNetid(const char *s) { UINT16 ret = 0, i = 0; - static UINT16 premiers[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53}; + static const UINT16 premiers[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53}; while (*s) { diff --git a/src/console.c b/src/console.c index df7fc299d..50d10d020 100644 --- a/src/console.c +++ b/src/console.c @@ -852,7 +852,7 @@ boolean CON_Responder(event_t *ev) return true; // ctrl modifier -- changes behavior, adds shortcuts - if (ctrldown && (cv_keyboardlayout.value != 3 || (cv_keyboardlayout.value == 3 && !altdown))) + if (ctrldown && (cv_keyboardlayout.value != 3 || !altdown)) { // show all cvars/commands that match what we have inputted if (key == KEY_TAB) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 02febde12..f5e32b2e0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2509,7 +2509,7 @@ static boolean CL_FinishedFileList(void) * \sa CL_ConnectToServer * */ -static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) +static void CL_ServerConnectionSearchTicker(tic_t *asksent) { INT32 i; @@ -2527,7 +2527,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) { i = SL_SearchServer(servernode); if (i < 0) - return true; + return; } joinnode = i; @@ -2555,7 +2555,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) { cl_mode = CL_ASKFULLFILELIST; cl_lastcheckedfilecount = 0; - return true; + return; } cl_mode = cv_serverinfoscreen.value ? CL_VIEWSERVER : CL_CHECKFILES; @@ -2566,7 +2566,7 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) *asksent = 0; } - return true; + return; } // Ask the info to the server (askinfo packet) @@ -2576,7 +2576,6 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) *asksent = I_GetTime() + NEWTICRATE; } - return true; } static void FreeMapIcon(void) @@ -2608,8 +2607,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic switch (cl_mode) { case CL_SEARCHING: - if (!CL_ServerConnectionSearchTicker(asksent)) - return false; + CL_ServerConnectionSearchTicker(asksent); break; case CL_ASKFULLFILELIST: @@ -5905,13 +5903,11 @@ static void PT_ServerTics(SINT8 node) realend = gametic + CLIENTBACKUPTICS; cl_packetmissed = realstart > neededtic; - UINT8 *pak = (UINT8 *)&packet->cmds; - UINT8 *txtpak = (UINT8 *)&packet->cmds[packet->numslots * packet->numtics]; - if (realstart <= neededtic && realend > neededtic) { tic_t i, j; - pak = (UINT8 *)&packet->cmds; + UINT8 *pak = (UINT8 *)&packet->cmds; + UINT8 *txtpak = (UINT8 *)&packet->cmds[packet->numslots * packet->numtics]; for (i = realstart; i < realend; i++) { diff --git a/src/g_demo.c b/src/g_demo.c index 4acbba9f5..c36b3273b 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1996,7 +1996,6 @@ static UINT8 G_CheckDemoExtraFiles(UINT8 **pp, boolean quick) UINT8 totalfiles, filesloaded, nmusfilecount; char filename[MAX_WADPATH]; UINT8 md5sum[16]; - boolean toomany = false; boolean alreadyloaded; UINT8 i, j; UINT8 error = 0; @@ -2006,53 +2005,44 @@ static UINT8 G_CheckDemoExtraFiles(UINT8 **pp, boolean quick) for (i = 0; i < totalfiles; ++i) { - if (toomany) - SKIPSTRING((*pp)); - else - { - strlcpy(filename, (char *)(*pp), sizeof filename); - SKIPSTRING((*pp)); - } + strlcpy(filename, (char *)(*pp), sizeof filename); + SKIPSTRING((*pp)); READMEM((*pp), md5sum, 16); // hue hue peepee - if (!toomany) + alreadyloaded = false; + nmusfilecount = 0; + + for (j = 0; j < numwadfiles; ++j) { - alreadyloaded = false; - nmusfilecount = 0; - - for (j = 0; j < numwadfiles; ++j) - { - if (wadfiles[j]->important && j > mainwads) - nmusfilecount++; - else - continue; - - if (memcmp(md5sum, wadfiles[j]->md5sum, 16) == 0) - { - alreadyloaded = true; - - if (i != nmusfilecount-1 && error < DFILE_ERROR_OUTOFORDER) - error |= DFILE_ERROR_OUTOFORDER; - - break; - } - } - - if (alreadyloaded) - { - filesloaded++; + if (wadfiles[j]->important && j > mainwads) + nmusfilecount++; + else continue; - } - if (numwadfiles >= MAX_WADFILES) - error = DFILE_ERROR_CANNOTLOAD; - else if (!quick && findfile(filename, md5sum, false) != FS_FOUND) - error = DFILE_ERROR_CANNOTLOAD; - else if (error < DFILE_ERROR_INCOMPLETEOUTOFORDER) - error |= DFILE_ERROR_NOTLOADED; - } else + if (memcmp(md5sum, wadfiles[j]->md5sum, 16) == 0) + { + alreadyloaded = true; + + if (i != nmusfilecount-1 && error < DFILE_ERROR_OUTOFORDER) + error |= DFILE_ERROR_OUTOFORDER; + + break; + } + } + + if (alreadyloaded) + { + filesloaded++; + continue; + } + + if (numwadfiles >= MAX_WADFILES) error = DFILE_ERROR_CANNOTLOAD; + else if (!quick && findfile(filename, md5sum, false) != FS_FOUND) + error = DFILE_ERROR_CANNOTLOAD; + else if (error < DFILE_ERROR_INCOMPLETEOUTOFORDER) + error |= DFILE_ERROR_NOTLOADED; } // Get final file count diff --git a/src/g_game.c b/src/g_game.c index 6b01b2bdc..f41e7ad79 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4047,7 +4047,6 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool if (W_CheckNumForName(mapname) == LUMPERROR) { I_Error("Internal game map '%s' not found\n", mapname); - Command_ExitGame_f(); return; } diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 3602cef1b..7bccbe198 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -150,7 +150,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p if (!column->topdelta) { const UINT8 *source = (const UINT8 *)(column) + 3; - HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); + HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, source[0]); } } @@ -302,7 +302,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, if (!column->topdelta) { const UINT8 *source = (const UINT8 *)(column) + 3; - HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); + HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, source[0]); } } diff --git a/src/k_hud.c b/src/k_hud.c index 3fc83c10b..3ec17ddd0 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2094,7 +2094,7 @@ static void K_DrawKartPositionNum(INT32 num) fy = POSI_Y; fflags = V_SNAPTOLEFT|((stplyrnum == 2) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. flipdraw = true; - if (num && num >= 10) + if (num >= 10) fx += W; // this seems dumb, but we need to do this in order for positions above 10 going off screen. } else // else, that means we're P2 or P4. @@ -4076,7 +4076,7 @@ static void K_drawBattleFullscreen(void) { if (i == displayplayers[0]) continue; - if (playeringame[i] && !stplyr->spectator) + if (playeringame[i]) return; } diff --git a/src/k_kart.c b/src/k_kart.c index 8dc651ecc..ec312cc3b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1955,11 +1955,9 @@ static void K_PlayGenericCombatSound(mobj_t *source, mobj_t *other, sfxenum_t sf if (!skin) return; - boolean alwaysHear = false; - if (cv_kartvoices.value && !P_MobjWasRemoved(other) && other->player != NULL) { - alwaysHear = P_IsDisplayPlayer(other->player); + boolean alwaysHear = P_IsDisplayPlayer(other->player); S_StartSound(alwaysHear ? NULL : source, skin->soundsid[S_sfx[sfx_id].skinsound]); } @@ -3678,10 +3676,8 @@ mobj_t *K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) dust->momx = mo->momx/2; dust->momy = mo->momy/2; dust->momz = mo->momz/2; - } - - if (translucent) dust->flags2 |= MF2_SHADOW; + } return dust; } @@ -4658,8 +4654,7 @@ void K_RepairOrbitChain(mobj_t *orbit) prev->movedir = num; } - if (player->kartstuff[k_itemamount] != num) - player->kartstuff[k_itemamount] = num; + player->kartstuff[k_itemamount] = num; } } diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index 6d3542c48..d2b2eeeb4 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -650,34 +650,34 @@ void LUA_HUD_DrawList(huddrawlist_h list) case DI_DrawString: switch(item->align) { - // hu_font - case align_left: - V_DrawString(LERPS(x), LERPS(y), item->flags, itemstr); - break; - case align_center: - V_DrawCenteredString(LERPS(x), LERPS(y), item->flags, itemstr); - break; - case align_right: - V_DrawRightAlignedString(LERPS(x), LERPS(y), item->flags, itemstr); - break; - case align_fixed: - V_DrawStringAtFixed(LERPS(x), LERPS(y), item->flags, itemstr); - break; - // hu_font, 0.5x scale - case align_small: - V_DrawSmallString(LERPS(x), LERPS(y), item->flags, itemstr); - break; - case align_smallright: - V_DrawRightAlignedSmallString(LERPS(x), LERPS(y), item->flags, itemstr); - break; - // tny_font - case align_thin: - V_DrawThinString(LERPS(x), LERPS(y), item->flags, itemstr); - break; - case align_thinright: - V_DrawRightAlignedThinString(LERPS(x), LERPS(y), item->flags, itemstr); - break; - } + // hu_font + case align_left: + V_DrawString(LERPS(x), LERPS(y), item->flags, itemstr); + break; + case align_center: + V_DrawCenteredString(LERPS(x), LERPS(y), item->flags, itemstr); + break; + case align_right: + V_DrawRightAlignedString(LERPS(x), LERPS(y), item->flags, itemstr); + break; + case align_fixed: + V_DrawStringAtFixed(LERPS(x), LERPS(y), item->flags, itemstr); + break; + // hu_font, 0.5x scale + case align_small: + V_DrawSmallString(LERPS(x), LERPS(y), item->flags, itemstr); + break; + case align_smallright: + V_DrawRightAlignedSmallString(LERPS(x), LERPS(y), item->flags, itemstr); + break; + // tny_font + case align_thin: + V_DrawThinString(LERPS(x), LERPS(y), item->flags, itemstr); + break; + case align_thinright: + V_DrawRightAlignedThinString(LERPS(x), LERPS(y), item->flags, itemstr); + break; + } break; case DI_DrawKartString: V_DrawKartString(LERPS(x), LERPS(y), item->flags, itemstr); @@ -690,7 +690,6 @@ void LUA_HUD_DrawList(huddrawlist_h list) break; default: I_Error("can't draw draw list item: invalid draw list item type"); - continue; } } } diff --git a/src/m_menu.c b/src/m_menu.c index cfc854d36..01b106d95 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5418,7 +5418,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na } if (cvar->flags & CV_NETVAR) - OP_CustomCvarMenu[ccvarposition] = (menuitem_t){ IT_STRING | IT_CVAR , NULL, Z_StrDup(va("\x85 %s", name)), cvar, ccvaralphakey }; + OP_CustomCvarMenu[ccvarposition] = (menuitem_t){ IT_STRING | IT_CVAR, NULL, Z_StrDup(va("\x85 %s", name)), cvar, ccvaralphakey }; else OP_CustomCvarMenu[ccvarposition] = (menuitem_t){ IT_STRING | IT_CVAR, NULL, Z_StrDup(name), cvar, ccvaralphakey }; diff --git a/src/m_textinput.c b/src/m_textinput.c index c49294094..a7c048e66 100644 --- a/src/m_textinput.c +++ b/src/m_textinput.c @@ -256,7 +256,7 @@ static boolean M_TextInputHandleBase(textinput_t *input, INT32 key, boolean emot return true; } - if (ctrldown && (cv_keyboardlayout.value != 3 || (cv_keyboardlayout.value == 3 && !altdown))) + if (ctrldown && (cv_keyboardlayout.value!=3 || !altdown)) { if (key == 'x' || key == 'X') { @@ -381,10 +381,10 @@ static boolean M_TextInputHandleBase(textinput_t *input, INT32 key, boolean emot // allow people to use keypad in console (good for typing IP addresses) - Calum if (key >= KEY_KEYPAD7 && key <= KEY_KPADDEL) { - char keypad_translation[] = {'7','8','9','-', - '4','5','6','+', - '1','2','3', - '0','.'}; + const char keypad_translation[] = {'7','8','9','-', + '4','5','6','+', + '1','2','3', + '0', '.'}; key = keypad_translation[key - KEY_KEYPAD7]; } diff --git a/src/p_enemy.c b/src/p_enemy.c index d1c96d6f7..cb9b16f2d 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3650,7 +3650,7 @@ static inline boolean PIT_GrenadeRing(mobj_t *thing) return true; if (thing->player && (thing->player->kartstuff[k_hyudorotimer] - || (G_BattleGametype() && thing->player && thing->player->kartstuff[k_bumper] <= 0 && thing->player->kartstuff[k_comebacktimer]))) + || (G_BattleGametype() && thing->player->kartstuff[k_bumper] <= 0 && thing->player->kartstuff[k_comebacktimer]))) return true; if ((gametype == GT_CTF || gametype == GT_TEAMMATCH) @@ -5301,7 +5301,7 @@ void A_MixUp(void *thing) if (playeringame[i] && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE && !players[i].exiting && !players[i].powers[pw_super]) { - if ((netgame || multiplayer) && players[i].spectator) // Ignore spectators + if (netgame && players[i].spectator) // Ignore spectators continue; numplayers++; @@ -7923,7 +7923,7 @@ void A_ItemPop(void *thing) if (!(actor->target && actor->target->player)) { - if (cv_debug && !(actor->target && actor->target->player)) + if (cv_debug) CONS_Printf("ERROR: Powerup has no target!\n"); return; } @@ -8785,7 +8785,7 @@ void A_ReaperThinker(void *thing) actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); // The player we should target if it's near us: - for (i = 0; ipowers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL) - return; - if (UNLIKELY(maptol & TOL_NIGHTS)) - return; - if (UNLIKELY(mariomode)) - return; - else if (toucher->eflags & MFE_VERTICALFLIP) - { - if (special->z+special->height < toucher->z + toucher->height / 3 - || special->z+special->height > toucher->z + (toucher->height*2/3)) - return; // Only go in the mouth - } - else if (special->z < toucher->z + toucher->height / 3 - || special->z > toucher->z + (toucher->height*2/3)) - return; // Only go in the mouth - - toucher->momx = toucher->momy = toucher->momz = 0; - break; case MT_WATERDROP: if (special->state == &states[special->info->spawnstate]) @@ -1877,11 +1859,9 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) P_SetThingPosition(target); P_InstaThrust(target,target->angle,FixedMul(2*FRACUNIT, target->scale)); target->momz = FixedMul(7*FRACUNIT, target->scale); - if (flip) - target->momz = -target->momz; - if (flip) { + target->momz = -target->momz; target = P_SpawnMobj(x,y,z-FixedMul(12*FRACUNIT, target->scale),MT_SPIKE); target->eflags |= MFE_VERTICALFLIP; } diff --git a/src/p_local.h b/src/p_local.h index 518bc12cb..95020c022 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -212,7 +212,6 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj); void P_GivePlayerRings(player_t *player, INT32 num_rings); void P_GivePlayerLives(player_t *player, INT32 numlives); UINT8 P_GetNextEmerald(void); -void P_GiveEmerald(boolean spawnObj); void P_ResetScore(player_t *player); boolean P_AutoPause(void); diff --git a/src/p_user.c b/src/p_user.c index 7c4756bfa..f57739c92 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -220,32 +220,6 @@ UINT8 P_GetNextEmerald(void) return (UINT8)(gamemap - sstage_start); } -// -// P_GiveEmerald -// -// Award an emerald upon completion -// of a special stage. -// -void P_GiveEmerald(boolean spawnObj) -{ - INT32 i; - UINT8 em; - - S_StartSound(NULL, sfx_cgot); // Got the emerald! - em = P_GetNextEmerald(); - emeralds |= (1 << em); - - if (spawnObj) - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i]) - P_SetMobjState(P_SpawnMobj(players[i].mo->x, players[i].mo->y, players[i].mo->z + players[i].mo->info->height, MT_GOTEMERALD), - mobjinfo[MT_GOTEMERALD].spawnstate + em); - } - } -} - // // P_ResetScore // @@ -1226,7 +1200,6 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost->pitch = mobj->pitch; ghost->roll = mobj->roll; - ghost->sloperoll = mobj->sloperoll; ghost->rollangle = mobj->rollangle; ghost->sloperoll = mobj->sloperoll; ghost->slopepitch = mobj->slopepitch; @@ -3130,19 +3103,16 @@ void P_ToggleDemoCamera(UINT8 viewnum) return; } - if (!cam->freecam) // toggle on + if (!cam->freecam) // toggle on { cam->freecam = true; cam->button_a_held = 2; cam->reset_aiming = true; // get rid of some hud elements - if (displayplayers[0] != consoleplayer) - { - displayplayers[0] = consoleplayer; - } + displayplayers[0] = consoleplayer; } - else // toggle off + else // toggle off { cam->freecam = false; G_FixCamera(viewnum+1); @@ -4056,7 +4026,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (timeover) thiscam->angle = angle; - else if (!camstill && !resetcalled && !paused && timeover != 1) + else if (!camstill && !resetcalled && !paused) thiscam->angle = R_PointToAngle2(thiscam->x, thiscam->y, viewpointx, viewpointy); if (timeover == 1) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 55a475c9d..60d84c57f 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -991,7 +991,6 @@ static void R_Subsector(size_t num) visffloor[numffloors].height = polysec->floorheight; visffloor[numffloors].polyobj = po; visffloor[numffloors].slope = NULL; -// visffloor[numffloors].ffloor = rover; po->visplane = visffloor[numffloors].plane; numffloors++; } diff --git a/src/r_data.c b/src/r_data.c index 43ff16cbb..507696925 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -37,44 +37,6 @@ // Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog #include -// -// Texture definition. -// Each texture is composed of one or more patches, -// with patches being lumps stored in the WAD. -// The lumps are referenced by number, and patched -// into the rectangular texture space using origin -// and possibly other attributes. -// -typedef struct -{ - INT16 originx, originy; - INT16 patch, stepdir, colormap; -} ATTRPACK mappatch_t; - -// -// Texture definition. -// An SRB2 wall texture is a list of patches -// which are to be combined in a predefined order. -// -typedef struct -{ - char name[8]; - INT32 masked; - INT16 width; - INT16 height; - INT32 columndirectory; // FIXTHIS: OBSOLETE - INT16 patchcount; - mappatch_t patches[1]; -} ATTRPACK maptexture_t; - -// Store lists of lumps for F_START/F_END etc. -typedef struct -{ - UINT16 wadfile; - UINT16 firstlump; - size_t numlumps; -} lumplist_t; - // // Graphics. // SRB2 graphics for walls and sprites @@ -836,11 +798,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) } else { - if (patchName != NULL) - { - Z_Free(patchName); - } - + Z_Free(patchName); patchName = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL); memcpy(patchName,texturesToken,texturesTokenLength*sizeof(char)); patchName[texturesTokenLength] = '\0'; diff --git a/src/r_data.h b/src/r_data.h index 090c363ed..168f72bf0 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -45,9 +45,6 @@ enum TEXTURETYPE_COMPOSITE, }; -// A maptexturedef_t describes a rectangular texture, -// which is composed of one or more mappatch_t structures -// that arrange graphic patches. typedef struct { // Keep name for switch changing, etc. diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 05c4d943a..a6a52fe83 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1282,10 +1282,7 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle else { // Don't mess with angle on slopes! We'll handle this ourselves later - if (viewangle != pl->viewangle + pl->plangle) - { - viewangle = pl->viewangle + pl->plangle; - } + viewangle = pl->viewangle + pl->plangle; ds->planeheight = abs(pl->height - pl->viewz); ds->planezlight = zlight[light]; diff --git a/src/r_things.h b/src/r_things.h index c8195891a..e8e30ca6b 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -50,7 +50,7 @@ extern fixed_t windowtop; extern fixed_t windowbottom; extern INT32 lengthcol; -FUNCINLINE static ATTRINLINE INT32 R_ThingLightLevel(mobj_t* thing) +FUNCINLINE static ATTRINLINE INT32 R_ThingLightLevel(const mobj_t* thing) { return (INT32)thing->lightlevel; } diff --git a/src/st_stuff.c b/src/st_stuff.c index 64bc4dc00..57a7c6e29 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -185,7 +185,7 @@ static void ST_doPaletteStuff(void) #endif if (stplyr && stplyr->flashcount) - palette = CLAMP(stplyr->flashpal, 0, 13); + palette = min(stplyr->flashpal, 13); if (palette != st_palette) { diff --git a/src/y_inter.c b/src/y_inter.c index 27e794ffc..684797999 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -51,13 +51,6 @@ #include "hardware/hw_main.h" #endif -typedef struct -{ - char patch[9]; - INT32 points; - UINT8 display; -} y_bonus_t; - static y_data_t data; // graphics @@ -1609,9 +1602,6 @@ void Y_SetupVoteFinish(SINT8 pick, SINT8 level) if (votes[i] == -1 || endtype > 1) // Don't need to go on continue; - if (endtype == 2) - continue; - if (votecompare == -1) { votecompare = votes[i]; From 621df7e29695900de025c7bde5a8f95ac9fd60fa Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 28 Mar 2026 23:36:10 +0100 Subject: [PATCH 248/589] v_video: make stringwidth loops safer --- src/v_video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 29857dd74..078e65b3c 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3235,7 +3235,7 @@ INT32 V_SubStringWidth(const char *string, INT32 length, INT32 option) break; } - for (i = 0; string[i] && i < length; i++) + for (i = 0; i < length && string[i]; i++) { c = string[i]; if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09 @@ -3280,7 +3280,7 @@ INT32 V_SmallSubStringWidth(const char *string, INT32 length, INT32 option) break; } - for (i = 0; string[i] && i < length; i++) + for (i = 0; i < length && string[i]; i++) { c = string[i]; if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09 @@ -3329,7 +3329,7 @@ INT32 V_ThinSubStringWidth(const char *string, INT32 length, INT32 option) break; } - for (i = 0; string[i] && i < length; i++) + for (i = 0; i < length && string[i]; i++) { c = string[i]; if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09 From 0fadfe0f72cfd1739db137248489ccb2bd7c89d5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Mar 2026 10:58:29 +0200 Subject: [PATCH 249/589] dehacked: fixup lua_enumlib_sprintf_upper apparently reusing a va list like that is ub, so we should just copy it if we want to reuse it also fix the resize check, since vsnprintf return does not include 0 terminator which we need to account for also make this part of dehacked.c a bit more readable lol --- src/dehacked.c | 134 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 106 insertions(+), 28 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 38f713092..a4082c6f2 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8208,84 +8208,109 @@ struct { {NULL,0} }; +// Returns the vlaue of MT_ enumerations static mobjtype_t get_mobjtype(const char *word) -{ // Returns the vlaue of MT_ enumerations +{ mobjtype_t i; + if (*word >= '0' && *word <= '9') return atoi(word); + if (fastncmp("MT_",word,3)) word += 3; // take off the MT_ - for (i = 0; i < NUMMOBJFREESLOTS; i++) { + + for (i = 0; i < NUMMOBJFREESLOTS; i++) + { if (!FREE_MOBJS[i]) break; if (fastcmp(word, FREE_MOBJS[i])) return MT_FIRSTFREESLOT+i; } + for (i = 0; i < MT_FIRSTFREESLOT; i++) if (fastcmp(word, MOBJTYPE_LIST[i]+3)) return i; + deh_warning("Couldn't find mobjtype named 'MT_%s'",word); return MT_BLUECRAWLA; } +// Returns the value of S_ enumerations static statenum_t get_state(const char *word) -{ // Returns the value of S_ enumerations +{ statenum_t i; if (*word >= '0' && *word <= '9') return atoi(word); + if (fastncmp("S_",word,2)) word += 2; // take off the S_ - for (i = 0; i < NUMSTATEFREESLOTS; i++) { + + for (i = 0; i < NUMSTATEFREESLOTS; i++) + { if (!FREE_STATES[i]) break; + if (fastcmp(word, FREE_STATES[i])) return S_FIRSTFREESLOT+i; } + for (i = 0; i < S_FIRSTFREESLOT; i++) if (fastcmp(word, STATE_LIST[i]+2)) return i; + deh_warning("Couldn't find state named 'S_%s'",word); return S_NULL; } +// Returns the value of SPR_ enumerations static spritenum_t get_sprite(const char *word) -{ // Returns the value of SPR_ enumerations +{ spritenum_t i; if (*word >= '0' && *word <= '9') return atoi(word); + if (fastncmp("SPR_",word,4)) word += 4; // take off the SPR_ + for (i = 0; i < NUMSPRITES; i++) - if (!sprnames[i][4] && memcmp(word,sprnames[i],4)==0) + if (!sprnames[i][4] && memcmp(word,sprnames[i],4) == 0) return i; + deh_warning("Couldn't find sprite named 'SPR_%s'",word); return SPR_NULL; } +// Returns the value of SFX_ enumerations static sfxenum_t get_sfx(const char *word) -{ // Returns the value of SFX_ enumerations +{ sfxenum_t i; + if (*word >= '0' && *word <= '9') return atoi(word); + if (fastncmp("SFX_",word,4)) word += 4; // take off the SFX_ else if (fastncmp("DS",word,2)) word += 2; // take off the DS + for (i = 0; i < NUMSFX; i++) if (S_sfx[i].name && fasticmp(word, S_sfx[i].name)) return i; + deh_warning("Couldn't find sfx named 'SFX_%s'",word); return sfx_None; } #ifdef MUSICSLOT_COMPATIBILITY +// Returns the value of MUS_ enumerations static UINT16 get_mus(const char *word, UINT8 dehacked_mode) -{ // Returns the value of MUS_ enumerations +{ UINT16 i; char lumptmp[4]; if (*word >= '0' && *word <= '9') return atoi(word); + if (!word[2] && toupper(word[0]) >= 'A' && toupper(word[0]) <= 'Z') return (UINT16)M_MapNumber(word[0], word[1]); @@ -8309,25 +8334,33 @@ static UINT16 get_mus(const char *word, UINT8 dehacked_mode) deh_warning("Couldn't find music named 'MUS_%s'",word); return 0; } + for (i = 0; compat_special_music_slots[i][0]; ++i) if (fasticmp(word, compat_special_music_slots[i])) return i + 1036; + if (dehacked_mode) deh_warning("Couldn't find music named 'MUS_%s'",word); + return 0; } #endif +// Returns the value of HUD_ enumerations static hudnum_t get_huditem(const char *word) -{ // Returns the value of HUD_ enumerations +{ hudnum_t i; + if (*word >= '0' && *word <= '9') return atoi(word); + if (fastncmp("HUD_",word,4)) word += 4; // take off the HUD_ + for (i = 0; i < NUMHUDITEMS; i++) if (fastcmp(word, HUDITEMS_LIST[i])) return i; + deh_warning("Couldn't find huditem named 'HUD_%s'",word); return HUD_LIVESNAME; } @@ -8374,15 +8407,16 @@ static inline int lib_freeslot(lua_State *L) { int n = lua_gettop(L); int r = 0; // args returned - char *s, *type,*word; + char *s, *type, *word; - while (n-- > 0) - { + while (n-- > 0) + { s = Z_StrDup(luaL_checkstring(L,1)); type = strtok(s, "_"); if (type) strupr(type); - else { + else + { Z_Free(s); return luaL_error(L, "Unknown enum type in '%s'\n", luaL_checkstring(L, 1)); } @@ -8390,19 +8424,25 @@ static inline int lib_freeslot(lua_State *L) word = strtok(NULL, "\n"); if (word) strupr(word); - else { + else + { Z_Free(s); return luaL_error(L, "Missing enum name in '%s'\n", luaL_checkstring(L, 1)); } - if (fastcmp(type, "SFX")) { + + if (fastcmp(type, "SFX")) + { sfxenum_t sfx; strlwr(word); CONS_Printf("Sound sfx_%s allocated.\n",word); sfx = S_AddSoundFx(word, false, 0, false); - if (sfx != sfx_None) { + + if (sfx != sfx_None) + { lua_pushinteger(L, sfx); r++; - } else + } + else I_Error("Out of Sfx Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); //Should never get here since S_AddSoundFx was changed to throw I_Error when it can't allocate } else if (fastcmp(type, "SPR")) @@ -8416,7 +8456,7 @@ static inline int lib_freeslot(lua_State *L) { if (used_spr[(j-SPR_FIRSTFREESLOT)/8] & (1<<(j%8))) { - if (!sprnames[j][4] && memcmp(sprnames[j],word,4)==0) + if (!sprnames[j][4] && memcmp(sprnames[j], word, 4) == 0) sprnames[j][4] = wad; continue; // Already allocated, next. } @@ -8434,6 +8474,7 @@ static inline int lib_freeslot(lua_State *L) r++; break; } + if (j > SPR_LASTFREESLOT) I_Error("Out of Sprite Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } @@ -8441,7 +8482,9 @@ static inline int lib_freeslot(lua_State *L) { statenum_t i; for (i = 0; i < NUMSTATEFREESLOTS; i++) - if (!FREE_STATES[i]) { + { + if (!FREE_STATES[i]) + { CONS_Printf("State S_%s allocated.\n",word); lua_pushcfunction(L, lua_glib_invalidate_cache); @@ -8455,6 +8498,8 @@ static inline int lib_freeslot(lua_State *L) r++; break; } + } + if (i == NUMSTATEFREESLOTS) I_Error("Out of State Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } @@ -8462,7 +8507,9 @@ static inline int lib_freeslot(lua_State *L) { mobjtype_t i; for (i = 0; i < NUMMOBJFREESLOTS; i++) - if (!FREE_MOBJS[i]) { + { + if (!FREE_MOBJS[i]) + { CONS_Printf("MobjType MT_%s allocated.\n",word); lua_pushcfunction(L, lua_glib_invalidate_cache); @@ -8476,13 +8523,17 @@ static inline int lib_freeslot(lua_State *L) r++; break; } + } + if (i == NUMMOBJFREESLOTS) I_Error("Out of Mobj Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } + Z_Free(s); lua_remove(L, 1); continue; } + return r; } @@ -8495,8 +8546,10 @@ static inline int lib_action(lua_State *L) mobj_t *actor = *((mobj_t **)luaL_checkudata(L,1,META_MOBJ)); var1 = (INT32)luaL_optinteger(L,2,0); var2 = (INT32)luaL_optinteger(L,3,0); + if (!actor) return LUA_ErrInvalid(L, "mobj_t"); + (*action)(actor); return 0; } @@ -8518,23 +8571,29 @@ FUNCINLINE static ATTRINLINE int lib_getenum(lua_State *L) const char *word; boolean mathlib = lua_toboolean(L, UV_MATHLIB); + if (lua_type(L,2) != LUA_TSTRING) return 0; + word = lua_tostring(L,2); /* First check actions, as they can be overridden. */ - if (!mathlib && fastncmp("A_",word,2)) { + if (!mathlib && fastncmp("A_",word,2)) + { char *caps; // Try to get a Lua action first. /// \todo Push a closure that sets superactions[] and superstack. lua_getfield(L, LUA_REGISTRYINDEX, LREG_ACTIONS); + // actions are stored in all uppercase. caps = Z_StrDup(word); strupr(caps); lua_getfield(L, -1, caps); Z_Free(caps); + if (!lua_isnil(L, -1)) return 1; // Success! :D That was easy. + // Welp, that failed. lua_pop(L, 2); // pop nil and LREG_ACTIONS // Hardcoded actions are handled by the proxy. @@ -8543,12 +8602,14 @@ FUNCINLINE static ATTRINLINE int lib_getenum(lua_State *L) /* Then check the globals proxy table. */ lua_pushvalue(L, 2); lua_gettable(L, GLIB_PROXY); + if (!lua_isnil(L, -1)) { return 1; } - if (mathlib) return luaL_error(L, "constant '%s' could not be parsed.\n", word); + if (mathlib) + return luaL_error(L, "constant '%s' could not be parsed.\n", word); return 0; } @@ -8606,6 +8667,7 @@ static int lua_enumlib_server_get(lua_State *L) { if ((!multiplayer || !(netgame || demo.playback)) && !playeringame[serverplayer]) return 0; + LUA_PushUserdata(L, &players[serverplayer], META_PLAYER); return 1; } @@ -8614,6 +8676,7 @@ static int lua_enumlib_consoleplayer_get(lua_State *L) { if (consoleplayer < 0 || !playeringame[consoleplayer]) return 0; + LUA_PushUserdata(L, &players[consoleplayer], META_PLAYER); return 1; } @@ -8806,12 +8869,15 @@ static int lua_enumlib_action_get(lua_State *L) const char *action = lua_tostring(L, 1); for (int i = 0; actionpointers[i].name; i++) - if (fasticmp(action, actionpointers[i].name)) { + { + if (fasticmp(action, actionpointers[i].name)) + { // push lib_action as a C closure with the actionf_t* as an upvalue. lua_pushlightuserdata(L, &actionpointers[i].action); lua_pushcclosure(L, lib_action, 1); return 1; } + } return 0; } @@ -8829,8 +8895,13 @@ static char *lua_enumlib_sprintf_upper(char **buf, int* size, const char *format va_list va; va_start(va, format); - int length = vsnprintf(*buf, *size, format, va); - if (length > *size) + va_list vacpy; + va_copy(vacpy, va); + + int length = vsnprintf(*buf, *size, format, vacpy); + va_end(vacpy); + + if (length >= *size) { void *ptr = realloc(*buf, length+1); if (!ptr) @@ -8838,12 +8909,13 @@ static char *lua_enumlib_sprintf_upper(char **buf, int* size, const char *format va_end(va); return NULL; } + *buf = ptr; *size = length+1; - va_start(va, format); - vsnprintf(*buf, *size, format, va); + length = vsnprintf(*buf, *size, format, va); } + va_end(va); for (int i = 0; i < length; i++) @@ -8868,11 +8940,14 @@ static int lua_enumlib_super_get(lua_State *L) } for (int i = 0; actionpointers[i].name; i++) - if (fasticmp(superactions[superstack-1], actionpointers[i].name)) { + { + if (fasticmp(superactions[superstack-1], actionpointers[i].name)) + { lua_pushlightuserdata(L, &actionpointers[i].action); lua_pushcclosure(L, lib_action, 1); return 1; } + } return 0; } @@ -9341,7 +9416,10 @@ enum actionnum LUA_GetActionNumByName(const char *actiontocompare) { size_t z; for (z = 0; actionpointers[z].name; z++) + { if (fasticmp(actiontocompare, actionpointers[z].name)) return z; + } + return z; } From 4dd5957f1918e253531a6d0a29e28471fd4e8cb1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Mar 2026 13:46:57 +0200 Subject: [PATCH 250/589] cache islocalplayer in P_SpectatorJoinGame --- src/p_user.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index f57739c92..24b646ee3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4149,10 +4149,12 @@ void P_ResetLocalCamAiming(player_t *player) boolean P_SpectatorJoinGame(player_t *player) { + const boolean islocalplayer = P_IsLocalPlayer(player); + // Team changing isn't allowed. if (!cv_allowteamchange.value) { - if (P_IsLocalPlayer(player)) + if (islocalplayer) CONS_Printf(M_GetText("Server does not allow team change.\n")); } // Team changing in Team Match and CTF @@ -4200,7 +4202,7 @@ boolean P_SpectatorJoinGame(player_t *player) P_ResetLocalCamAiming(player); //Reset away view - if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer) + if (islocalplayer && displayplayers[0] != consoleplayer) displayplayers[0] = consoleplayer; if (changeto == 1) @@ -4227,7 +4229,7 @@ boolean P_SpectatorJoinGame(player_t *player) P_ResetLocalCamAiming(player); //Reset away view - if (P_IsLocalPlayer(player) && displayplayers[0] != consoleplayer) + if (islocalplayer && displayplayers[0] != consoleplayer) displayplayers[0] = consoleplayer; HU_AddChatText(va(M_GetText("\x82*%s entered the game."), player_names[player-players]), false); From 12169bfb388b18fdf112ad399099fd9da6ca1b68 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 29 Mar 2026 13:49:59 +0200 Subject: [PATCH 251/589] controllers:check if controller supports addressable led and rumble --- src/dedicated/i_system.c | 12 ++++++++++++ src/g_input.c | 21 ++++++++++++++++++++ src/i_system.h | 3 +++ src/sdl/i_system.cpp | 41 ++++++++++++++++++++++++++++++++++++++++ src/sdl/sdlmain.h | 4 ++++ 5 files changed, 81 insertions(+) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index ddc17d6a5..978190bec 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -735,6 +735,18 @@ const char *I_GetJoyName(INT32 joyindex) return NULL; } +boolean I_GamepadHasLED(INT32 playernum) +{ + (void)playernum; + return false; +} + +boolean I_GamepadHasRumble(INT32 playernum) +{ + (void)playernum; + return false; +} + void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration) { (void)playernum; diff --git a/src/g_input.c b/src/g_input.c index d44edd6dc..091027ada 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -939,6 +939,11 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color) return; } + if (!I_GamepadHasLED(playernum)) + { + return; + } + // so we can override this skincolor = color ? color : G_GetSkinColorForGamepad(playernum); byte_color = V_GetColor(colortranslations[skincolor][8]).s; @@ -974,12 +979,22 @@ void G_DeviceLEDTick(void) for (i = 0; i <= splitscreen; i++) { if (!cv_usejoystick[i].value || !cv_gamepadled[i].value) + { continue; + } + + // does not have a configurable led! :c + if (!I_GamepadHasLED(i)) + { + continue; + } newcolor = G_GetSkinColorForGamepad(i); if (curcolor[i] == newcolor) // dont update if same colour + { continue; + } G_SetPlayerGamepadIndicatorColor(i, newcolor); curcolor[i] = newcolor; @@ -1055,6 +1070,12 @@ void G_DeviceRumbleTick(void) continue; } + // does not support rumble! :c + if (!I_GamepadHasRumble(i)) + { + continue; + } + if (camera[i].freecam) { continue; diff --git a/src/i_system.h b/src/i_system.h index 45767f1f7..88bb9c985 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -148,6 +148,9 @@ extern INT32 numcontrollers; */ const char *I_GetJoyName(INT32 joyindex); +boolean I_GamepadHasLED(INT32 playernum); +boolean I_GamepadHasRumble(INT32 playernum); + void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration); void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 blue); diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 407e5c3a0..8ddea4249 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -729,6 +729,8 @@ static void JoyReset(SDLJoyInfo_t *JoySet) #if (SDL_VERSION_ATLEAST(2,32,4)) JoySet->id = -1; #endif + JoySet->hasled = false; + JoySet->hasrumble = false; } /** \brief SDL info about joystick @@ -949,6 +951,13 @@ static int joy_open(int playerIndex, int joyIndex) JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev); #endif +#if (SDL_VERSION_ATLEAST(2,0,14)) + JoyInfo[playerIndex].hasled = SDL_GameControllerHasLED(JoyInfo[playerIndex].dev); +#endif +#if (SDL_VERSION_ATLEAST(2,0,18)) + JoyInfo[playerIndex].hasrumble = SDL_GameControllerHasRumble(JoyInfo[playerIndex].dev); +#endif + return SDL_CONTROLLER_AXIS_MAX; } @@ -996,6 +1005,8 @@ void I_InitJoystick(UINT8 index) #if (SDL_VERSION_ATLEAST(2,32,4)) JoyInfo[index].id = -1; #endif + JoyInfo[index].hasled = false; + JoyInfo[index].hasrumble = false; if (cv_usejoystick[index].value) newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1); @@ -1130,6 +1141,26 @@ const char *I_GetJoyName(INT32 joyindex) return joyname; } +boolean I_GamepadHasLED(INT32 playernum) +{ +#if !(SDL_VERSION_ATLEAST(2,0,14)) + (void)playernum; + return false; +#else + return (JoyInfo[playernum].dev != NULL && JoyInfo[playernum].hasled); +#endif +} + +boolean I_GamepadHasRumble(INT32 playernum) +{ +#if !(SDL_VERSION_ATLEAST(2,0,18)) + (void)playernum; + return false; +#else + return (JoyInfo[playernum].dev != NULL && JoyInfo[playernum].hasrumble); +#endif +} + void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration) { #if !(SDL_VERSION_ATLEAST(2,0,14)) @@ -1145,6 +1176,11 @@ void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, return; } + if (!I_GamepadHasRumble(playernum)) + { + return; + } + SDL_GameControllerRumble(controller, low_strength, high_strength, duration); #endif } @@ -1164,6 +1200,11 @@ void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 b return; } + if (!I_GamepadHasLED(playernum)) + { + return; + } + SDL_GameControllerSetLED(controller, red, green, blue); #endif } diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index 11287fe55..b904eefc6 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -57,6 +57,10 @@ typedef struct SDLJoyInfo_s //int hats; /// number of balls //int balls; + /// + boolean hasled; + /// + boolean hasrumble; } SDLJoyInfo_t; /** \brief SDL info about controller 1 From 7b0e3269b32e278a66f4664c9026ac9340ad27a3 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 4 Apr 2026 16:37:15 +0300 Subject: [PATCH 252/589] Add option to hide finished players from minimap --- src/d_netcmd.h | 1 + src/k_hud.c | 5 +++++ src/m_menudefs.c | 52 +++++++++++++++++++++++++----------------------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index f22fe33a8..c28df3e7d 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -155,6 +155,7 @@ extern consvar_t cv_pingstyle; //extern consvar_t cv_smallpos; extern consvar_t cv_showminimapnames; +extern consvar_t cv_showminimapfinished; extern consvar_t cv_minihead; extern consvar_t cv_showminimapangle; diff --git a/src/k_hud.c b/src/k_hud.c index 3ec17ddd0..6ded3a2f1 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -92,6 +92,7 @@ consvar_t cv_showinput = {"showinput", "Off", CV_SAVE, inputdisplay_cons_t, NULL static CV_PossibleValue_t minihead_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Others"}, {0, NULL}}; consvar_t cv_minihead = {"smallminimapplayers", "Off", CV_SAVE, minihead_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showminimapnames = {"showminimapnames", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showminimapfinished = {"showminimapfinished", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; CV_PossibleValue_t minimapdot_cons_t[NUMMINIMAPDOTSTUFF]; consvar_t cv_showminimapangle = {"showminimapangle", "Off", CV_SAVE, minimapdot_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -221,6 +222,7 @@ void K_RegisterKartHudStuff(void) CV_RegisterVar(&cv_minihead); CV_RegisterVar(&cv_showminimapnames); + CV_RegisterVar(&cv_showminimapfinished); CV_RegisterVar(&cv_showminimapangle); CV_RegisterVar(&cv_showlapemblem); @@ -3772,6 +3774,9 @@ static void K_drawKartMinimap(void) if (!players[i].mo || players[i].spectator) continue; + if (!cv_showminimapfinished.value && players[i].exiting) + continue; + if (P_IsDisplayPlayer(&players[i])) { // Draw display players on top of everything else diff --git a/src/m_menudefs.c b/src/m_menudefs.c index e734021eb..3f1b969ee 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1831,44 +1831,45 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING|IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 10}, {IT_STRING|IT_CVAR, NULL, "Battle Speedometer", &cv_battlespeedo, 15}, - {IT_STRING|IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 25}, - {IT_STRING|IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 30}, - {IT_STRING|IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 35}, + {IT_STRING|IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 25}, + {IT_STRING|IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 30}, + {IT_STRING|IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 35}, - {IT_STRING|IT_CVAR, NULL, "Input Display", &cv_showinput, 45}, + {IT_STRING|IT_CVAR, NULL, "Input Display", &cv_showinput, 45}, - {IT_STRING|IT_CVAR, NULL, "Stat Display", &cv_showstats, 55}, + {IT_STRING|IT_CVAR, NULL, "Stat Display", &cv_showstats, 55}, - {IT_STRING|IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 65}, + {IT_STRING|IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 65}, - {IT_STRING|IT_CVAR, NULL, "Small Positionnumber", &cv_smallposnum, 75}, - {IT_STRING|IT_CVAR, NULL, "Positionnumber Animation", &cv_posanim, 80}, + {IT_STRING|IT_CVAR, NULL, "Small Positionnumber", &cv_smallposnum, 75}, + {IT_STRING|IT_CVAR, NULL, "Positionnumber Animation", &cv_posanim, 80}, - {IT_STRING|IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 90}, + {IT_STRING|IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 90}, - {IT_STRING|IT_CVAR, NULL, "Multi-Item icons", &cv_multiitemicon, 100}, - {IT_STRING|IT_CVAR, NULL, "Item Amount Number", &cv_huditemamount, 105}, - {IT_STRING|IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 110}, + {IT_STRING|IT_CVAR, NULL, "Multi-Item icons", &cv_multiitemicon, 100}, + {IT_STRING|IT_CVAR, NULL, "Item Amount Number", &cv_huditemamount, 105}, + {IT_STRING|IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 110}, - {IT_STRING|IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 120}, - {IT_STRING|IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 125}, + {IT_STRING|IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 120}, + {IT_STRING|IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 125}, - {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, 145}, - {IT_STRING|IT_CVAR, NULL, "Player Angle Visual", &cv_showminimapangle, 150}, + {IT_STRING|IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135}, + {IT_STRING|IT_CVAR, NULL, "Show Finished on Minimap", &cv_showminimapfinished, 140}, + {IT_STRING|IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 145}, + {IT_STRING|IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 150}, + {IT_STRING|IT_CVAR, NULL, "Player Angle Visual", &cv_showminimapangle, 155}, - {IT_STRING|IT_CVAR, NULL, "Music Credits", &cv_songcredits, 160}, - {IT_STRING|IT_CVAR, NULL, "Music Credits on Pause", &cv_pausesongcredits, 165}, + {IT_STRING|IT_CVAR, NULL, "Music Credits", &cv_songcredits, 165}, + {IT_STRING|IT_CVAR, NULL, "Music Credits on Pause", &cv_pausesongcredits, 170}, - {IT_STRING|IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 175}, + {IT_STRING|IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 180}, - {IT_STRING|IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 185}, + {IT_STRING|IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 190}, - {IT_STRING|IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 195}, - {IT_STRING|IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 200}, + {IT_STRING|IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 200}, + {IT_STRING|IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 205}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 210}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 215}, }; static const char* OP_SaturnHudTooltips[] = @@ -1891,6 +1892,7 @@ static const char* OP_SaturnHudTooltips[] = "Show the big 'LAP' text on a lap change.", "Show the big Cecho Messages.", "Show player names on the minimap.", + "Show players that have finished already on the minimap.", "Minimize the player icons on the minimap.", "Erratically rotate player icons during spinouts.", "Visualize the player facing angle.", From 9d75bb14056c00aa3311f6d73f0e0f4e7c11597c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Apr 2026 15:46:23 +0200 Subject: [PATCH 253/589] hw_main: reorder things, mark const, remove pointless check for polyobject planes like normal planes, polyobject planes will just reallocate their vertex buffer eitherways according to size, so that check does not make much sense, srb2 also did remove it a while ago --- src/hardware/hw_main.cpp | 39 +++++++++++++++------------------------ src/hardware/hw_shaders.c | 10 ++++++++-- src/r_main.cpp | 12 ++++++------ src/sdl/i_system.cpp | 4 +++- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 0806d05c8..87192e2bd 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -388,11 +388,11 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 extralight = FixedMul(extralight, std::min(std::max(0, *lightlevel), 255) * FRACUNIT / 255); // simple OGL approximation - fixed_t tr = R_QuickCamDist(spr->mobj->x, spr->mobj->y); - fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); + const fixed_t tr = R_QuickCamDist(spr->mobj->x, spr->mobj->y); + const fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); // Less change in contrast at further distances, to counteract DOOM diminished light - fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); + const fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); extralight = FixedMul(extralight, std::min(n, FRACUNIT)); // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance @@ -515,7 +515,7 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg, extracolormap_t *colo if (seg != NULL && P_ApplyLightOffsetFine(lightnum, seg->frontsector)) { - INT16 offset = (cv_glfakecontrast.value == 2) ? seg->hwLightOffset : ((INT16)seg->lightOffset * 8); + const INT16 offset = (cv_glfakecontrast.value == 2) ? seg->hwLightOffset : ((INT16)seg->lightOffset * 8); finallight += offset; finallight = CLAMP(finallight, 0 , 255); @@ -533,7 +533,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t if (slope != NULL && sector != NULL && P_ApplyLightOffsetFine(lightnum, sector)) { - INT16 offset = (cv_glfakecontrast.value == 2) ? slope->hwLightOffset : ((INT16)slope->lightOffset * 8); + const INT16 offset = (cv_glfakecontrast.value == 2) ? slope->hwLightOffset : ((INT16)slope->lightOffset * 8); finallight += (fof ? -offset : offset); finallight = CLAMP(finallight, 0 , 255); @@ -1420,6 +1420,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { draw_sky_walls(0, 1, worldhigh, worldhighslope); } + + // hack to allow height changes in outdoor areas + // This is what gets rid of the upper textures if there should be sky + worldtop = worldhigh; + worldtopslope = worldhighslope; } else { @@ -1464,15 +1469,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } - // hack to allow height changes in outdoor areas - // This is what gets rid of the upper textures if there should be sky - if (gl_frontsector->ceilingpic == skyflatnum - && gl_backsector->ceilingpic == skyflatnum) - { - worldtop = worldhigh; - worldtopslope = worldhighslope; - } - gl_toptexture = R_GetTextureNum(gl_sidedef->toptexture); // check TOP TEXTURE @@ -2263,7 +2259,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom static inline boolean HWR_UsePortals(void) { - return supportstencil && cv_glportals.value && gl_maphasportals; + return supportstencil && gl_maphasportals && cv_glportals.value; } // From PrBoom: @@ -2407,7 +2403,8 @@ static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2) // SoM: Backsector needs to be run through R_FakeFlat static sector_t tempsec; - auto do_addline = [&](bool dontdraw) { + auto do_addline = [&](bool dontdraw) + { // Single sided line? if (!line->backsector) { @@ -2688,14 +2685,6 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, if (nrPlaneVerts < 3) // not even a triangle ? return; - if (nrPlaneVerts > INT16_MAX) // FIXME: exceeds plVerts size - { - CONS_Debug(DBG_RENDER, "polygon size of %s exceeds max value of %d vertices\n", sizeu1(nrPlaneVerts), UINT16_MAX); - return; - } - - const sector_t *sec = FOFsector ? FOFsector : gl_frontsector; - // Allocate plane-vertex buffer if we need to if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts) { @@ -2704,6 +2693,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, Z_Malloc(numAllocedPlaneVerts * sizeof(FOutVector), PU_LEVEL, &planeVerts); } + const sector_t *sec = FOFsector ? FOFsector : gl_frontsector; + height = FixedToFloat(fixedheight); len = W_LumpLength(lumpnum); diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 90d019b2b..31723eab1 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -365,13 +365,17 @@ static void HWR_CompileShader(int index) if (vertex_source) { char *preprocessed = HWR_PreprocessShader(vertex_source); - if (!preprocessed) return; + if (!preprocessed) + return; + GL_LoadShader(index, preprocessed, HWD_SHADERSTAGE_VERTEX); } if (fragment_source) { char *preprocessed = HWR_PreprocessShader(fragment_source); - if (!preprocessed) return; + if (!preprocessed) + return; + GL_LoadShader(index, preprocessed, HWD_SHADERSTAGE_FRAGMENT); } @@ -387,8 +391,10 @@ void HWR_CompileShaders(void) { int custom_index = gl_shadertargets[i].custom_shader; HWR_CompileShader(i); + if (!gl_shaders[i].compiled) CONS_Alert(CONS_ERROR, "HWR_CompileShaders: Compilation failed for base %s shader!\n", shaderxlat[i].type); + if (custom_index != -1) { HWR_CompileShader(custom_index); diff --git a/src/r_main.cpp b/src/r_main.cpp index 2b318858a..cf7df9088 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -342,14 +342,14 @@ angle_t R_PointToAngle64(INT64 x, INT64 y) return (y -= viewy, (x -= viewx) || y) ? x >= 0 ? y >= 0 ? - (x > y) ? tantoangle[SlopeDivEx(y,x)] : // octant 0 - ANGLE_90-tantoangle[SlopeDivEx(x,y)] : // octant 1 - x > (y = -y) ? 0-tantoangle[SlopeDivEx(y,x)] : // octant 8 - ANGLE_270+tantoangle[SlopeDivEx(x,y)] : // octant 7 + (x > y) ? tantoangle[SlopeDivEx(y,x)] : // octant 0 + ANGLE_90-tantoangle[SlopeDivEx(x,y)] : // octant 1 + x > (y = -y) ? 0-tantoangle[SlopeDivEx(y,x)] : // octant 8 + ANGLE_270+tantoangle[SlopeDivEx(x,y)] : // octant 7 y >= 0 ? (x = -x) > y ? ANGLE_180-tantoangle[SlopeDivEx(y,x)] : // octant 3 - ANGLE_90 + tantoangle[SlopeDivEx(x,y)] : // octant 2 + ANGLE_90 + tantoangle[SlopeDivEx(x,y)] : // octant 2 (x = -x) > (y = -y) ? ANGLE_180+tantoangle[SlopeDivEx(y,x)] : // octant 4 - ANGLE_270-tantoangle[SlopeDivEx(x,y)] : // octant 5 + ANGLE_270-tantoangle[SlopeDivEx(x,y)] : // octant 5 0; } diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 8ddea4249..2f2253fe8 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -304,7 +304,7 @@ static void I_StartupConsole(void) if (!consolevent) return; - if (isatty(STDIN_FILENO)!=1) + if (isatty(STDIN_FILENO) != 1) { I_OutputMsg("stdin is not a tty, tty console mode failed\n"); consolevent = false; @@ -1993,12 +1993,14 @@ FUNCNORETURN void ATTRNORETURN I_Quit(void) I_ShutdownInput(); I_ShutdownSystem(); SDL_Quit(); + /* if option -noendtxt is set, don't print the text */ if (!M_CheckParm("-noendtxt") && W_CheckNumForName("ENDOOM") != LUMPERROR) { printf("\r"); ShowEndTxt(); } + if (myargmalloc) free(myargv); // Deallocate allocated memory From e543599598236f205c050b4f6cff248cb4b944fd Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 4 Apr 2026 16:53:01 +0300 Subject: [PATCH 254/589] Add option to hide skin name from stat display --- src/k_hud.c | 17 +++++++++++------ src/k_hud.h | 1 + src/m_menudefs.c | 48 +++++++++++++++++++++++++----------------------- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 6ded3a2f1..1efdcbdcb 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -83,6 +83,7 @@ IMPL_HUD_OFFSET(stat); // Stats // extra hud things consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showstats_skinname = {"showstats_skinname", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_highresportrait = {"highresportrait", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // make char potraits use their high-res version instead @@ -208,6 +209,7 @@ void K_RegisterKartHudStuff(void) CV_RegisterVar(&cv_kartspeedometer); CV_RegisterVar(&cv_showstats); + CV_RegisterVar(&cv_showstats_skinname); CV_RegisterVar(&cv_showinput); CV_RegisterVar(&cv_posanim); @@ -1436,13 +1438,16 @@ static void K_drawKartStats(void) fakeskin = K_GetPlayerSkin(stplyr); // Skin name - if (K_IsHighResolution()) // V_DrawSmallString becomes a mess at low resolutions lel + if (cv_showstats_skinname.value) { - V_DrawSmallString(x+20, y+12, flags2, fakeskin->realname); - } - else - { - V_DrawThinString(x+20, y+7, flags2, fakeskin->realname); + if (K_IsHighResolution()) // V_DrawSmallString becomes a mess at low resolutions lel + { + V_DrawSmallString(x+20, y+12, flags2, fakeskin->realname); + } + else + { + V_DrawThinString(x+20, y+7, flags2, fakeskin->realname); + } } // Icon and stats diff --git a/src/k_hud.h b/src/k_hud.h index c42996a4e..ca38f43ea 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -35,6 +35,7 @@ extern consvar_t cv_darkitembox; extern consvar_t cv_biglaps; extern consvar_t cv_highresportrait; extern consvar_t cv_showstats; +extern consvar_t cv_showstats_skinname; extern consvar_t cv_fancyroulette; extern consvar_t cv_showlaptimes; extern consvar_t cv_battlespeedo; diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 3f1b969ee..0b176fab3 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1828,8 +1828,8 @@ static menuitem_t OP_SaturnHudMenu[] = { {IT_HEADER, NULL, "Saturn Hud Options", NULL, 0}, - {IT_STRING|IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 10}, - {IT_STRING|IT_CVAR, NULL, "Battle Speedometer", &cv_battlespeedo, 15}, + {IT_STRING|IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 10}, + {IT_STRING|IT_CVAR, NULL, "Battle Speedometer", &cv_battlespeedo, 15}, {IT_STRING|IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 25}, {IT_STRING|IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 30}, @@ -1838,38 +1838,39 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING|IT_CVAR, NULL, "Input Display", &cv_showinput, 45}, {IT_STRING|IT_CVAR, NULL, "Stat Display", &cv_showstats, 55}, + {IT_STRING|IT_CVAR, NULL, "Skin Name in Stat Display", &cv_showstats_skinname, 60}, - {IT_STRING|IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 65}, + {IT_STRING|IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 70}, - {IT_STRING|IT_CVAR, NULL, "Small Positionnumber", &cv_smallposnum, 75}, - {IT_STRING|IT_CVAR, NULL, "Positionnumber Animation", &cv_posanim, 80}, + {IT_STRING|IT_CVAR, NULL, "Small Positionnumber", &cv_smallposnum, 80}, + {IT_STRING|IT_CVAR, NULL, "Positionnumber Animation", &cv_posanim, 85}, - {IT_STRING|IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 90}, + {IT_STRING|IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 95}, - {IT_STRING|IT_CVAR, NULL, "Multi-Item icons", &cv_multiitemicon, 100}, - {IT_STRING|IT_CVAR, NULL, "Item Amount Number", &cv_huditemamount, 105}, - {IT_STRING|IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 110}, + {IT_STRING|IT_CVAR, NULL, "Multi-Item icons", &cv_multiitemicon, 105}, + {IT_STRING|IT_CVAR, NULL, "Item Amount Number", &cv_huditemamount, 110}, + {IT_STRING|IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 115}, - {IT_STRING|IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 120}, - {IT_STRING|IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 125}, + {IT_STRING|IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 125}, + {IT_STRING|IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 130}, - {IT_STRING|IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135}, - {IT_STRING|IT_CVAR, NULL, "Show Finished on Minimap", &cv_showminimapfinished, 140}, - {IT_STRING|IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 145}, - {IT_STRING|IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 150}, - {IT_STRING|IT_CVAR, NULL, "Player Angle Visual", &cv_showminimapangle, 155}, + {IT_STRING|IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 140}, + {IT_STRING|IT_CVAR, NULL, "Show Finished on Minimap", &cv_showminimapfinished, 145}, + {IT_STRING|IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 150}, + {IT_STRING|IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 155}, + {IT_STRING|IT_CVAR, NULL, "Player Angle Visual", &cv_showminimapangle, 160}, - {IT_STRING|IT_CVAR, NULL, "Music Credits", &cv_songcredits, 165}, - {IT_STRING|IT_CVAR, NULL, "Music Credits on Pause", &cv_pausesongcredits, 170}, + {IT_STRING|IT_CVAR, NULL, "Music Credits", &cv_songcredits, 170}, + {IT_STRING|IT_CVAR, NULL, "Music Credits on Pause", &cv_pausesongcredits, 175}, - {IT_STRING|IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 180}, + {IT_STRING|IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 185}, - {IT_STRING|IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 190}, + {IT_STRING|IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 195}, - {IT_STRING|IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 200}, - {IT_STRING|IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 205}, + {IT_STRING|IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 205}, + {IT_STRING|IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 210}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 215}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 220}, }; static const char* OP_SaturnHudTooltips[] = @@ -1882,6 +1883,7 @@ static const char* OP_SaturnHudTooltips[] = "The color to use instead of the player color when\ncolourized hud is enabled.", "Displays the input display and lets you choose its style.", "Enable the stat display.", + "Show skin name in the stat display.", "Enable the use of the higher resolution want icons instead of rank\nfor some places.", "Make the Postionnumber half the size.", "Disable the animation of the Positionnumber\nwhen overtaking someone.", From 873cff447483c8f396456fbeae7b007b87d30546 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 10 Mar 2026 02:27:36 +0300 Subject: [PATCH 255/589] Display information about addon types loaded on server when joining (WIP) --- src/d_clisrv.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/d_netfil.c | 49 +++++++++++++++++++++++++++++++++++ src/d_netfil.h | 12 +++++++++ 3 files changed, 131 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f5e32b2e0..fb665a943 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1154,6 +1154,64 @@ static void CV_LoadPlayerNames(UINT8 **p) } } +static void CL_DrawAddonTypes(void) +{ + INT32 y = 0; + + INT32 addontypes_downloaded[NUMADDONTYPES] = {0}; + + for (INT32 i = 0; i < fileneedednum; ++i) + { + switch (fileneeded[i].status) + { + case FS_FOUND: + case FS_OPEN: + addontypes_downloaded[fileneeded[i].type]++; + break; + + default: + break; + } + } + + for (addontype_t type = 0; type < NUMADDONTYPES; ++type) + { + if (addontypes[type] == 0) + continue; + + INT32 flags = V_SNAPTOTOP|V_SNAPTOLEFT|V_ALLOWLOWERCASE; + + if (addontypes[type] == addontypes_downloaded[type]) + flags |= V_GREENMAP; + else + flags |= V_YELLOWMAP; + + const char *typestr = "Misc"; + + switch (type) + { + case ADDON_SCRIPT: + typestr = "Script"; + break; + + case ADDON_MAP: + typestr = "Map"; + break; + + case ADDON_CHARACTER: + typestr = "Character"; + break; + + default: + break; + } + + V_DrawSmallString(4, 4 + y, flags, va("%s addons", typestr)); + V_DrawRightAlignedSmallString(100, 4 + y, flags, va("%d/%d", addontypes_downloaded[type], addontypes[type])); + y += 6; + } +} + // // CL_DrawConnectionStatus // @@ -1269,6 +1327,8 @@ static void CL_DrawConnectionStatus(void) V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va(" %2u/%2u Files", checkednum, fileneedednum)); + + CL_DrawAddonTypes(); } else if (cl_mode == CL_LOADFILES) { @@ -1292,6 +1352,8 @@ static void CL_DrawConnectionStatus(void) V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va(" %2u/%2u Files", loadcompletednum, fileneedednum)); + + CL_DrawAddonTypes(); } else if (cl_mode == CL_VIEWSERVER) { @@ -1495,6 +1557,8 @@ static void CL_DrawConnectionStatus(void) V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va("%2u/%2u Files ", filedownload.completednum, filedownload.totalnum)); + + CL_DrawAddonTypes(); } else { @@ -1511,6 +1575,8 @@ static void CL_DrawConnectionStatus(void) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-32, V_YELLOWMAP|MENUCAPS, M_GetText("Waiting to download files...")); + + CL_DrawAddonTypes(); } } } @@ -2559,6 +2625,7 @@ static void CL_ServerConnectionSearchTicker(tic_t *asksent) } cl_mode = cv_serverinfoscreen.value ? CL_VIEWSERVER : CL_CHECKFILES; + CL_CheckAddonTypes(); } else { @@ -2612,7 +2679,10 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic case CL_ASKFULLFILELIST: if (cl_lastcheckedfilecount == UINT16_MAX) // All files retrieved + { cl_mode = cv_serverinfoscreen.value ? CL_VIEWSERVER : CL_CHECKFILES; + CL_CheckAddonTypes(); + } else if (fileneedednum != cl_lastcheckedfilecount || I_GetTime() >= *asksent) { if (CL_AskFileList(fileneedednum)) diff --git a/src/d_netfil.c b/src/d_netfil.c index aca8f35ba..8865ab618 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -116,6 +116,8 @@ static I_mutex downloadmutex; #endif char downloaddir[512] = "DOWNLOAD"; +INT32 addontypes[NUMADDONTYPES] = {0}; + file_download_t filedownload = {}; #ifdef HAVE_CURL @@ -135,6 +137,8 @@ HTTP_login *curl_logins = NULL; static void CURLGetFile(void); #endif +static addontype_t GetAddonType(const char *name); + /** Fills a serverinfo packet with information about wad files loaded. * * \todo Give this function a better name since it is in global scope. @@ -227,6 +231,9 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi fileneeded[i].file = NULL; // The file isn't open yet READSTRINGL(p, fileneeded[i].filename, MAX_WADPATH); // The next bytes are the file name READMEM(p, fileneeded[i].md5sum, 16); // The last 16 bytes are the file checksum + + // Should be good place to calculate that? + fileneeded[i].type = GetAddonType(fileneeded[i].filename); } } @@ -575,6 +582,48 @@ INT32 CL_CheckFiles(void) return 1; //everything is FS_OPEN or FS_FOUND, proceed to loading } +static addontype_t GetAddonType(const char *name) +{ + const char *prefix = strchr(name, '_'); + + // Doesn't have prefix (no '_' character or it is too far and is probably not for prefix but for something like version) + // KRBCL_ is longest prefix i can think of so this should be enough + if (prefix == NULL || prefix - name > 5) + return ADDON_MISC; + + // Skip 'K' + if (*name == 'K') + ++name; + + switch (*name) + { + case 'L': + return ADDON_SCRIPT; + break; + + case 'R': + case 'B': + return ADDON_MAP; + break; + + case 'C': + return ADDON_CHARACTER; + break; + } + + return ADDON_MISC; +} + +void CL_CheckAddonTypes(void) +{ + memset(&addontypes, 0, sizeof(addontypes)); + + for (INT32 i = 0; i < fileneedednum; i++) + { + addontypes[fileneeded[i].type]++; + } +} + // Load it now boolean CL_LoadServerFiles(void) { diff --git a/src/d_netfil.h b/src/d_netfil.h index 268cd80be..4d4cdba74 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -40,6 +40,15 @@ typedef enum FS_FALLBACK, // HTTP failed } filestatus_t; +typedef enum addontype_e +{ + ADDON_SCRIPT, + ADDON_MAP, + ADDON_CHARACTER, + ADDON_MISC, + NUMADDONTYPES, +} addontype_t; + typedef struct { UINT8 willsend; // Is the server willing to send it? @@ -51,11 +60,13 @@ typedef struct UINT32 totalsize; filestatus_t status; // The value returned by recsearch boolean justdownloaded; // To prevent late fragments from causing an I_Error + addontype_t type; } fileneeded_t; extern INT32 fileneedednum; extern fileneeded_t fileneeded[MAX_WADFILES]; extern char downloaddir[512]; +extern INT32 addontypes[NUMADDONTYPES]; typedef struct { @@ -91,6 +102,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi void CL_PrepareDownloadSaveGame(const char *tmpsave); INT32 CL_CheckFiles(void); +void CL_CheckAddonTypes(void); boolean CL_LoadServerFiles(void); void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UINT8 fileid); From 42fa435a0ba12a55a080fa2a1b381636b030b952 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 11 Mar 2026 17:26:12 +0300 Subject: [PATCH 256/589] Add toggle for server addon info --- src/d_clisrv.c | 5 +++++ src/d_clisrv.h | 2 ++ src/d_netcmd.c | 1 + 3 files changed, 8 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index fb665a943..d9419a15b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1156,6 +1156,9 @@ static void CV_LoadPlayerNames(UINT8 **p) static void CL_DrawAddonTypes(void) { + if (!cv_serveraddoninfo.value) + return; + INT32 y = 0; INT32 addontypes_downloaded[NUMADDONTYPES] = {0}; @@ -4284,6 +4287,8 @@ consvar_t cv_connectawaittime = {"connectawaittime", "5", CV_SAVE, connectawaitt consvar_t cv_serverinfoscreen = {"serverinfoscreen", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_serveraddoninfo = {"serveraddoninfo", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + static void Got_AddPlayer(const UINT8 **p, INT32 playernum); static void Got_RemovePlayer(const UINT8 **p, INT32 playernum); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index e6741b949..8392f13a1 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -600,6 +600,8 @@ extern consvar_t cv_discordinvites; extern consvar_t cv_serverinfoscreen; +extern consvar_t cv_serveraddoninfo; + // Used in d_net, the only dependence //tic_t ExpandTics(INT32 low, tic_t basetic); void D_ClientServerInit(void); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index aee7f20d4..828ad136a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -900,6 +900,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_mindelay); CV_RegisterVar(&cv_gentlemens); CV_RegisterVar(&cv_serverinfoscreen); + CV_RegisterVar(&cv_serveraddoninfo); #ifdef NETGAME_DEVMODE CV_RegisterVar(&cv_fishcake); From b84e6d89e20776174a50e9dfe949dd51668d25be Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 4 Apr 2026 17:24:58 +0300 Subject: [PATCH 257/589] Add toggle for server addons info hud into settings --- src/m_menudefs.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 0b176fab3..e2fd3305f 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1694,29 +1694,30 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Minimum Input Delay", &cv_mindelay, 20}, {IT_STRING | IT_CVAR, NULL, "Gentlemens Ping", &cv_gentlemens, 25}, {IT_STRING | IT_CVAR, NULL, "Server Info Screen", &cv_serverinfoscreen, 30}, + {IT_STRING | IT_CVAR, NULL, "Server Addons Info", &cv_serveraddoninfo, 35}, - {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 40}, + {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 45}, - {IT_STRING | IT_CVAR, NULL, "Colorized Speedlines", &cv_coloredspeedlines, 50}, - {IT_STRING | IT_CVAR, NULL, "Colorized Sneakertrails", &cv_coloredsneakertrail, 55}, + {IT_STRING | IT_CVAR, NULL, "Colorized Speedlines", &cv_coloredspeedlines, 55}, + {IT_STRING | IT_CVAR, NULL, "Colorized Sneakertrails", &cv_coloredsneakertrail, 60}, - {IT_STRING | IT_CVAR, NULL, "Player Blendeffects", &cv_playerblendeffects, 65}, + {IT_STRING | IT_CVAR, NULL, "Player Blendeffects", &cv_playerblendeffects, 70}, - {IT_STRING | IT_CVAR, NULL, "Bananadrag Jitter", &cv_bananajitter, 75}, + {IT_STRING | IT_CVAR, NULL, "Bananadrag Jitter", &cv_bananajitter, 80}, - {IT_STRING | IT_CVAR, NULL, "Midair Driftsparks", &cv_airsparks, 85}, + {IT_STRING | IT_CVAR, NULL, "Midair Driftsparks", &cv_airsparks, 90}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 95}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 100}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 105}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 110}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 115}, + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 120}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 125}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 130}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 135}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 140}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 145}, // uwu + {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 140}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 150}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -1726,6 +1727,7 @@ static const char* OP_SaturnTooltips[] = "Practice for online play! 0 = instant response.", "Simulate online input delay when hosting a server.\nValue choosen by Player with the lowest ping", "Show a screen before joining a server displaying important information about it", + "Show a amount and types of addons loaded by server when joining", "How much speen do you want?", "Colourize the speedlines in your skincolor if you go fast enough!", "Colourize the sneaker flame trails in your skincolor!", From e6434c24ec246b31212c436762475109de5a622a Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 4 Apr 2026 18:01:10 +0300 Subject: [PATCH 258/589] Fix spelling in server addon info tooltip --- src/m_menudefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index e2fd3305f..9eb89515f 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1727,7 +1727,7 @@ static const char* OP_SaturnTooltips[] = "Practice for online play! 0 = instant response.", "Simulate online input delay when hosting a server.\nValue choosen by Player with the lowest ping", "Show a screen before joining a server displaying important information about it", - "Show a amount and types of addons loaded by server when joining", + "Show amount and types of addons that are loaded by server when joining", "How much speen do you want?", "Colourize the speedlines in your skincolor if you go fast enough!", "Colourize the sneaker flame trails in your skincolor!", From efd8c20d2677f9d0efeaa9d9b20cf3de2d66905e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Apr 2026 18:26:16 +0200 Subject: [PATCH 259/589] enable lto by default on makefile builds change flag to NOLTO to disable lto at this point we shouldnt have any issues anymore since the utter crapton of bugfixes --- src/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 372594384..c930f87ed 100644 --- a/src/Makefile +++ b/src/Makefile @@ -93,7 +93,7 @@ # NOLDWARNING=1 - ? # NOSDLMAIN=1 - ? # SDLMAIN=1 - ? -# USELTO=1 - Enable building with LTO. +# NOLTO=1 - Disable link time optimizations # # Library configuration flags: # Everything here is an override. @@ -260,7 +260,7 @@ debug_opts=-D_DEBUG else # build a normal optimized version debug_opts=-DNDEBUG opts+=-O3 -ifdef USELTO +ifndef NOLTO # compile with LTO opts+=-flto=auto libs+=-flto=auto From 489a58f9fd65ff66dee0abd2321526d7948e256a Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 3 Mar 2026 03:24:08 +0300 Subject: [PATCH 260/589] Allocate all colormaps with PU_STATIC --- src/p_setup.c | 3 ++- src/r_draw.cpp | 7 ++++++- src/r_skins.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 0d432e747..afc53234b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2586,7 +2586,8 @@ void P_FreeLevelState(void) } // Clear pointers that would be left dangling by the purge - R_FlushTranslationColormapCache(); + // Pointers are now PU_STATIC so they won't be freed :) + //R_FlushTranslationColormapCache(); #ifdef HWRENDER // Free GPU textures before freeing patches. diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 2e7c47e87..474496108 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -419,7 +419,7 @@ static UINT8* RGetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 f // Generate the colormap if necessary if (!ret) { - ret = static_cast(Z_Malloc(NUM_PALETTE_ENTRIES, (flags & GTC_CACHE) ? PU_LEVEL : PU_STATIC, NULL)); + ret = static_cast(Z_Malloc(NUM_PALETTE_ENTRIES, PU_STATIC, NULL)); K_GenerateKartColormap(ret, skinnum, color, local); //R_GenerateTranslationColormap(ret, skinnum, color); // SRB2kart // Cache the colormap if desired @@ -487,6 +487,10 @@ patch_t* R_GetSkinFaceMini(player_t* ply) \return void */ + +/* There seems to be no reason to free cached colormaps tho? Not like they can change :ChonkBunckle: */ + +/* void R_FlushTranslationColormapCache(void) { INT32 i; @@ -499,6 +503,7 @@ void R_FlushTranslationColormapCache(void) if (localtranslationtablecache[i]) memset(localtranslationtablecache[i], 0, MAXTRANSLATIONS * sizeof(UINT8**)); } +*/ // ========================================================================== // COMMON DRAWER FOR 8 AND 16 BIT COLOR MODES diff --git a/src/r_skins.c b/src/r_skins.c index 41971788c..9ab6e0fbf 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -774,7 +774,7 @@ void R_AddSkins(UINT16 wadnum, boolean local) // So just let the function in the while loop take care of it for us. } - R_FlushTranslationColormapCache(); + //R_FlushTranslationColormapCache(); CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); #ifdef SKINVALUES From 4ccf3dfaf98b1a88fb1e55ae8c450901f1c41b62 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Apr 2026 20:17:56 +0200 Subject: [PATCH 261/589] software: make R_DrawWallColumn being able to render "holey" textures not the most efficient but idk a better solution to this, and clipping code may cause some other undesired effects, but well were not supposed to be drawing textures with holes on single sided walls eitherways, but here we are basically this copies columns into a buffer filled with cyan pixels, so the holes become cyan instead of nothing, which we can cut again using the twomultipatch drawers fixes the "melt" effect on some things like spelunky or music plant (and well reading/writing oob) --- src/r_draw.cpp | 2 -- src/r_draw.h | 3 ++- src/r_segs.cpp | 58 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/screen.c | 5 ++++- 4 files changed, 62 insertions(+), 6 deletions(-) diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 474496108..b8f3fc903 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -515,8 +515,6 @@ void R_FlushTranslationColormapCache(void) // in reality, the few routines that can work for either mode, are // put here -enum columncontext_e columncontext = COLUMNCONTEXT_DIRECT; - enum ColumnFlushType { FLUSH_NONE = 0x0000, diff --git a/src/r_draw.h b/src/r_draw.h index a472b5537..a1d451fb4 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -105,7 +105,6 @@ enum columncontext_e COLUMNCONTEXT_FLUSH, }; -extern enum columncontext_e columncontext; void R_SetColumnContext(enum columncontext_e _columncontext); void R_ResetColumnBuffer(void); @@ -124,6 +123,8 @@ enum COLDRAWFUNC_TRANSTRANS, COLDRAWFUNC_TWOSMULTIPATCH, COLDRAWFUNC_TWOSMULTIPATCHTRANS, + COLDRAWFUNC_TWOSMULTIPATCH_DIRECT, + COLDRAWFUNC_TWOSMULTIPATCHTRANS_DIRECT, COLDRAWFUNC_FOG, COLDRAWFUNC_MAX diff --git a/src/r_segs.cpp b/src/r_segs.cpp index a53d40ec4..f94e72b4c 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -16,6 +16,7 @@ #include "r_sky.h" #include +#include #include "r_portal.h" #include "r_splats.h" @@ -1166,6 +1167,37 @@ static inline void R_ExpandPlaneY(visplane_t *pl, INT32 x, INT16 top, INT16 bott // CALLED: CORE LOOPING ROUTINE. // +static std::vector holecol(256); + +// used for R_DrawWallColumn +// convert "holey" columns into contigous columns +// filled with cyan in place of holes +static UINT8 *R_GetHoleColumn(drawcolumndata_t* dc) +{ + column_t *col = (column_t *)(dc->source - 3); + + const INT32 texheight = dc->texheight; + holecol.resize(texheight); + + // fill in everything with cyan so we can skip it + memset(holecol.data(), TRANSPARENTPIXEL, texheight); + + // shamelessly copy pasted from R_GenerateTexture + INT32 topdelta, prevdelta = -1; + while (col->topdelta != 0xff) + { + topdelta = col->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + + memcpy(holecol.data() + topdelta, (UINT8*)col + 4, col->length); + col = (column_t *)((UINT8*)col + col->length + 4); + } + + return holecol.data(); +} + static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t mid, fixed_t texturecolumn, INT32 texture, boolean remap) { const INT32 itexturecolumn = texturecolumn >> FRACBITS; @@ -1175,13 +1207,35 @@ static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t m dc->source = R_GetColumn(texture, itexturecolumn); dc->texheight = textureheight[texture] >> FRACBITS; dc->sourcelength = dc->texheight; + R_SetColumnFunc(colfunctype); coldrawfunc_t* colfunccopy = colfunc; + + if (textures[texture]->holes) + { + dc->source = R_GetHoleColumn(dc); + + if (cv_softcyancut.value) + { + // need to use multipatch drawers to cut cyan pixels + if (R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == true) + { + colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS_DIRECT]; + } + else + { + colfunccopy = colfuncs[COLDRAWFUNC_TWOSMULTIPATCH_DIRECT]; + } + } + } + drawcolumndata_t dc_copy = *dc; + if (remap) { dc_copy.colormap += COLORMAP_REMAPOFFSET; } + colfunccopy(const_cast(&dc_copy)); } @@ -1390,7 +1444,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc) // calculate lighting pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; - if (pindex >= MAXLIGHTSCALE) + if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; dc->colormap = walllights[pindex]; @@ -1425,7 +1479,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc) pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; - if (pindex >= MAXLIGHTSCALE) + if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; if (dc->lightlist[i].extra_colormap) diff --git a/src/screen.c b/src/screen.c index b292c646d..ebc5abddf 100644 --- a/src/screen.c +++ b/src/screen.c @@ -120,6 +120,10 @@ static void SCR_SetDrawFuncs(enum columncontext_e _columncontext) colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn; } + // gotta keep a copy of those for R_DrawWallColumn..... + colfuncs[COLDRAWFUNC_TWOSMULTIPATCH_DIRECT] = R_Draw2sMultiPatchColumn; + colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS_DIRECT] = R_Draw2sMultiPatchTranslucentColumn; + colfuncs[COLDRAWFUNC_FOG] = R_DrawFogColumn; R_SetColumnFunc(BASEDRAWFUNC); @@ -154,7 +158,6 @@ void SCR_SetMode(void) // effectively adding massive overhead due to excessive flushing, so we draw our masked thing directly to screen instead void R_SetColumnContext(enum columncontext_e _columncontext) { - columncontext = _columncontext; SCR_SetDrawFuncs(_columncontext); // set our column drawers } From 7177a9f57ff58e591ee83fe3678fec12de533bb5 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Apr 2026 17:53:11 +0200 Subject: [PATCH 262/589] raise version to v9.3 --- src/doomdef.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 1543e68a9..69347f05a 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -130,8 +130,8 @@ extern char logfilename[1024]; #else #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number -#define VERSIONSTRING "Saturn v9.2" -#define VERSIONSTRINGW L"Saturn v9.2" +#define VERSIONSTRING "Saturn v9.3" +#define VERSIONSTRINGW L"Saturn v9.3" #define SATURN_TESTING // comment out for saturn release builds! From d957bddc1f3630cf097f1621e02d982b6aecfb1b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Apr 2026 13:46:27 +0200 Subject: [PATCH 263/589] update opengl dithering shader now works more like i intended too by more or less scaling the pattern to be roughly the same size on each resolution and trying to reduce precision issues by using floor to convert float values to integer range --- src/hardware/hw_shaders.h | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 40f936f69..ff8b229de 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -78,33 +78,23 @@ // Include GLSL_FLOOR_FUDGES or GLSL_WALL_FUDGES or define the fudges in shaders that use this macro. #define GLSL_DOOM_COLORMAP_DITHER \ "float baseValue = max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ - "float endResolutionx = scr_resolution.x;\n" \ - "float endResolutiony = scr_resolution.y;\n" \ - "if (scr_resolution.x > 1280.0) {\n" \ - "endResolutionx = scr_resolution.x * 0.5;\n" \ - "}\n" \ - "if (scr_resolution.y > 720.0) {\n" \ - "endResolutiony = scr_resolution.y * 0.5;\n" \ - "}\n" \ - "float zFactor = clamp((z - 192.0) / (6144.0 - 192.0), 0.0, 1.0);\n" \ - "int scaleFactor = int(mix(1.0, 8.0, zFactor));\n" \ - "endResolutionx = endResolutionx * scaleFactor;\n" \ - "endResolutiony = endResolutiony * scaleFactor;\n" \ - "vec2 normalizedPosition = position * vec2(endResolutionx / scr_resolution.x, endResolutiony / scr_resolution.y);\n" \ - "int x = int(mod(normalizedPosition.x, 4.0));\n" \ - "int y = int(mod(normalizedPosition.y, 4.0));\n" \ + "float patscale = min(scr_resolution.x / 1280.0, scr_resolution.y / 720.0);\n" \ + "patscale = max(floor(patscale + 0.5), 1.0);\n" \ + "patscale = 1.0 / patscale;\n" \ + "ivec2 p = ivec2(mod(floor(position * patscale), 4.0));\n" \ + "float depthfactor = clamp((z - 192.0) / (6144.0 - 192.0), 0.0, 1.0);\n" \ "float bayerMatrix[4*4] = float[4*4](\n" \ "0.0, 8.0, 2.0, 10.0,\n" \ "12.0, 4.0, 14.0, 6.0,\n" \ "3.0, 11.0, 1.0, 9.0,\n" \ "15.0, 7.0, 13.0, 5.0\n" \ ");\n" \ + "float threshold = 16.0;\n" \ "#ifdef SRB2_PALETTE_RENDERING\n" \ - "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 11.0);\n" \ - "#else\n" \ - "float threshold = (1.0 - pow(zFactor, 2.0)) * (bayerMatrix[y*4 + x] / 16.0);\n" \ + "threshold = 11.0;\n" \ "#endif\n" \ - "return mix(baseValue + threshold - 0.5 / 16.0, baseValue, zFactor);\n" + "threshold = (1.0 - pow(depthfactor, 2.0)) * (bayerMatrix[p.y*4 + p.x] / threshold);\n" \ + "return mix(baseValue + threshold - 0.5 / 16.0, baseValue, depthfactor);\n" #define GLSL_DOOM_COLORMAP_NODITHER \ "return max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ From 5461a6dcbe18c5a409e2f699c7a7da3095bfad5c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Apr 2026 14:39:01 +0200 Subject: [PATCH 264/589] cleanup skinselect menu stuff slightly --- src/m_menu.c | 93 +++++++++++++++++++--------------------------------- 1 file changed, 34 insertions(+), 59 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 01b106d95..2dc7119e4 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7953,25 +7953,24 @@ static void M_DrawSetupMultiPlayerMenu(void) INT32 tw = 0; spritedef_t *sprdef; spriteframe_t *sprframe; - patch_t *statbg = (patch_t *)W_CachePatchName("K_STATBG", PU_PATCH); - patch_t *statlr = (patch_t *)W_CachePatchName("K_STATLR", PU_PATCH); - patch_t *statud = (patch_t *)W_CachePatchName("K_STATUD", PU_PATCH); - patch_t *statdot = (patch_t *)W_CachePatchName("K_SDOT0" , PU_PATCH); patch_t *patch; UINT8 frame; UINT8 speed; UINT8 weight; UINT8 i; UINT8 s, w; - const UINT8 *flashcol = V_GetStringColormap(highlightflags); INT32 skinnum = 0; INT32 statx, staty; UINT32 speenframe; INT32 sltw, actw, hetw; UINT8 skintodisplay; INT32 nameboxaddy = 0; - int statoffset = 0; - int gridyoffset = 0; + + const UINT8 *flashcol = V_GetStringColormap(highlightflags); + patch_t *statbg = (patch_t *)W_CachePatchName("K_STATBG", PU_PATCH); + patch_t *statlr = (patch_t *)W_CachePatchName("K_STATLR", PU_PATCH); + patch_t *statud = (patch_t *)W_CachePatchName("K_STATUD", PU_PATCH); + patch_t *statdot = (patch_t *)W_CachePatchName("K_SDOT0" , PU_PATCH); mx = MP_PlayerSetupDef.x; my = MP_PlayerSetupDef.y; @@ -7986,8 +7985,6 @@ static void M_DrawSetupMultiPlayerMenu(void) switch (cv_skinselectmenu.value) { case SKINMENUTYPE_EXTENDED: - nameboxaddy = 6; - break; case SKINMENUTYPE_GRID: nameboxaddy = 6; break; @@ -8003,39 +8000,23 @@ static void M_DrawSetupMultiPlayerMenu(void) else M_DrawTextInput(mx + 40, my + nameboxaddy, &setupm_input, 0); +#define GETSELECTEDSKINNAME (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].realname : skins[setupm_fakeskin].realname) +#define GETSELECTEDSPEED (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartspeed : skins[setupm_fakeskin].kartspeed) +#define GETSELECTEDWEIGHT (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartweight : skins[setupm_fakeskin].kartweight) + // draw skin string st = V_StringWidth(skins[setupm_fakeskin].realname, 0); switch (cv_skinselectmenu.value) { case SKINMENUTYPE_EXTENDED: -#define GETSELECTEDSKINNAME (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].realname : skins[setupm_fakeskin].realname) -#define GETSELECTEDSPEED (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartspeed : skins[setupm_fakeskin].kartspeed) -#define GETSELECTEDWEIGHT (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartweight : skins[setupm_fakeskin].kartweight) - - tw = V_StringWidth("Character", 0);//V_StringWidth(GETSELECTEDSKINNAME, 0); - st = V_StringWidth(GETSELECTEDSKINNAME, 0); - - V_DrawString((mx+(tw/2)) - (st/2), my + 37, - ((MP_PlayerSetupMenu[2].status & IT_TYPE) == IT_SPACE ? V_TRANSLUCENT : 0) | highlightflags | V_ALLOWLOWERCASE, - GETSELECTEDSKINNAME); - if (statdp == true) - statoffset = 50; - else - statoffset = 113; - - V_DrawString(statx - statoffset, staty - 10, V_6WIDTHSPACE, va("\x84%dS \x87%dW", GETSELECTEDSPEED, GETSELECTEDWEIGHT)); -#undef GETSELECTEDSKINNAME -#undef GETSELECTEDSPEED -#undef GETSELECTEDWEIGHT - break; + V_DrawString(statx - (statdp ? 50 : 113), staty - 10, V_6WIDTHSPACE, va("\x84%dS \x87%dW", GETSELECTEDSPEED, GETSELECTEDWEIGHT)); + /* FALLTHRU */ case SKINMENUTYPE_GRID: -#define GETSELECTEDSKINNAME (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].realname : skins[setupm_fakeskin].realname) - tw = V_StringWidth("Character", 0);//V_StringWidth(GETSELECTEDSKINNAME, 0); + tw = V_StringWidth("Character", 0); st = V_StringWidth(GETSELECTEDSKINNAME, 0); V_DrawString((mx+(tw/2)) - (st/2), my + 37, ((MP_PlayerSetupMenu[2].status & IT_TYPE) == IT_SPACE ? V_TRANSLUCENT : 0) | highlightflags | V_ALLOWLOWERCASE, GETSELECTEDSKINNAME); -#undef GETSELECTEDSKINNAME break; case SKINMENUTYPE_2D: @@ -8113,8 +8094,6 @@ static void M_DrawSetupMultiPlayerMenu(void) break; } -#define GRIDSTATOFFSET 0 - switch (cv_skinselectmenu.value) { case SKINMENUTYPE_EXTENDED: @@ -8126,9 +8105,6 @@ static void M_DrawSetupMultiPlayerMenu(void) if (itemOn == 1) V_DrawSmallString(statx+101, staty-37, V_6WIDTHSPACE|highlightflags, "BS: change"); -#define GETSELECTEDSPEED (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartspeed : skins[setupm_fakeskin].kartspeed) -#define GETSELECTEDWEIGHT (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartweight : skins[setupm_fakeskin].kartweight) - if (statdp == true) { //Background @@ -8158,22 +8134,19 @@ static void M_DrawSetupMultiPlayerMenu(void) } } -#undef GETSELECTEDSPEED -#undef GETSELECTEDWEIGHT - break; case SKINMENUTYPE_GRID: // SRB2Kart: draw the stat backer // labels - V_DrawSmallString(statx+12+GRIDSTATOFFSET, staty+67, V_6WIDTHSPACE|highlightflags, "Acceleration"); - V_DrawSmallString(statx+76+GRIDSTATOFFSET, staty+67, V_6WIDTHSPACE|highlightflags, "Max Speed"); - V_DrawSmallString(statx+14+GRIDSTATOFFSET, staty+75, V_6WIDTHSPACE|highlightflags, "Handling"); - V_DrawSmallString(statx+21+GRIDSTATOFFSET, staty+108, V_6WIDTHSPACE|highlightflags, "Weight"); + V_DrawSmallString(statx+12, staty+67, V_6WIDTHSPACE|highlightflags, "Acceleration"); + V_DrawSmallString(statx+76, staty+67, V_6WIDTHSPACE|highlightflags, "Max Speed"); + V_DrawSmallString(statx+14, staty+75, V_6WIDTHSPACE|highlightflags, "Handling"); + V_DrawSmallString(statx+21, staty+108, V_6WIDTHSPACE|highlightflags, "Weight"); // label arrows - V_DrawFixedPatch(((statx+61+GRIDSTATOFFSET)<>1), (staty+67)<>1, 0, statlr, flashcol); - V_DrawFixedPatch((statx+40+GRIDSTATOFFSET)<>1, 0, statud, flashcol); + V_DrawFixedPatch(((statx+61)<>1), (staty+67)<>1, 0, statlr, flashcol); + V_DrawFixedPatch((statx+40)<>1, 0, statud, flashcol); // bg - V_DrawFixedPatch(((statx+48+GRIDSTATOFFSET)<>1), (staty+73)<>1, 0, statbg, NULL); + V_DrawFixedPatch(((statx+48)<>1), (staty+73)<>1, 0, statbg, NULL); for (i = 0; i < numskins; i++) // draw the stat dots { @@ -8181,7 +8154,7 @@ static void M_DrawSetupMultiPlayerMenu(void) { speed = skins[i].kartspeed; weight = skins[i].kartweight; - V_DrawFixedPatch((((statx+46+GRIDSTATOFFSET) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, NULL); + V_DrawFixedPatch((((statx+46) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, NULL); } } @@ -8207,9 +8180,9 @@ static void M_DrawSetupMultiPlayerMenu(void) #define TEXTVERTSHIFT 10 DRAWSLOW(statx - sltw - 2, staty); - DRAWSLOW(statx - sltw - 2, staty - TEXTVERTSHIFT+ (9 * 18) - 11); + DRAWSLOW(statx - sltw - 2, staty - TEXTVERTSHIFT + (9 * 18) - 11); DRAWFAST(statx + (9 * 18), staty); - DRAWFAST(statx + (9 * 18), staty - TEXTVERTSHIFT+ (9 * 18) - 11); + DRAWFAST(statx + (9 * 18), staty - TEXTVERTSHIFT + (9 * 18) - 11); DRAWACCEL(statx - actw - 2, staty + TEXTVERTSHIFT); DRAWACCEL(statx + (9 * 18), staty + TEXTVERTSHIFT); DRAWHEAVY(statx - hetw - 2, staty + (9 * 18) - 11); @@ -8246,15 +8219,18 @@ static void M_DrawSetupMultiPlayerMenu(void) break; } +#undef GETSELECTEDSKINNAME +#undef GETSELECTEDSPEED +#undef GETSELECTEDWEIGHT + switch (cv_skinselectmenu.value) { - //Skin grid stuff - case SKINMENUTYPE_EXTENDED: - gridyoffset = 10; + //Skin grid stuff + case SKINMENUTYPE_EXTENDED: for (s = 0; s < SKINGRIDNEWWIDTH*SKINGRIDNEWHEIGHT; s++) { INT32 x = ((s % SKINGRIDNEWWIDTH) * 18) + ((BASEVIDWIDTH / 2) - (18 * SKINGRIDNEWWIDTH) - 8) + 100 + SKINXSHIFT; //BASEVIDWIDTH / 2 - ((icons + 1) * 24) - 4; - INT32 y = ((s / SKINGRIDNEWWIDTH) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2)) + gridyoffset); //BASEVIDWIDTH / 2 - ((icons + 1) * 24) - 4; + INT32 y = ((s / SKINGRIDNEWWIDTH) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2)) + 10); //BASEVIDWIDTH / 2 - ((icons + 1) * 24) - 4; INT32 calcs = s + (setupm_skinypos * SKINGRIDNEWWIDTH); INT32 skinn; patch_t *face; @@ -8280,7 +8256,7 @@ static void M_DrawSetupMultiPlayerMenu(void) { patch_t *cursor; INT32 curx = (((setupm_skinselect % SKINGRIDNEWWIDTH) * 18) + ((BASEVIDWIDTH / 2) - (18 * SKINGRIDNEWWIDTH/2)) + SKINXSHIFT) + 20; - INT32 cury = (((setupm_skinselect / SKINGRIDNEWWIDTH) - setupm_skinypos) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2))+ gridyoffset); + INT32 cury = (((setupm_skinselect / SKINGRIDNEWWIDTH) - setupm_skinypos) * 18) + ((BASEVIDHEIGHT / 2) - (18 * (SKINGRIDNEWWIDTH/2))+ 10); UINT8 cursorframe = (I_GetTime() / 4) % 7; cursor = (patch_t *)W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_PATCH); @@ -8340,13 +8316,13 @@ static void M_DrawSetupMultiPlayerMenu(void) weight = skins[selectedskin].kartweight; statdot = (patch_t *)W_CachePatchName("K_SDOT1", PU_PATCH); if (skullAnimCounter < 4) // SRB2Kart: we draw this dot later so that it's not covered if there's multiple skins with the same stats - V_DrawFixedPatch((((statx+46+GRIDSTATOFFSET) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, flashcol); + V_DrawFixedPatch((((statx+46) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, flashcol); else - V_DrawFixedPatch((((statx+46+GRIDSTATOFFSET) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, NULL); + V_DrawFixedPatch((((statx+46) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, NULL); statdot = (patch_t *)W_CachePatchName("K_SDOT2", PU_PATCH); // coloured center if (setupm_fakecolor) - V_DrawFixedPatch((((statx+46+GRIDSTATOFFSET) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, R_GetTranslationColormap(0, setupm_fakecolor, GTC_MENUCACHE)); + V_DrawFixedPatch((((statx+46) + (speed*4))<>1), (((staty+71) + (weight*4))<>1, 0, statdot, R_GetTranslationColormap(0, setupm_fakecolor, GTC_MENUCACHE)); } break; case SKINMENUTYPE_2D: @@ -8397,7 +8373,6 @@ static void M_DrawSetupMultiPlayerMenu(void) } } break; -#undef GRIDSTATOFFSET #undef SKINXSHIFT default: speed = skins[setupm_fakeskin].kartspeed; From 898bcd336d2451367bb8bd46b308ee71e9dc22e5 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Apr 2026 18:53:35 +0200 Subject: [PATCH 265/589] should be :chonkbuncle: --- src/lua_hudlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 538463117..444733097 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1297,7 +1297,7 @@ static int lib_hudsetvotebackground(lua_State *L) if (strlen(prefix) != 4) { - return luaL_argerror(L, 1, "prefix should 4 characters wide"); + return luaL_argerror(L, 1, "prefix should be 4 characters wide"); } strncpy(VoteScreen.luaPrefix, prefix, 4); From 8c2132a98c029419429418345d088b4c446ec440 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Apr 2026 21:54:32 +0200 Subject: [PATCH 266/589] remove a few more unused things --- src/d_clisrv.c | 4 +-- src/d_main.c | 12 ++++----- src/dedicated/i_system.c | 4 +++ src/dehacked.c | 57 +++++++++++++++++++++------------------- src/doomstat.h | 7 ----- src/f_finale.c | 8 ------ src/g_demo.c | 5 ++-- src/g_game.c | 9 ------- src/g_game.h | 4 --- src/k_hud.c | 11 ++++++-- src/p_saveg.c | 4 --- src/p_tick.c | 4 +-- src/s_sound.c | 4 +-- 13 files changed, 57 insertions(+), 76 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d9419a15b..5da2b4ee2 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4361,7 +4361,7 @@ void D_ClientServerInit(void) playerinfo[i].node = 255; gametic = 0; - localgametic = 0; + leveltime = 0; // do not send anything before the real begin SV_StopServer(); @@ -6819,7 +6819,7 @@ boolean TryRunTics(tic_t realtics) { boolean update_stats = !(paused || P_AutoPause()); - DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic)); + DEBFILE(va("============ Running tic %d (local %d)\n", gametic, leveltime)); if (update_stats) PS_START_TIMING(ps_tictime); diff --git a/src/d_main.c b/src/d_main.c index a0b1f6fa4..5655d0532 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -697,16 +697,16 @@ void D_SRB2Loop(void) for (;;) { - if (I_Interrupted()) - { - I_Quit(); - } - // capbudget is the minimum precise_t duration of a single loop iteration precise_t capbudget; precise_t elapsed; precise_t enterprecise, finishprecise; + if (I_Interrupted()) + { + I_Quit(); + } + enterprecise = I_GetPreciseTime(); memset(&g_dc, 0, sizeof(g_dc)); @@ -2163,8 +2163,8 @@ void D_SRB2Main(void) if (dedicated && server) { - levelstarttic = gametic; G_SetGamestate(GS_LEVEL); + if (!P_SetupLevel(false, false)) I_Quit(); // fail so reset game stuff } diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 22ef96419..014533af8 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1424,6 +1424,7 @@ void I_Quit(void) /* prevent recursive I_Quit() */ if (quiting) goto death; + quiting = false; I_ShutdownConsole(); M_SaveConfig(NULL); //save game config, cvars.. @@ -1441,14 +1442,17 @@ void I_Quit(void) // use this for 1.28 19990220 by Kin I_ShutdownGraphics(); I_ShutdownSystem(); + /* if option -noendtxt is set, don't print the text */ if (!M_CheckParm("-noendtxt") && W_CheckNumForName("ENDOOM") != LUMPERROR) { printf("\r"); ShowEndTxt(); } + if (myargmalloc) free(myargv); // Deallocate allocated memory + death: W_Shutdown(); exit(0); diff --git a/src/dehacked.c b/src/dehacked.c index a4082c6f2..9f7889945 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2503,26 +2503,12 @@ static void readmaincfg(MYFILE *f) { flashingtics = (UINT16)get_number(word2); } - else if (fastcmp(word, "TAILSFLYTICS")) - { - tailsflytics = (UINT16)get_number(word2); - } - else if (fastcmp(word, "UNDERWATERTICS")) - { - underwatertics = (UINT16)get_number(word2); - } - else if (fastcmp(word, "SPACETIMETICS")) - { - spacetimetics = (UINT16)get_number(word2); - } else if (fastcmp(word, "EXTRALIFETICS")) { + // this modifies player->powers[pw_extralife] + // which still has some game behaviour attached to it... extralifetics = (UINT16)get_number(word2); } - else if (fastcmp(word, "GAMEOVERTICS")) - { - gameovertics = get_number(word2); - } else if (fastcmp(word, "INTROTOPLAY")) { @@ -2546,10 +2532,7 @@ static void readmaincfg(MYFILE *f) if (creditscutscene > 128) creditscutscene = 128; } - else if (fastcmp(word, "NUMDEMOS")) - { - numDemos = (UINT8)get_number(word2); - } + else if (fastcmp(word, "DEMODELAYTIME")) { demoDelayTime = get_number(word2); @@ -2562,10 +2545,6 @@ static void readmaincfg(MYFILE *f) { use1upSound = (UINT8)(value || word2[0] == 'T' || word2[0] == 'Y'); } - else if (fastcmp(word, "MAXXTRALIFE")) - { - continue; // unused - } else if (fastcmp(word, "GAMEDATA")) { // just ignore it but dont throw a warning @@ -2604,6 +2583,30 @@ static void readmaincfg(MYFILE *f) { strlcpy(customversionstring, word2, sizeof (customversionstring)); } + else if (fastcmp(word, "NUMDEMOS")) + { + continue; // unused + } + else if (fastcmp(word, "TAILSFLYTICS")) + { + continue; // unused + } + else if (fastcmp(word, "UNDERWATERTICS")) + { + continue; // unused + } + else if (fastcmp(word, "SPACETIMETICS")) + { + continue; // unused + } + else if (fastcmp(word, "GAMEOVERTICS")) + { + continue; // unused + } + else if (fastcmp(word, "MAXXTRALIFE")) + { + continue; // unused + } else deh_warning("Maincfg: unknown word '%s'", word); } @@ -8572,13 +8575,13 @@ FUNCINLINE static ATTRINLINE int lib_getenum(lua_State *L) const char *word; boolean mathlib = lua_toboolean(L, UV_MATHLIB); - if (lua_type(L,2) != LUA_TSTRING) + if (lua_type(L, 2) != LUA_TSTRING) return 0; - word = lua_tostring(L,2); + word = lua_tostring(L, 2); /* First check actions, as they can be overridden. */ - if (!mathlib && fastncmp("A_",word,2)) + if (!mathlib && fastncmp("A_", word, 2)) { char *caps; // Try to get a Lua action first. diff --git a/src/doomstat.h b/src/doomstat.h index f8216cc1e..e8eae7a4f 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -54,7 +54,6 @@ extern INT16 maptol; extern UINT8 globalweather; extern INT32 curWeather; extern INT32 cursaveslot; -extern INT16 lastmapsaved; extern boolean gamecomplete; #define PRECIP_NONE 0 @@ -78,7 +77,6 @@ extern boolean imcontinuing; // Temporary flag while continuing extern UINT8 modeattacking; // menu demo things -extern UINT8 numDemos; extern UINT32 demoDelayTime; extern UINT32 demoIdleTime; @@ -114,7 +112,6 @@ extern UINT8 paused; // Game paused? extern UINT8 window_notinfocus; // are we in focus? (backend independant -- handles auto pausing and display of "focus lost" message) extern boolean nodrawers; -extern boolean noblit; extern boolean lastdraw; #ifdef MOTIONBLUR @@ -402,9 +399,6 @@ extern boolean CheckForReverseGravity; extern UINT16 invulntics; extern UINT16 sneakertics; extern UINT16 flashingtics; -extern UINT16 tailsflytics; -extern UINT16 underwatertics; -extern UINT16 spacetimetics; extern UINT16 extralifetics; // SRB2kart @@ -490,7 +484,6 @@ extern UINT32 timesBeatenWithEmeralds; // WAD, partly set at startup time. extern tic_t gametic; -#define localgametic leveltime // Player spawn spots. extern mapthing_t *playerstarts[MAXPLAYERS]; // Cooperative diff --git a/src/f_finale.c b/src/f_finale.c index f7efbbced..624b64739 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1110,14 +1110,6 @@ void F_TitleScreenTicker(boolean run) return; } - // Replay intro when done cycling through demos - /*if (curDemo == numDemos) -- uuuh... we have a LOT of maps AND a big devteam... probably not gonna see a repeat unless you're super unlucky :V - { - curDemo = 0; - F_StartIntro(); - return; - }*/ - mapname = G_BuildMapName(G_RandMap(TOL_RACE, -2, false, 0, false, NULL)+1); numstaff = 1; diff --git a/src/g_demo.c b/src/g_demo.c index c36b3273b..850e08048 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -66,12 +66,10 @@ #include // menu demo things -UINT8 numDemos = 0; //3; -- i'm FED UP of losing my skincolour to a broken demo. change this back when we make new ones UINT32 demoDelayTime = 15*TICRATE; UINT32 demoIdleTime = 3*TICRATE; boolean nodrawers = false; // for comparative timing purposes -boolean noblit = false; // for comparative timing purposes static tic_t demostarttime; // for comparative timing purposes //@TODO put these all in a struct for namespacing purposes? @@ -3512,10 +3510,11 @@ static INT32 restorecv_vidwait; void G_TimeDemo(const char *name) { nodrawers = M_CheckParm("-nodraw"); - noblit = M_CheckParm("-noblit"); + restorecv_vidwait = cv_vidwait.value; if (cv_vidwait.value) CV_Set(&cv_vidwait, "0"); + demo.timing = true; singletics = true; framecount = 0; diff --git a/src/g_game.c b/src/g_game.c index f41e7ad79..d2040bcb9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -87,7 +87,6 @@ INT16 maptol = 0; UINT8 globalweather = 0; INT32 curWeather = PRECIP_NONE; INT32 cursaveslot = -1; // Auto-save 1p savegame slot -INT16 lastmapsaved = 0; // Last map we auto-saved at boolean gamecomplete = false; UINT16 mainwads = 0; @@ -108,7 +107,6 @@ INT32 consoleplayer = 0; // player taking events and displaying INT32 displayplayers[MAXSPLITSCREENPLAYERS] = {}; // view being displayed tic_t gametic = 0; -tic_t levelstarttic = 0; // gametic at level start UINT32 totalrings = 0; // for intermission INT16 lastmap = 0; // last level you were at (returning from special stages) tic_t timeinmap = 0; // Ticker for time spent in level (used for levelcard display) @@ -186,9 +184,6 @@ boolean CheckForReverseGravity = false; UINT16 invulntics = 20*TICRATE; UINT16 sneakertics = 20*TICRATE; UINT16 flashingtics = 3*TICRATE/2; // SRB2kart -UINT16 tailsflytics = 8*TICRATE; -UINT16 underwatertics = 30*TICRATE; -UINT16 spacetimetics = 11*TICRATE + (TICRATE/2); UINT16 extralifetics = 4*TICRATE; // SRB2kart @@ -206,8 +201,6 @@ const INT32 wipeoutslowtime = 20; const INT32 wantedreduce = 5*TICRATE; const INT32 wantedfrequency = 10*TICRATE; -INT32 gameovertics = 15*TICRATE; - UINT8 use1upSound = 0; UINT8 introtoplay = 0; @@ -1298,8 +1291,6 @@ static void G_DoLoadLevel(boolean resetplayer) // Make sure objectplace is OFF when you first start the level! OP_ResetObjectplace(); - levelstarttic = gametic; // for time calculation - if (wipegamestate == GS_LEVEL) wipegamestate = -1; // force a wipe diff --git a/src/g_game.h b/src/g_game.h index 6ecc69dfa..76759d257 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -39,12 +39,8 @@ extern INT32 player_name_changes[MAXPLAYERS]; extern player_t players[MAXPLAYERS]; extern boolean playeringame[MAXPLAYERS]; -// gametic at level start -extern tic_t levelstarttic; - // for modding? extern INT16 prevmap, nextmap; -extern INT32 gameovertics; extern tic_t timeinmap; // Ticker for time spent in level (used for levelcard display) extern INT16 rw_maximums[NUM_WEAPONS]; diff --git a/src/k_hud.c b/src/k_hud.c index 1efdcbdcb..bed4c36be 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4022,6 +4022,7 @@ static void K_drawBattleFullscreen(void) { if (stplyrnum == 0) V_DrawFadeScreen(0xFF00, 16); + if (stplyr->exiting < 6*TICRATE && !stplyr->spectator) { if (stplyr->kartstuff[k_position] == 1) @@ -4337,7 +4338,7 @@ static void K_drawInput(void) } else { - const boolean analogjoystickmove = cv_usejoystick[stplyrnum].value && !Joystick[stplyrnum].bGamepadStyle; + const boolean analogjoystickmove = cv_usejoystick[stplyrnum].value && !Joystick[stplyrnum].bGamepadStyle; const boolean gamepadjoystickmove = cv_usejoystick[stplyrnum].value && Joystick[stplyrnum].bGamepadStyle; const UINT8 ssplayer = stplyrnum+1; @@ -4354,9 +4355,10 @@ static void K_drawInput(void) { hudforward += KART_FULLTURN; } + if (InputDown(gc_aimbackward, ssplayer) || (gamepadjoystickmove && axis > 0)) { - hudforward-= KART_FULLTURN; + hudforward -= KART_FULLTURN; } } @@ -4442,6 +4444,7 @@ static void K_drawChallengerScreen(void) 19,20,19,20,19,20,19,20,19,20, // frame 20-21, 1 tic, 5 alternating: all text vibrates from impact 21,22,23,24 // frame 22-25, 1 tic: CHALLENGER turns gold }; + const UINT8 offset = min(52-1, (3*TICRATE)-mapreset); V_DrawFadeScreen(0xFF00, 16); // Fade out @@ -4543,6 +4546,7 @@ static void K_drawDistributionDebugger(void) kp_orbinaut[4], kp_jawz[1] }; + INT32 useodds = 0; INT32 pingame = 0, bestbumper = 0; INT32 i; @@ -4559,8 +4563,10 @@ static void K_drawDistributionDebugger(void) if (!playeringame[i] || players[i].spectator) continue; pingame++; + if (players[i].exiting) dontforcespb = true; + if (players[i].kartstuff[k_bumper] > bestbumper) bestbumper = players[i].kartstuff[k_bumper]; } @@ -4714,6 +4720,7 @@ void K_drawKartHUD(void) { if (LUA_HudEnabled(hud_battlefullscreen)) K_drawBattleFullscreen(); + return; } diff --git a/src/p_saveg.c b/src/p_saveg.c index 64686dfd4..667ee5c47 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3308,8 +3308,6 @@ FUNCINLINE static ATTRINLINE void P_ArchiveMisc(savebuffer_t *save) else WRITEINT16(save->p, gamemap); - lastmapsaved = gamemap; - WRITEUINT16(save->p, (botskin ? (emeralds|(1<<10)) : emeralds)+357); WRITESTRINGN(save->p, timeattackfolder, sizeof(timeattackfolder)); } @@ -3333,8 +3331,6 @@ FUNCINLINE static ATTRINLINE void P_UnArchiveSPGame(savebuffer_t *save, INT16 ma if (!mapheaderinfo[gamemap-1]) P_AllocMapHeader(gamemap-1); - lastmapsaved = gamemap; - tokenlist = 0; token = 0; diff --git a/src/p_tick.c b/src/p_tick.c index 9365f5669..24142a823 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -706,6 +706,7 @@ void P_Ticker(boolean run) if (indirectitemcooldown > 0) indirectitemcooldown--; + if (hyubgone > 0) hyubgone--; @@ -713,8 +714,7 @@ void P_Ticker(boolean run) { K_UpdateSpectateGrief(); } - - if (G_BattleGametype()) + else if (G_BattleGametype()) { if (wantedcalcdelay && --wantedcalcdelay <= 0) K_CalculateBattleWanted(); diff --git a/src/s_sound.c b/src/s_sound.c index 5b959e063..40efbe909 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1398,8 +1398,8 @@ void S_LoadMusicDefs(UINT16 wadnum) for (int k = 0; k < 2; k++) { - const char *lumpname = (k == 1 ? "MUSCINFO" : "MUSICDEF"); - lumpnum = W_CheckNumForNamePwad(lumpname, wadnum, 0); //check for MUSCINFO lump on 2nd iteration + const char *lumpname = (k == 1 ? "MUSCINFO" : "MUSICDEF"); //check for MUSCINFO lump on 2nd iteration + lumpnum = W_CheckNumForNamePwad(lumpname, wadnum, 0); if (lumpnum == INT16_MAX) continue; From 71a0b25e32dfcd40031bc81c3579e14676c001e8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Apr 2026 22:33:09 +0200 Subject: [PATCH 267/589] remove old and unused menu player description stuff hope ignorelines is the correct thing to well ignore lines lol --- src/d_main.c | 4 - src/dehacked.c | 186 +++++++++-------------------------------------- src/doomdata.h | 2 +- src/m_menu.c | 63 ---------------- src/m_menu.h | 22 ------ src/m_menudefs.c | 6 -- 6 files changed, 34 insertions(+), 249 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 5655d0532..84abb528d 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1786,10 +1786,6 @@ void D_SRB2Main(void) // Setup default unlockable conditions M_SetupDefaultConditionSets(); - // Setup character tables - // Have to be done here before files are loaded - M_InitCharacterTables(); - // load wad, including the main wad file CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n"); diff --git a/src/dehacked.c b/src/dehacked.c index 9f7889945..c35092a91 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -280,149 +280,6 @@ static void clear_levels(void) P_AllocMapHeader(gamemap-1); } -static boolean findFreeSlot(INT32 *num) -{ - // Send the character select entry to a free slot. - while (*num < MAXSKINS && PlayerMenu[*num].status != IT_DISABLED) - *num = *num+1; - - // No more free slots. :( - if (*num >= MAXSKINS) - return false; - - // Found one! ^_^ - return true; -} - -// Reads a player. -// For modifying the character select screen -static void readPlayer(MYFILE *f, INT32 num) -{ - char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word; - char *word2; - INT32 i; - boolean slotfound = false; - - do - { - if (myfgets(s, MAXLINELEN, f)) - { - if (s[0] == '\n') - break; - - word = strtok(s, " "); - if (word) - strupr(word); - else - break; - - if (fastcmp(word, "PLAYERTEXT")) - { - char *playertext = NULL; - - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) - goto done; - PlayerMenu[num].status = IT_CALL; - - // A friendly neighborhood alias for brevity's sake - const size_t note_size = sizeof(description[num].notes); - - for (i = 0; i < (INT32)(MAXLINELEN-note_size-3); i++) - { - if (s[i] == '=') - { - playertext = &s[i+2]; - break; - } - } - - if (playertext) - { - strlcpy(description[num].notes, playertext, note_size); - strlcat(description[num].notes, - myhashfgets(playertext, note_size, f), note_size); - } - else - strcpy(description[num].notes, ""); - - // For some reason, cutting the string did not work above. Most likely due to strcpy or strcat... - // It works down here, though. - { - INT32 numline = 0; - for (i = 0; (size_t)i < note_size-1; i++) - { - if (numline < 20 && description[num].notes[i] == '\n') - numline++; - - if (numline >= 20 || description[num].notes[i] == '\0' || description[num].notes[i] == '#') - break; - } - } - - description[num].notes[strlen(description[num].notes)-1] = '\0'; - description[num].notes[i] = '\0'; - continue; - } - - word2 = strtok(NULL, " = "); - if (word2) - strupr(word2); - else - break; - - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - i = atoi(word2); - - if (fastcmp(word, "PICNAME")) - { - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) - goto done; - PlayerMenu[num].status = IT_CALL; - strncpy(description[num].picname, word2, 8); - } - else if (fastcmp(word, "STATUS")) - { - // Limit the status to only IT_DISABLED and IT_CALL - if (i) - i = IT_CALL; - else - i = IT_DISABLED; - - /* - You MAY disable previous entries if you so desire... - But try to enable something that's already enabled and you will be sent to a free slot. - - Because of this, you are allowed to edit any previous entrys you like, but only if you - signal that you are purposely doing so by disabling and then reenabling the slot. - - ... Or use MENUPOSITION first, that works too. Hell, you could edit multiple character - slots in a single section that way, due to how SOC editing works. - */ - if (i != IT_DISABLED && !slotfound && (slotfound = findFreeSlot(&num)) == false) - goto done; - PlayerMenu[num].status = (INT16)i; - } - else if (fastcmp(word, "SKINNAME")) - { - // Send to free slot. - if (!slotfound && (slotfound = findFreeSlot(&num)) == false) - goto done; - PlayerMenu[num].status = IT_CALL; - - strlcpy(description[num].skinname, word2, sizeof description[num].skinname); - strlwr(description[num].skinname); - } - else - deh_warning("readPlayer %d: unknown word '%s'", num, word); - } - } while (!myfeof(f)); // finish when the line is empty - -done: - Z_Free(s); -} - static int freeslotusage[2][2] = {{0, 0}, {0, 0}}; // [S_, MT_][max, previous .wad's max] void DEH_UpdateMaxFreeslots(void) @@ -2820,6 +2677,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) // it doesn't test the version of SRB2 and version of dehacked file dbg_line = -1; // start at -1 so the first line is 0. + while (!myfeof(f)) { char origpos[256]; @@ -2847,11 +2705,15 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) strncpy(origpos, s, size); origpos[size] = '\0'; - if (NULL != (word = strtok(s, " "))) { + if (NULL != (word = strtok(s, " "))) + { strupr(word); - if (word[strlen(word)-1] == '\n') - word[strlen(word)-1] = '\0'; + const size_t wordlen = strlen(word); + + if (word[wordlen-1] == '\n') + word[wordlen-1] = '\0'; } + if (word) { if (fastcmp(word, "FREESLOT")) @@ -2872,32 +2734,46 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) // This is not a major mod. continue; } + word2 = strtok(NULL, " "); + if (fastcmp(word, "CHARACTER")) { - if (word2) { + if (word2) + { strupr(word2); - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + const size_t wordlen = strlen(word2); + + if (word2[wordlen-1] == '\n') + word2[wordlen-1] = '\0'; + i = atoi(word2); - } else + } + else i = 0; + if (i >= 0 && i < 32) - readPlayer(f, i); + ignorelines(f); // unused else { deh_warning("Character %d out of range (0 - 31)", i); ignorelines(f); } + // This is not a major mod. continue; } + if (word2) { strupr(word2); - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + const size_t wordlen = strlen(word2); + + if (word2[wordlen-1] == '\n') + word2[wordlen-1] = '\0'; + i = atoi(word2); + if (fastcmp(word, "PATCH")) { // Read patch from spec file. @@ -2908,6 +2784,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_mobjtype(word2); // find a thing by name + if (i < NUMMOBJTYPES && i >= 0) { if (i < (MT_FIRSTFREESLOT+freeslotusage[1][1])) @@ -2955,6 +2832,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_state(word2); // find a state by name + if (i < NUMSTATES && i >= 0) { if (i < (S_FIRSTFREESLOT+freeslotusage[0][1])) @@ -2971,6 +2849,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_sfx(word2); // find a sound by name + if (i < NUMSFX && i >= 0) readsound(f, i, savesfxnames); else @@ -2984,6 +2863,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) { if (i == 0 && word2[0] != '0') // If word2 isn't a number i = get_huditem(word2); // find a huditem by name + if (i >= 0 && i < NUMHUDITEMS) readhuditem(f, i); else diff --git a/src/doomdata.h b/src/doomdata.h index a646686f1..2f5e014c7 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -61,7 +61,7 @@ enum typedef struct { INT16 x, y; -}ATTRPACK mapvertex_t; +} ATTRPACK mapvertex_t; // A SideDef, defining the visual appearance of a wall, // by setting textures and offsets. diff --git a/src/m_menu.c b/src/m_menu.c index 2dc7119e4..7b20b8f41 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -149,9 +149,6 @@ M_waiting_mode_t m_waiting_mode = M_NOT_WAITING; const char *quitmsg[NUM_QUITMESSAGES] = {}; -// Stuff for customizing the player select screen Tails 09-22-2003 -description_t description[MAXSKINS] = {}; - INT32 mapwads[NUMMAPS] = {}; boolean browselocalskins = false; @@ -1996,8 +1993,6 @@ void M_Ticker(void) // void M_Init(void) { - UINT8 i; - COM_AddCommand("manual", Command_Manual_f); CV_RegisterVar(&cv_nextmap); @@ -2043,15 +2038,6 @@ void M_Init(void) quitmsg[QUIT3MSG5] = M_GetText("You'll be back to play soon, though...\n...right?\n\n(Press 'Y' to quit)"); quitmsg[QUIT3MSG6] = M_GetText("Aww, is Eggman's Nightclub too\ndifficult for you?\n\n(Press 'Y' to quit)"); - // Setup PlayerMenu table - for (i = 0; i < MAXSKINS; i++) - { - PlayerMenu[i].status = (i == 0 ? IT_CALL : IT_DISABLED); - PlayerMenu[i].patch = PlayerMenu[i].text = NULL; - PlayerMenu[i].itemaction = M_ChoosePlayer; - PlayerMenu[i].alphaKey = 0; - } - #ifdef HWRENDER // Permanently hide some options based on render mode if (rendermode == render_soft) @@ -2106,55 +2092,6 @@ void M_Init(void) M_TextInputInit(&menuinput, menu_text_input_buf, sizeof menu_text_input_buf); } -void M_InitCharacterTables(void) -{ - UINT8 i; - - // Setup PlayerMenu table - for (i = 0; i < MAXSKINS; i++) - { - PlayerMenu[i].status = (i < 4 ? IT_CALL : IT_DISABLED); - PlayerMenu[i].patch = PlayerMenu[i].text = NULL; - PlayerMenu[i].itemaction = M_ChoosePlayer; - PlayerMenu[i].alphaKey = 0; - } - - // Setup description table - for (i = 0; i < MAXSKINS; i++) - { - if (i == 0) - { - strcpy(description[i].notes, "\x82Sonic\x80 is the fastest of the three, but also the hardest to control. Beginners beware, but experts will find Sonic very powerful.\n\n\x82""Ability:\x80 Speed Thok\nDouble jump to zoom forward with a huge burst of speed.\n\n\x82Tip:\x80 Simply letting go of forward does not slow down in SRB2. To slow down, hold the opposite direction."); - strcpy(description[i].picname, ""); - strcpy(description[i].skinname, "sonic"); - } - else if (i == 1) - { - strcpy(description[i].notes, "\x82Tails\x80 is the most mobile of the three, but has the slowest speed. Because of his mobility, he's well-\nsuited to beginners.\n\n\x82""Ability:\x80 Fly\nDouble jump to start flying for a limited time. Repetitively hit the jump button to ascend.\n\n\x82Tip:\x80 To quickly descend while flying, hit the spin button."); - strcpy(description[i].picname, ""); - strcpy(description[i].skinname, "tails"); - } - else if (i == 2) - { - strcpy(description[i].notes, "\x82Knuckles\x80 is well-\nrounded and can destroy breakable walls simply by touching them, but he can't jump as high as the other two.\n\n\x82""Ability:\x80 Glide & Climb\nDouble jump to glide in the air as long as jump is held. Glide into a wall to climb it.\n\n\x82Tip:\x80 Press spin while climbing to jump off the wall; press jump instead to jump off\nand face away from\nthe wall."); - strcpy(description[i].picname, ""); - strcpy(description[i].skinname, "knuckles"); - } - else if (i == 3) - { - strcpy(description[i].notes, "\x82Sonic & Tails\x80 team up to take on Dr. Eggman!\nControl Sonic while Tails desperately struggles to keep up.\n\nPlayer 2 can control Tails directly by setting the controls in the options menu.\nTails's directional controls are relative to Player 1's camera.\n\nTails can pick up Sonic while flying and carry him around."); - strcpy(description[i].picname, "CHRS&T"); - strcpy(description[i].skinname, "sonic&tails"); - } - else - { - strcpy(description[i].notes, "???"); - strcpy(description[i].picname, ""); - strcpy(description[i].skinname, ""); - } - } -} - // ========================================================================== // SPECIAL MENU OPTION DRAW ROUTINES GO HERE // ========================================================================== diff --git a/src/m_menu.h b/src/m_menu.h index 2b048fe90..b1070bdc5 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -50,9 +50,6 @@ void M_Drawer(void); // Called by D_SRB2Main, loads the config file. void M_Init(void); -// Called by D_SRB2Main also, sets up the playermenu and description tables. -void M_InitCharacterTables(void); - // Called by intro code to force menu up upon a keypress, // does nothing if menu is already up. void M_StartControlPanel(void); @@ -84,11 +81,6 @@ typedef enum } menumessagetype_t; void M_StartMessage(const char *string, void *routine, menumessagetype_t itemtype); -extern boolean DPADUPSCROLL; -extern boolean DPADDOWNSCROLL; -extern boolean DPADLEFTSCROLL; -extern boolean DPADRIGHTSCROLL; - typedef enum { M_NOT_WAITING, @@ -168,8 +160,6 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt); #define MAXMENUCCVARS 999 -#define MAXTOOLTIPS 255 - typedef union { struct menu_s *submenu; // IT_SUBMENU @@ -195,8 +185,6 @@ typedef struct menuitem_s UINT16 alphaKey; } menuitem_t; -extern menuitem_t PlayerMenu[MAXSKINS]; - typedef struct menu_s { const char *menutitlepic; @@ -227,14 +215,6 @@ extern menu_t SP_LoadDef; void M_SetupJoystickMenu(INT32 choice); extern menu_t OP_JoystickSetDef; -// Stuff for customizing the player select screen -typedef struct -{ - char notes[441]; - char picname[8]; - char skinname[SKINNAMESIZE*2+2]; // skin&skin\0 -} description_t; - // mode descriptions for video mode menu typedef struct { @@ -262,8 +242,6 @@ typedef struct extern INT32 mapwads[NUMMAPS]; -extern description_t description[MAXSKINS]; - extern consvar_t cv_replaysearchrate; extern consvar_t cv_showfocuslost; extern consvar_t cv_newgametype, cv_nextmap, cv_chooseskin, cv_serversort; diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 9eb89515f..af6deacb8 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -495,12 +495,6 @@ static menuitem_t SP_LevelStatsMenu[] = {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleLevelStats, '\0'}, // dummy menuitem for the control func }; -// A rare case. -// External files modify this menu, so we can't call it static. -// And I'm too lazy to go through and rename it everywhere. ARRGH! -#define M_ChoosePlayer NULL -menuitem_t PlayerMenu[MAXSKINS]; - // ----------------------------------- // Multiplayer and all of its submenus // ----------------------------------- From c039d14efc22786813a9ba9ca77710bfd421a41c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Apr 2026 22:41:35 +0200 Subject: [PATCH 268/589] remove even more unused stuff --- src/d_net.h | 1 - src/d_netcmd.h | 5 ---- src/dehacked.c | 3 ++ src/g_game.c | 3 +- src/g_state.h | 1 - src/hardware/hw_main.cpp | 2 +- src/hu_stuff.c | 16 ++-------- src/hu_stuff.h | 5 ---- src/i_joy.h | 3 -- src/m_cheat.c | 8 ----- src/m_cheat.h | 9 ------ src/p_enemy.c | 63 +++++++--------------------------------- src/p_local.h | 7 ----- src/p_mobj.c | 11 +------ src/p_user.c | 2 -- 15 files changed, 20 insertions(+), 119 deletions(-) diff --git a/src/d_net.h b/src/d_net.h index f170cdf05..739b4f2fb 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -27,7 +27,6 @@ extern "C" { // SINT8 is used for nodes sometimes >:( #define MAXNETNODES 127 #define BROADCASTADDR MAXNETNODES -#define NETSPLITSCREEN // Kart's splitscreen netgame feature #define STATLENGTH (TICRATE*2) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index c28df3e7d..c9520f1a7 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -93,11 +93,6 @@ extern consvar_t cv_pause; extern consvar_t cv_restrictskinchange, cv_allowteamchange, cv_ingamecap, cv_respawntime; extern consvar_t cv_spectatorreentry, cv_antigrief; -/*extern consvar_t cv_teleporters, cv_superring, cv_supersneakers, cv_invincibility; -extern consvar_t cv_jumpshield, cv_watershield, cv_ringshield, cv_forceshield, cv_bombshield; -extern consvar_t cv_1up, cv_eggmanbox; -extern consvar_t cv_recycler;*/ - // SRB2kart items extern consvar_t cv_sneaker, cv_rocketsneaker, cv_invincibility, cv_banana; extern consvar_t cv_eggmanmonitor, cv_orbinaut, cv_jawz, cv_mine; diff --git a/src/dehacked.c b/src/dehacked.c index c35092a91..323261243 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -43,6 +43,9 @@ #include "m_cond.h" +// idk how PUSHGETTER works, but this is unused +static UINT8 ultimatemode = false; + #define REQUIRE_MATHLIB_GUID "{748fcbc8-6480-4013-ac4e-7afce6cab766}" // Free slot names diff --git a/src/g_game.c b/src/g_game.c index d2040bcb9..0eb9ee506 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -61,7 +61,6 @@ gameaction_t gameaction = 0; gamestate_t gamestate = GS_NULL; -UINT8 ultimatemode = false; boolean botingame = false; UINT8 botskin = 0; @@ -3394,7 +3393,7 @@ static void G_DoContinued(void) token = 0; // Reset # of lives - pl->lives = (ultimatemode) ? 1 : 3; + pl->lives = 3; D_MapChange(gamemap, gametype, false, false, 0, false, false); diff --git a/src/g_state.h b/src/g_state.h index f9f1babd3..02d876d49 100644 --- a/src/g_state.h +++ b/src/g_state.h @@ -52,7 +52,6 @@ typedef enum } gameaction_t; extern gamestate_t gamestate; -extern UINT8 ultimatemode; // was sk_insane extern gameaction_t gameaction; extern boolean botingame; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 87192e2bd..8f2e33a40 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3862,7 +3862,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) wallVerts[1].y = endbot; // The x and y only need to be adjusted in the case that it's not a papersprite - if (cv_glspritebillboarding.value && sprmo && !papersprite) + if (cv_glspritebillboarding.value && !papersprite) { // Get the x and z of the vertices so billboarding draws correctly realheight = realbot - realtop; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 0f54d7bf8..8a60a1a9e 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1581,7 +1581,6 @@ static void HU_drawMiniChat(void) y = chaty - charheight*(msglines+1); -#ifdef NETSPLITSCREEN if (splitscreen) { y -= BASEVIDHEIGHT/2; @@ -1589,7 +1588,6 @@ static void HU_drawMiniChat(void) y += 16; } else -#endif y -= (cv_kartspeedometer.value ? 16 : 0); dx = 0; @@ -1687,18 +1685,15 @@ static void HU_drawChatLog(INT32 offset) if (chat_scroll > chat_maxscroll) chat_scroll = chat_maxscroll; -#ifdef NETSPLITSCREEN if (splitscreen) { boxh = max(6, boxh/2); if (splitscreen > 1) boxw = max(64, boxw/2); } -#endif y = chaty - offset*charheight - (chat_scroll*charheight) - boxh*charheight - 12; -#ifdef NETSPLITSCREEN if (splitscreen) { y -= BASEVIDHEIGHT/2; @@ -1706,7 +1701,6 @@ static void HU_drawChatLog(INT32 offset) y += 16; } else -#endif y -= (cv_kartspeedometer.value ? 16 : 0); @@ -1821,7 +1815,6 @@ static void HU_DrawChat(void) const char *talk = ntalk; const char *mute = "Chat has been muted."; -#ifdef NETSPLITSCREEN if (splitscreen) { y -= BASEVIDHEIGHT/2; @@ -1832,7 +1825,6 @@ static void HU_DrawChat(void) } } else -#endif y -= (cv_kartspeedometer.value ? 16 : 0); if (teamtalk) @@ -1933,7 +1925,7 @@ static void HU_DrawChat(void) INT32 count = 0; INT32 p_dispy = chaty - charheight - 1; size_t longest_name_length = 0; -#ifdef NETSPLITSCREEN + if (splitscreen) { p_dispy -= BASEVIDHEIGHT/2; @@ -1941,13 +1933,13 @@ static void HU_DrawChat(void) p_dispy += 16; } else -#endif p_dispy -= (cv_kartspeedometer.value ? 16 : 0); // Find longest player name, for drawing background for /pm list later for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) continue; + if (!playeringame[i]) + continue; longest_name_length = max(longest_name_length, strlen(player_names[i])); } @@ -2050,7 +2042,6 @@ static void HU_DrawChat(void) skip = 0; -#ifdef NETSPLITSCREEN if (splitscreen) { suggesty -= BASEVIDHEIGHT/2; @@ -2058,7 +2049,6 @@ static void HU_DrawChat(void) suggesty += 16; } else -#endif suggesty -= (cv_kartspeedometer.value ? 16 : 0); while ((suggest = M_FindEmote(complete, complete_len, skip)) != NULL) diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 85ff630f5..8ba4bce19 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -68,12 +68,7 @@ typedef struct #define HU_MAXMSGLEN 223 #define HU_MSGBUFSIZE 255 #define MAX_CHAT_BUFSIZE 256 // that's enough messages, right? We'll delete the older ones when that gets out of hand. -#define NETSPLITSCREEN // why the hell WOULDN'T we want this? -#ifdef NETSPLITSCREEN #define OLDCHAT (cv_consolechat.value == 1 || dedicated || vid.width < 640) -#else -#define OLDCHAT (cv_consolechat.value == 1 || dedicated || vid.width < 640) -#endif #define CHAT_MUTE (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer))) // this still allows to open the chat but not to type. That's used for scrolling and whatnot. #define OLD_MUTE (OLDCHAT && cv_mute.value && !(server || IsPlayerAdmin(consoleplayer))) // this is used to prevent oldchat from opening when muted. diff --git a/src/i_joy.h b/src/i_joy.h index 20252b54d..d1282e945 100644 --- a/src/i_joy.h +++ b/src/i_joy.h @@ -44,9 +44,6 @@ extern "C" { struct JoyType_s { - /*! if true, we MUST Poll() to get new joystick data, - that is: we NEED the DIRECTINPUTDEVICE2 ! (watchout NT compatibility) */ - INT32 bJoyNeedPoll; /*! this joystick is a gamepad, read: digital axes if FALSE, interpret the joystick event data as JOYAXISRANGE (see above) */ INT32 bGamepadStyle; diff --git a/src/m_cheat.c b/src/m_cheat.c index 8223f2250..783ff3bcb 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -249,9 +249,6 @@ boolean cht_Responder(event_t *ev) #define REQUIRE_SINGLEPLAYER if (netgame || multiplayer)\ { CONS_Printf(M_GetText("This only works in single player.\n")); return; } -#define REQUIRE_NOULTIMATE if (ultimatemode)\ -{ CONS_Printf(M_GetText("You're too good to be cheating!\n")); return; } - // command that can be typed at the console! void Command_CheatNoClip_f(void) { @@ -259,7 +256,6 @@ void Command_CheatNoClip_f(void) REQUIRE_INLEVEL; REQUIRE_SINGLEPLAYER; - REQUIRE_NOULTIMATE; plyr = &players[consoleplayer]; plyr->pflags ^= PF_NOCLIP; @@ -274,7 +270,6 @@ void Command_CheatGod_f(void) REQUIRE_INLEVEL; REQUIRE_SINGLEPLAYER; - REQUIRE_NOULTIMATE; plyr = &players[consoleplayer]; plyr->pflags ^= PF_GODMODE; @@ -289,7 +284,6 @@ void Command_CheatNoTarget_f(void) REQUIRE_INLEVEL; REQUIRE_SINGLEPLAYER; - REQUIRE_NOULTIMATE; plyr = &players[consoleplayer]; plyr->pflags ^= PF_INVIS; @@ -593,7 +587,6 @@ void Command_Devmode_f(void) #ifndef _DEBUG REQUIRE_SINGLEPLAYER; #endif - REQUIRE_NOULTIMATE; if (COM_Argc() > 1) { @@ -1048,7 +1041,6 @@ void Command_ObjectPlace_f(void) { REQUIRE_INLEVEL; REQUIRE_SINGLEPLAYER; - REQUIRE_NOULTIMATE; G_SetGameModified(multiplayer, true); diff --git a/src/m_cheat.h b/src/m_cheat.h index f2944c27c..aaf038436 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -29,7 +29,6 @@ void Command_ObjectPlace_f(void); void Command_Writethings_f(void); extern consvar_t cv_opflags, cv_mapthingnum, cv_speed; -//extern consvar_t cv_snapto, cv_grid; extern boolean objectplacing; extern mobjtype_t op_currentthing; @@ -48,18 +47,10 @@ void Command_CheatNoClip_f(void); void Command_CheatGod_f(void); void Command_CheatNoTarget_f(void); void Command_Savecheckpoint_f(void); -/*void Command_Getallemeralds_f(void); -void Command_Resetemeralds_f(void); -void Command_Setrings_f(void); -void Command_Setlives_f(void); -void Command_Setcontinues_f(void);*/ void Command_Devmode_f(void); void Command_Scale_f(void); void Command_Gravflip_f(void); void Command_Hurtme_f(void); -/*void Command_JumpToAxis_f(void); -void Command_Charability_f(void); -void Command_Charspeed_f(void);*/ void Command_Teleport_f(void); void Command_RTeleport_f(void); void Command_Skynum_f(void); diff --git a/src/p_enemy.c b/src/p_enemy.c index cb9b16f2d..f1a0ed535 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -1531,10 +1531,7 @@ void A_LobShot(void *thing) if (!(actor->flags & MF_BOSS)) { - if (ultimatemode) - actor->reactiontime = actor->info->reactiontime*TICRATE; - else - actor->reactiontime = actor->info->reactiontime*TICRATE*2; + actor->reactiontime = actor->info->reactiontime*TICRATE*2; } } @@ -1570,10 +1567,7 @@ void A_FireShot(void *thing) if (!(actor->flags & MF_BOSS)) { - if (ultimatemode) - actor->reactiontime = actor->info->reactiontime*TICRATE; - else - actor->reactiontime = actor->info->reactiontime*TICRATE*2; + actor->reactiontime = actor->info->reactiontime*TICRATE*2; } } @@ -1613,10 +1607,7 @@ void A_SuperFireShot(void *thing) if (!(actor->flags & MF_BOSS)) { - if (ultimatemode) - actor->reactiontime = actor->info->reactiontime*TICRATE; - else - actor->reactiontime = actor->info->reactiontime*TICRATE*2; + actor->reactiontime = actor->info->reactiontime*TICRATE*2; } } @@ -2870,12 +2861,6 @@ void A_ExtraLife(void *thing) if (actor->type == MT_1UPICO && !actor->tracer) actor->frame -= 2; // No lives icon for this player, use the default. - if (ultimatemode) //I don't THINK so! - { - S_StartSound(player->mo, sfx_lose); - return; - } - // In shooter gametypes, give the player 100 rings instead of an extra life. if (gametype != GT_COOP && gametype != GT_COMPETITION) P_GivePlayerRings(player, 100); @@ -4015,26 +4000,13 @@ void A_JetChase(void *thing) } // chase towards player - if (ultimatemode) - P_Thrust(actor, actor->angle, FixedMul(actor->info->speed/2, actor->scale)); - else - P_Thrust(actor, actor->angle, FixedMul(actor->info->speed/4, actor->scale)); + P_Thrust(actor, actor->angle, FixedMul(actor->info->speed/4, actor->scale)); // must adjust height - if (ultimatemode) - { - if (actor->z < (actor->target->z + actor->target->height + FixedMul((64<scale))) - actor->momz += FixedMul(FRACUNIT/2, actor->scale); - else - actor->momz -= FixedMul(FRACUNIT/2, actor->scale); - } + if (actor->z < (actor->target->z + actor->target->height + FixedMul((32<scale))) + actor->momz += FixedMul(FRACUNIT/2, actor->scale); else - { - if (actor->z < (actor->target->z + actor->target->height + FixedMul((32<scale))) - actor->momz += FixedMul(FRACUNIT/2, actor->scale); - else - actor->momz -= FixedMul(FRACUNIT/2, actor->scale); - } + actor->momz -= FixedMul(FRACUNIT/2, actor->scale); } // Function: A_JetbThink @@ -4137,10 +4109,7 @@ void A_JetgShoot(void *thing) A_FaceTarget(actor); P_SpawnMissile(actor, actor->target, (mobjtype_t)actor->info->raisestate); - if (ultimatemode) - actor->reactiontime = actor->info->reactiontime*TICRATE; - else - actor->reactiontime = actor->info->reactiontime*TICRATE*2; + actor->reactiontime = actor->info->reactiontime*TICRATE*2; if (actor->info->attacksound) S_StartSound(actor, actor->info->attacksound); @@ -6463,12 +6432,8 @@ void A_BuzzFly(void *thing) // chase towards player { INT32 dist, realspeed; - const fixed_t mf = 5*(FRACUNIT/4); - if (ultimatemode) - realspeed = FixedMul(FixedMul(actor->info->speed,mf), actor->scale); - else - realspeed = FixedMul(actor->info->speed, actor->scale); + realspeed = FixedMul(actor->info->speed, actor->scale); dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z); @@ -9256,10 +9221,7 @@ void A_MultiShot(void *thing) if (!(actor->flags & MF_BOSS)) { - if (ultimatemode) - actor->reactiontime = actor->info->reactiontime*TICRATE; - else - actor->reactiontime = actor->info->reactiontime*TICRATE*2; + actor->reactiontime = actor->info->reactiontime*TICRATE*2; } } @@ -10868,10 +10830,7 @@ void A_BrakFireShot(void *thing) if (!(actor->flags & MF_BOSS)) { - if (ultimatemode) - actor->reactiontime = actor->info->reactiontime*TICRATE; - else - actor->reactiontime = actor->info->reactiontime*TICRATE*2; + actor->reactiontime = actor->info->reactiontime*TICRATE*2; } } diff --git a/src/p_local.h b/src/p_local.h index 95020c022..b71e99ebd 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -99,9 +99,6 @@ typedef struct camera_s // Hold up/down to pan the camera vertically SINT8 dpad_y_held; - // Things used by FS cameras. - fixed_t viewheight; - angle_t startangle; // Camera demobjerization // Info for drawing: position. @@ -121,8 +118,6 @@ typedef struct camera_s fixed_t radius; fixed_t height; - fixed_t relativex; - // Momentums, used to update position. fixed_t momx, momy, momz; @@ -219,7 +214,6 @@ void P_DoJumpShield(player_t *player); void P_BlackOw(player_t *player); void P_ElementalFireTrail(player_t *player); -//void P_DoPityCheck(player_t *player); void P_PlayerThink(player_t *player); void P_PlayerAfterThink(player_t *player); void P_DoPlayerExit(player_t *player); @@ -280,7 +274,6 @@ void P_RemoveMobj(mobj_t *th); void P_RemoveSavegameMobj(mobj_t *th); boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state); boolean P_SetMobjState(mobj_t *mobj, statenum_t state); -//void P_RunShields(void); void P_RunOverlays(void); void P_RunShadows(void); void P_MobjThinker(mobj_t *mobj); diff --git a/src/p_mobj.c b/src/p_mobj.c index 28b85dea6..a413feda8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11163,16 +11163,7 @@ void P_SpawnMapThing(mapthing_t *mthing) } } - if (ultimatemode) - { - if (i == MT_PITYTV || i == MT_GREENTV || i == MT_YELLOWTV || i == MT_BLUETV || i == MT_BLACKTV || i == MT_WHITETV) - return; // No shields in Ultimate mode - - if (i == MT_SUPERRINGBOX) - return; // No rings in Ultimate mode (except special stages) - } - - if (i == MT_EMMY && (gametype != GT_COOP || ultimatemode || tokenbits == 30 || tokenlist & (1 << tokenbits++))) + if (i == MT_EMMY && (gametype != GT_COOP || tokenbits == 30 || tokenlist & (1 << tokenbits++))) return; // you already got this token, or there are too many, or the gametype's not right // Objectplace landing point diff --git a/src/p_user.c b/src/p_user.c index 24b646ee3..ba39f0472 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3478,8 +3478,6 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) } } - thiscam->relativex = 0; - thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y); thiscam->radius = 20*FRACUNIT; From 27f22e4b5b44e159fd8d7c6c505cea289488525b Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 9 Apr 2026 19:09:27 +0300 Subject: [PATCH 269/589] Use case insensitive string hashing and compare functions for cvar hashtable --- src/command.c | 4 ++-- src/verstable.h | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/command.c b/src/command.c index 2eac48a7f..f09f7bf47 100644 --- a/src/command.c +++ b/src/command.c @@ -1168,8 +1168,8 @@ void VS_Print(vsbuf_t *buf, const char *data) #define NAME cvar_map_t #define KEY_TY const char * #define VAL_TY consvar_t * -#define HASH_FN vt_hash_string -#define CMPR_FN vt_cmpr_string +#define HASH_FN FNV1a_HashLowercaseString +#define CMPR_FN vt_cmpr_casestring #include "verstable.h" #define NAME netvar_map_t diff --git a/src/verstable.h b/src/verstable.h index b3fe13f91..d7165e4e9 100644 --- a/src/verstable.h +++ b/src/verstable.h @@ -462,6 +462,8 @@ License (MIT): #include #include +#include "fastcmp.h" + // Two-way concatenation macro. #define VT_CAT_( a, b ) a##b #define VT_CAT( a, b ) VT_CAT_( a, b ) @@ -705,7 +707,12 @@ static inline FORCE_INLINE bool vt_cmpr_integer( uint64_t key_1, uint64_t key_2 static inline FORCE_INLINE bool vt_cmpr_string( const char *key_1, const char *key_2 ) { - return strcmp( key_1, key_2 ) == 0; + return fastcmp( key_1, key_2 ); +} + +static inline FORCE_INLINE bool vt_cmpr_casestring( const char *key_1, const char *key_2 ) +{ + return fasticmp( key_1, key_2 ); } // Default allocation and free functions. From e5c0967a3ffefb2651c9135e5123d4703aee3af6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Apr 2026 16:34:32 +0200 Subject: [PATCH 270/589] BLUA: simplify lua number hash --- src/blua/ltable.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/blua/ltable.c b/src/blua/ltable.c index b21bc4bfa..dc4de9c62 100644 --- a/src/blua/ltable.c +++ b/src/blua/ltable.c @@ -81,6 +81,7 @@ static /*const*/ Node dummynode_ = { /* ** hash for lua_Numbers */ +#if 0 static Node *hashnum (const Table *t, lua_Number n) { unsigned int a[numints]; int i; @@ -90,6 +91,12 @@ static Node *hashnum (const Table *t, lua_Number n) { for (i = 1; i < numints; i++) a[0] += a[i]; return hashmod(t, a[0]); } +#else +// our lua_Number is just typedef´d int32 so no need to do any of the above +static inline Node *hashnum (const Table *t, lua_Number n) { + return hashmod(t, cast(unsigned int, n)); +} +#endif From 1217089d819a807d27b95e5417d7f1bbe35e9576 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 11 Apr 2026 21:53:15 +0300 Subject: [PATCH 271/589] G_UseContinue is unused, delet it --- src/g_game.c | 12 ------------ src/g_game.h | 1 - 2 files changed, 13 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 0eb9ee506..6554a22be 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3343,18 +3343,6 @@ static void G_DoStartVote(void) gameaction = ga_nothing; } -// -// G_UseContinue -// -void G_UseContinue(void) -{ - if (gamestate == GS_LEVEL && !netgame && !multiplayer) - { - gameaction = ga_startcont; - lastdraw = true; - } -} - static void G_DoStartContinue(void) { I_Assert(!netgame && !multiplayer); diff --git a/src/g_game.h b/src/g_game.h index 76759d257..f1ed7834e 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -248,7 +248,6 @@ UINT8 G_GetGametypeColor(INT16 gt); void G_ExitLevel(void); void G_NextLevel(void); void G_Continue(void); -void G_UseContinue(void); void G_AfterIntermission(void); void G_EndGame(void); // moved from y_inter.c/h and renamed From eccc3eb33fb280fd3dfa10e3a6ae5f22aacf25dd Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Apr 2026 14:27:44 +0200 Subject: [PATCH 272/589] print opengl extensions in new lines for ogllog otherwise this may still get truncated and lots of text editor also complain about a super long single line of text also fix null ptr dereferencing into strtok should strdup return null --- src/hardware/hw_main.cpp | 4 +++- src/sdl/ogl_sdl.c | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 8f2e33a40..9e0dd6ea6 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5979,7 +5979,7 @@ static void COM_HWR_glinfo(void) // if the GPU is super new and supports a bajillion extensions - xyzzy char *copy = strdup((const char*)gl_extensions); - char *ext = strtok(copy, " "); + char *ext; if (copy == NULL) { @@ -5987,6 +5987,8 @@ static void COM_HWR_glinfo(void) return; } + ext = strtok(copy, " "); + do { CONS_Printf(" - %s\n", ext); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index d50cdbe93..46af6e178 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -137,13 +137,13 @@ boolean OglSdlSurface(INT32 w, INT32 h) GL_DBG_Printf("OpenGL %s\n", gl_version); GL_DBG_Printf("GPU: %s\n", gl_renderer); - GL_DBG_Printf("Extensions:"); + GL_DBG_Printf("Extensions: \n"); { // Need to do it with strtok for same reason its done like that in gr_glinfo command char *copy = strdup((const char*)gl_extensions); - char *ext = strtok(copy, " "); + char *ext; if (copy == NULL) { @@ -151,9 +151,11 @@ boolean OglSdlSurface(INT32 w, INT32 h) } else { + ext = strtok(copy, " "); + do { - GL_DBG_Printf(" %s", ext); + GL_DBG_Printf(" - %s\n", ext); } while ((ext = strtok(NULL, " ")) != NULL); free(copy); From e0bf663157e280882ec3446ee555349f8625ffcf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Apr 2026 15:05:51 +0200 Subject: [PATCH 273/589] Hack: fix intermission screen displaying whitescreen in some cases does not fix whitescreen when switching resolutions while in intermission screen, but oh well lets hope there will be no issues with calling D_Renderview in intermission state, but it seems to work from quick testing lul --- src/d_main.c | 46 +++++++++++++++----- src/hardware/hw_main.cpp | 91 ++++++++++++++++++++-------------------- src/hardware/hw_main.h | 5 +++ 3 files changed, 87 insertions(+), 55 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 84abb528d..5a5ecb510 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -362,6 +362,40 @@ static void D_Renderview(void) // added comment : there is a wipe eatch change of the gamestate gamestate_t wipegamestate = GS_LEVEL; +static void D_MakeIntermissionBG(void) +{ + if (rendermode == render_none) + return; + + if (!lastdraw) + return; + + // no more valid map + // shouldnt happen at this point, but better safe than sorry! + if (!numsectors) + return; + + // need to render level again for this + // should be fine since at this point we did not unload it yet + if (cv_renderview.value) + { + D_Renderview(); + } + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + HWR_MakeScreenTexture(); + } + else +#endif + { + VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.width, vid.width); + } + + lastdraw = false; +} + static boolean D_Display(void) { boolean ranwipe = false; @@ -519,6 +553,8 @@ static boolean D_Display(void) break; } + D_MakeIntermissionBG(); + if (gamestate == GS_LEVEL) { // draw the view directly @@ -529,16 +565,6 @@ static boolean D_Display(void) PS_STOP_TIMING(ps_rendercalltime); } - if (lastdraw) - { - if (rendermode == render_soft) - { - VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.width, vid.width); - } - - lastdraw = false; - } - PS_START_TIMING(ps_uitime); ST_Drawer(); HU_Drawer(); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 9e0dd6ea6..f458015ae 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -6093,61 +6093,62 @@ static void HWR_DoPostProcessor(void) if (cv_glscreentextures.value != 2) // screen textures are needed for the rest of the effects return; - //UINT8 viewnum = R_GetViewNumber(); // see below + // Not supported in splitscreen - someone want to add support? + if (splitscreen || cv_reducevfx.value) + return; + + //UINT8 viewnum = R_GetViewNumber(); //camera_t *thiscam = &camera[viewnum]; const camera_t *thiscam = &camera[0]; - // Not supported in splitscreen - someone want to add support? - const boolean screenwave = (!splitscreen && !cv_reducevfx.value && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); + if (!(thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)) + return; // Capture the screen for intermission and screen waving - if ((lastdraw || screenwave) && gamestate != GS_INTERMISSION) + if (gamestate != GS_INTERMISSION) GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); // Drunken vision! WooOOooo~ - if (screenwave) + // 10 by 10 grid. 2 coordinates (xy) + float v[SCREENVERTS][SCREENVERTS][2]; + float disStart = (leveltime-1) + FixedToFloat(R_GetTimeFrac(RTF_LEVEL)); + + UINT8 x, y; + float WAVELENGTH; + float AMPLITUDE; + float FREQUENCY; + + // Modifies the wave. + if (thiscam->postimg & POSTIMG_WATER) { - // 10 by 10 grid. 2 coordinates (xy) - float v[SCREENVERTS][SCREENVERTS][2]; - float disStart = (leveltime-1) + FixedToFloat(R_GetTimeFrac(RTF_LEVEL)); - - UINT8 x, y; - float WAVELENGTH; - float AMPLITUDE; - float FREQUENCY; - - // Modifies the wave. - if (thiscam->postimg & POSTIMG_WATER) - { - WAVELENGTH = 5.0f; - AMPLITUDE = 40.0f; - FREQUENCY = 8.0f; - } - else - { - WAVELENGTH = 10.0f; - AMPLITUDE = 60.0f; - FREQUENCY = 4.0f; - } - - //static constexpr float scale = ((float)SCREENVERTS - 1.0f) / 9.0f; // well this evals to just 1.0f and what is x / 1? kek - - for (x = 0; x < SCREENVERTS; x++) - { - for (y = 0; y < SCREENVERTS; y++) - { - // Change X position based on its Y position. - v[x][y][0] = x-4.5f + sinf(((disStart+(static_cast(y) * WAVELENGTH)) / FREQUENCY)) / AMPLITUDE; // (x / scale) - v[x][y][1] = y-4.5f; // (y / scale) - } - } - - GL_PostImgRedraw(v); - - // Capture the screen again for screen waving on the intermission - if (gamestate != GS_INTERMISSION) - GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); + WAVELENGTH = 5.0f; + AMPLITUDE = 40.0f; + FREQUENCY = 8.0f; } + else + { + WAVELENGTH = 10.0f; + AMPLITUDE = 60.0f; + FREQUENCY = 4.0f; + } + + //static constexpr float scale = ((float)SCREENVERTS - 1.0f) / 9.0f; // well this evals to just 1.0f and what is x / 1? kek + + for (x = 0; x < SCREENVERTS; x++) + { + for (y = 0; y < SCREENVERTS; y++) + { + // Change X position based on its Y position. + v[x][y][0] = x-4.5f + sinf(((disStart+(static_cast(y) * WAVELENGTH)) / FREQUENCY)) / AMPLITUDE; // (x / scale) + v[x][y][1] = y-4.5f; // (y / scale) + } + } + + GL_PostImgRedraw(v); + + // Capture the screen again for screen waving on the intermission + if (gamestate != GS_INTERMISSION) + GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); // Flipping of the screen isn't done here anymore } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 8a501f727..cbd8e11e7 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -151,6 +151,11 @@ FUNCINLINE static ATTRINLINE void HWR_RenderVhsEffect(fixed_t upbary, fixed_t do GL_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize); } +FUNCINLINE static ATTRINLINE void HWR_MakeScreenTexture(void) +{ + GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); +} + FUNCINLINE static ATTRINLINE void HWR_MakeScreenFinalTexture(void) { GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); From 4edc102d671bb1e10d01d64f5024a23692c1d9ad Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Apr 2026 15:23:45 +0200 Subject: [PATCH 274/589] hack: fix intermission background becoming white after resolution change --- src/d_main.c | 13 +++++++++---- src/hardware/hw_main.cpp | 4 +++- src/screen.c | 4 ++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 5a5ecb510..9443c0a47 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -364,16 +364,22 @@ gamestate_t wipegamestate = GS_LEVEL; static void D_MakeIntermissionBG(void) { - if (rendermode == render_none) - return; - if (!lastdraw) return; + if (rendermode == render_none) + { + lastdraw = false; + return; + } + // no more valid map // shouldnt happen at this point, but better safe than sorry! if (!numsectors) + { + lastdraw = false; return; + } // need to render level again for this // should be fine since at this point we did not unload it yet @@ -381,7 +387,6 @@ static void D_MakeIntermissionBG(void) { D_Renderview(); } - #ifdef HWRENDER if (rendermode == render_opengl) { diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index f458015ae..6e41a7d3b 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -254,11 +254,13 @@ static void CV_screentextures_OnChange(void) { if (cv_glpaletterendering.value != 0) CV_SetValue(&cv_glpaletterendering, 0); - #ifdef USE_FBO_OGL if (cv_glframebuffer.value != 0) CV_SetValue(&cv_glframebuffer, 0); #endif + // HACK: set lastdraw so intermission bg can refresh after toggling screentextures + if (gamestate == GS_INTERMISSION) + lastdraw = true; } GL_SetSpecialState(HWD_SET_SCREEN_TEXTURES, cv_glscreentextures.value); M_UpdateOGLMenu(); diff --git a/src/screen.c b/src/screen.c index ebc5abddf..84e81617a 100644 --- a/src/screen.c +++ b/src/screen.c @@ -277,6 +277,10 @@ void SCR_Recalc(void) // vid.recalc lasts only for the next refresh... con_recalc = true; am_recalc = true; + + // HACK: set lastdraw so intermission bg can refresh after resolution change + if (gamestate == GS_INTERMISSION) + lastdraw = true; } // Check for screen cmd-line parms: to force a resolution. From 6c58c0de415d63bd95c48615cedd27df3b15ecc4 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Fri, 13 Jun 2025 09:40:57 -0400 Subject: [PATCH 275/589] Add support for using custom SDL2 mappings --- src/sdl/i_system.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 3206bec70..ae11829c6 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -975,6 +975,18 @@ void I_InitJoystick(UINT8 index) if (M_CheckParm("-nojoy")) return; + { + char dbpath[1024]; + sprintf(dbpath, "%s" PATHSEP "gamecontrollerdb.txt", srb2path); + SDL_GameControllerAddMappingsFromFile(dbpath); + } + + { + char dbpath[1024]; + sprintf(dbpath, "%s" PATHSEP "gamecontrollerdb_user.txt", srb2home); + SDL_GameControllerAddMappingsFromFile(dbpath); + } + if (M_CheckParm("-noxinput")) SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); From 81f46224e13e904a1a1a72d00dfe79a81c055a57 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Mon, 13 Apr 2026 18:32:26 +0200 Subject: [PATCH 276/589] Fix asan error when pressing shift and arrow key Also fix addons menu ignoring shift when capslock is on! Also also fix capslock+rshift still typing uppercase letters! --- src/console.c | 193 +++++++++++++++++++++++++++++++++++++++++----- src/hu_stuff.c | 155 ------------------------------------- src/hu_stuff.h | 13 ---- src/m_menu.c | 29 +------ src/sdl/i_video.c | 1 - 5 files changed, 174 insertions(+), 217 deletions(-) diff --git a/src/console.c b/src/console.c index 50d10d020..d02f68bb6 100644 --- a/src/console.c +++ b/src/console.c @@ -208,14 +208,6 @@ static void CONS_Clear_f(void) Unlock_state(); } -// Choose english keymap -// -/*static void CONS_English_f(void) -{ - shiftxform = english_shiftxform; - CONS_Printf(M_GetText("%s keymap.\n"), M_GetText("English")); -}*/ - static char *bindtable[NUMINPUTS]; static void CONS_Bind_f(void) @@ -633,27 +625,186 @@ void CON_MoveConsole(void) Unlock_state(); } +//====================================================================== +// KEYBOARD LAYOUTS FOR ENTERING TEXT +//====================================================================== + +static char english_shiftxform[] = +{ + 0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, + ' ', '!', '"', '#', '$', '%', '&', + '"', // shift-' + '(', ')', '*', '+', + '<', // shift-, + '_', // shift-- + '>', // shift-. + '?', // shift-/ + ')', // shift-0 + '!', // shift-1 + '@', // shift-2 + '#', // shift-3 + '$', // shift-4 + '%', // shift-5 + '^', // shift-6 + '&', // shift-7 + '*', // shift-8 + '(', // shift-9 + ':', + ':', // shift-; + '<', + '+', // shift-= + '>', '?', '@', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '{', // shift-[ + '|', // shift-backslash - OH MY GOD DOES WATCOM SUCK + '}', // shift-] + '"', '_', + '~', // shift-` + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '{', '|', '}', '~', 127 +}; + +static char french_shiftxform[] = +{ + 0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, + ' ','$', //shift-! + '3', //shift-" + '#', '$', '%', + '1', //shift-& + '4', // shift-' + '5', // shift-( + ')', // shift-) + '*', '+', + '?', // shift-, + '6', // shift-- + '.', '/', + '0', '1', '2', '3', '4', '5', + '6', '7', '8', '9', + '/', // shitf-: + '.', // shift-; + '>', // shift-< + '+', // shift-= + '>', '?', '@', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '[', '\\', ']', '^', + '8', //shift-_ + '`', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '{', '|', '}', '~', 127, + 128, 129, + '2', + 131, 132, + '0', + 134, + '9', + 136, 137, + '7', + 139, 140, + '%' +}; + +static char french_altgrxform[] = +{ + 0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, + ' ', '!', + '#', //altgr-" + '#', '$', '%', '&', + '{', //altgr-' + '[', //altgr-( + ']', //altgr-) + '*', '+', ',', + '|', //altg-- + '.', '/', + '0', '1', '2', '3', '4', '5', + '6', '7', '8', '9', + ':', ';', '<', + '}', //altgr-= + '>', '?', '@', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '[', '\\', ']', '^', + '\\', //altgr-backslash + '`', + 'a', 'b', 'c', 'd', 'E', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '{', '|', '}', '~', 127, + 128, 129, + '~', + 131, 132, + '@', + 134, + '^', + 136, 137, + '`', + 139, 140, + KEY_FR_U_GRAVE +}; + +// fallback for special letter non displayable in the game (i.e.: 'é','à',etc.) +static INT32 CON_FallBackFrSpecialLetter(INT32 key) +{ + switch (key) + { + case KEY_FR_E_AIGUE: return 'e'; + case KEY_FR_E_GRAVE: return 'e'; + case KEY_FR_C_CEDILLE: return 'c'; + case KEY_FR_A_GRAVE: return 'a'; + case KEY_FR_U_GRAVE: return 'u'; + default: return key; + } +} + +// goddang AZERTY +static size_t CON_GetShiftSize(void) +{ + return ((cv_keyboardlayout.value == 3) ? sizeof(french_shiftxform) : sizeof(english_shiftxform)); +} + +static char *CON_Shiftform(void) +{ + return (cv_keyboardlayout.value == 3) ? french_shiftxform : english_shiftxform; +} + INT32 CON_ShiftChar(INT32 ch) { - if (I_UseNativeKeyboard()) + if (I_UseNativeKeyboard() || ch >= (INT32)CON_GetShiftSize()) return ch; + // warning: shiftdown is NOT a boolean, it's 1 or 2 for lshift/rshift if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { - if (shiftdown ^ capslock) - ch = shiftxform[ch]; + return !!shiftdown != capslock ? CON_Shiftform()[ch] : ch; } - else // if we're holding shift we should still shift non letter symbols + + // if we're holding shift we should still shift non letter symbols + if (shiftdown) { - if (shiftdown) - ch = shiftxform[ch]; - else if (cv_keyboardlayout.value == 3) - { - if (altdown & 0x2) - ch = french_altgrxform[ch]; - else - ch = HU_FallBackFrSpecialLetter(ch); - } + return CON_Shiftform()[ch]; + } + + // AZERTY + if (cv_keyboardlayout.value == 3) + { + if (altdown & 0x2) + return french_altgrxform[ch]; + + return CON_FallBackFrSpecialLetter(ch); } return ch; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 8a60a1a9e..4f84fad89 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -115,155 +115,8 @@ static patch_t *songcreditbg = NULL; // ------- static void HU_DrawRankings(void); - consvar_t cv_showspecstuff = {"showspecstuff", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -//====================================================================== -// KEYBOARD LAYOUTS FOR ENTERING TEXT -//====================================================================== - -char *shiftxform = NULL; - -char english_shiftxform[] = -{ - 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, - ' ', '!', '"', '#', '$', '%', '&', - '"', // shift-' - '(', ')', '*', '+', - '<', // shift-, - '_', // shift-- - '>', // shift-. - '?', // shift-/ - ')', // shift-0 - '!', // shift-1 - '@', // shift-2 - '#', // shift-3 - '$', // shift-4 - '%', // shift-5 - '^', // shift-6 - '&', // shift-7 - '*', // shift-8 - '(', // shift-9 - ':', - ':', // shift-; - '<', - '+', // shift-= - '>', '?', '@', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '{', // shift-[ - '|', // shift-backslash - OH MY GOD DOES WATCOM SUCK - '}', // shift-] - '"', '_', - '~', // shift-` - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '{', '|', '}', '~', 127 -}; - -char french_shiftxform[] = -{ - 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, - ' ','$', //shift-! - '3', //shift-" - '#', '$', '%', - '1', //shift-& - '4', // shift-' - '5', // shift-( - ')', // shift-) - '*', '+', - '?', // shift-, - '6', // shift-- - '.', '/', - '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', - '/', // shitf-: - '.', // shift-; - '>', // shift-< - '+', // shift-= - '>', '?', '@', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '[', '\\', ']', '^', - '8', //shift-_ - '`', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '{', '|', '}', '~', 127, - 128, 129, - '2', - 131, 132, - '0', - 134, - '9', - 136, 137, - '7', - 139, 140, - '%' -}; - -char french_altgrxform[] = -{ - 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, - ' ', '!', - '#', //altgr-" - '#', '$', '%', '&', - '{', //altgr-' - '[', //altgr-( - ']', //altgr-) - '*', '+', ',', - '|', //altg-- - '.', '/', - '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', - ':', ';', '<', - '}', //altgr-= - '>', '?', '@', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '[', '\\', ']', '^', - '\\', //altgr-backslash - '`', - 'a', 'b', 'c', 'd', 'E', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '{', '|', '}', '~', 127, - 128, 129, - '~', - 131, 132, - '@', - 134, - '^', - 136, 137, - '`', - 139, 140, - KEY_FR_U_GRAVE -}; - -//fallback for special letter non displayable in the game (i.e.: 'é','à',etc.) -INT32 HU_FallBackFrSpecialLetter(INT32 key) -{ - switch(key){ - case KEY_FR_E_AIGUE: return 'e'; - case KEY_FR_E_GRAVE: return 'e'; - case KEY_FR_C_CEDILLE: return 'c'; - case KEY_FR_A_GRAVE: return 'a'; - case KEY_FR_U_GRAVE: return 'u'; - default: return key; - } -} - static char cechotext[1024]; static tic_t cechotimer = 0; static tic_t cechoduration = 5*TICRATE; @@ -407,9 +260,6 @@ void HU_Init(void) COM_AddCommand("csay", Command_CSay_f); RegisterNetXCmd(XD_SAY, Got_Saycmd); - // set shift translation table - shiftxform = english_shiftxform; - if (dedicated || rendermode == render_none) return; @@ -435,11 +285,6 @@ void HU_Start(void) headsupactive = true; } -void HU_Shiftform(void) -{ - shiftxform = (cv_keyboardlayout.value == 3) ? french_shiftxform : english_shiftxform; -} - //====================================================================== // EXECUTION //====================================================================== diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 8ba4bce19..16b4bf0fc 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -42,15 +42,6 @@ #define CRED_FONTEND 'Z' // the last font character #define CRED_FONTSIZE (CRED_FONTEND - CRED_FONTSTART + 1) -extern char *shiftxform; // english translation shift table -extern char english_shiftxform[]; - -extern char french_shiftxform[]; -extern char french_altgrxform[]; - -//fallback for special letter non displayable in the game (i.e.: 'é','à',etc.) -INT32 HU_FallBackFrSpecialLetter(INT32 key); - //------------------------------------ // sorted player lines //------------------------------------ @@ -105,8 +96,6 @@ void HU_LoadGraphics(void); // reset heads up when consoleplayer respawns. void HU_Start(void); -void HU_Shiftform(void); - boolean HU_Responder(event_t *ev); void HU_Ticker(void); void HU_TickSongCredits(void); @@ -115,8 +104,6 @@ void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_clearChatChars(void); void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags); // Lat': Ping drawer for scoreboard. -//void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer); -//void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer); void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 hilicol); void HU_DrawEmeralds(INT32 x, INT32 y, INT32 pemeralds); const char *HU_SkinColorToConsoleColor(skincolors_t color); diff --git a/src/m_menu.c b/src/m_menu.c index 7b20b8f41..a6790ff78 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -496,32 +496,6 @@ static consvar_t cv_dummystaff = {"dummystaff", "0", CV_HIDEN|CV_CALL, dummystaf // all the menu definitions and onchanges reside in here now #include "m_menudefs.c" -static INT32 M_ShiftChar(INT32 ch) -{ - if (I_UseNativeKeyboard()) - return ch; - - if (cv_keyboardlayout.value == 3) - { - if (ch >= 32 && ch <= 141) - { - if (shiftdown) - ch = shiftxform[ch]; - else if (altdown & 0x2) - ch = french_altgrxform[ch]; - else - ch = HU_FallBackFrSpecialLetter(ch); - } - } - else - { - if (shiftdown && ch >= 32 && ch <= 127) - ch = shiftxform[ch]; - } - - return ch; -} - // // M_GetGametypeColor // @@ -1250,7 +1224,7 @@ boolean M_Responder(event_t *ev) // Handle menuitems which need a specific key handling if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER) { - ch = M_ShiftChar(ch); + ch = CON_ShiftChar(ch); routine(ch); return true; } @@ -1280,6 +1254,7 @@ boolean M_Responder(event_t *ev) void (*otherroutine)(event_t *sev) = currentMenu->menuitems[itemOn].itemaction; otherroutine(ev); //Alam: what a hack } + return true; } } diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 813b6bfa0..aa0c5c72d 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -108,7 +108,6 @@ static void KeyboardLayout_OnChange(void) { if (cv_keyboardlayout.value != 2) SDL_StopTextInput(); - HU_Shiftform(); } static CV_PossibleValue_t keyboardlayout_cons_t[] = {{1,"Default US"}, {2, "Native"}, {3, "AZERTY"}, {0, NULL}}; From bb62fbfc126a8f72870738222b236a95e663466d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 15 Apr 2026 23:45:26 +0200 Subject: [PATCH 277/589] add "USEJEMALLOC" make flag to link against "jemalloc" allocator on my linux system and usual benchmark setup this improves performance quite significantly (+~12fps) this relies on jemalloc to be installed as a separate library for now and is more a convenience thing --- src/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Makefile b/src/Makefile index c930f87ed..4ee7cf1a9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -94,6 +94,7 @@ # NOSDLMAIN=1 - ? # SDLMAIN=1 - ? # NOLTO=1 - Disable link time optimizations +# USEJEMALLOC=1 Enable building with jemalloc Allocator to replace GLibc malloc, might improve performance # # Library configuration flags: # Everything here is an override. @@ -279,6 +280,10 @@ opts+=-O1 -fsanitize=undefined -fno-omit-frame-pointer libs+=-fsanitize=undefined endif +ifdef USEJEMALLOC +libs+=-ljemalloc +endif + ifneq (,$(filter $(CC) $(CXX),clang clang++)) libs+=-fuse-ld=lld endif From b46e5cb577e47dc1c9cba02642defc7152f4b02d Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 4 Apr 2026 00:27:42 -0500 Subject: [PATCH 278/589] gl: Fix sky dome VBO leak --- src/hardware/hw_main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 6e41a7d3b..e38b1b3c8 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5284,7 +5284,6 @@ void HWR_ClearSkyDome(void) sky->loops = NULL; sky->data = NULL; - sky->vbo = 0; sky->rows = sky->columns = 0; sky->loopcount = 0; From a59928221bf78027ddcad472617dc923e2777898 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 16 Apr 2026 17:39:01 +0200 Subject: [PATCH 279/589] few more cleanups and super tiny optimizations k_hud --- src/hu_stuff.c | 3 +- src/k_hud.c | 114 ++++++++++++++++++++++++----------------------- src/p_user.c | 11 ++++- src/r_draw.cpp | 17 ++++--- src/r_patch.cpp | 3 +- src/r_things.cpp | 7 +-- 6 files changed, 86 insertions(+), 69 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 4f84fad89..145ce240f 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -979,7 +979,8 @@ void HU_Ticker(void) } } - if (cechotimer > 0) --cechotimer; + if (cechotimer > 0) + --cechotimer; // Animate the desynch dots if (hu_resynching diff --git a/src/k_hud.c b/src/k_hud.c index bed4c36be..ce60d23c8 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1362,10 +1362,12 @@ INT32 K_getMinimapTrans(void) return -1; if (timeinmap <= 113) + { minimaptrans = ((((INT32)timeinmap) - 105)*minimaptrans)/(113-105); - if (!minimaptrans) - return -1; + if (!minimaptrans) + return -1; + } return (10-minimaptrans)<spectator || !player->mo) continue; @@ -2434,7 +2437,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I static boolean K_BigLap(void) { - return (cv_biglaps.value && (cv_numlaps.value > 9) && (K_UseColorHud() ? big_lap_color : big_lap) && (!stplyr->exiting)); + return (cv_biglaps.value && (cv_numlaps.value > 9) && !stplyr->exiting && (K_UseColorHud() ? big_lap_color : big_lap)); } static void K_drawKartLaps(void) @@ -2643,7 +2646,7 @@ static void K_drawKartSpeedometer(void) return; // index 0 is the raw value, index 1 is the converted value - fixed_t convSpeed[2] = {0,0}; + fixed_t convSpeed[2] = {0, 0}; #ifdef ROTSPRITE fixed_t dial_divisor = DIALSPDDIV; #endif @@ -2712,34 +2715,27 @@ static void K_drawKartSpeedometer(void) V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, metric); } - else if (speedostyle == SPEEDO_EXTRA) // why bother if we dont? + else if (speedostyle == SPEEDO_EXTRA || speedostyle == SPEEDO_ACHII) // why bother if we dont? { - if (K_UseColorSpeedo(SPEEDO_EXTRA)) //Colourized hud + patch_t *speedopat; + + if (K_UseColorSpeedo(speedostyle)) //Colourized hud { + speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_smallstickerclr : skp_smallstickerachiclr); 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, speedopat, colormap); } else - V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallsticker); + { + speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_smallsticker : skp_smallstickerachi); + V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat); + } 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_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_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_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]); - } + + speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_speedpatches[cv_kartspeedometer.value] : skp_speedpatchesachi[cv_kartspeedometer.value]); + V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat); } #ifdef ROTSPRITE else if (speedostyle == SPEEDO_DIAL) // why bother if we dont? @@ -2769,29 +2765,32 @@ static void K_drawKartSpeedometer(void) // Draw the Speed counter. else if ((speedostyle == SPEEDO_PMETER) || (speedostyle == SPEEDO_PMETERSMOL)) { - fixed_t fuspeed = 0; INT32 spdpatch = 0; - static const INT32 speedIntervals[22] = {2, 5, 7, 10, 12, 15, 17, - 20, 22, 25, 27, 30, 32, - 35, 37, 40, 42, 45, 47, - 50, 52, 55}; + static const INT32 spdinterval[22] = { 2, 5, 7, 10, + 12, 15, 17, 20, + 22, 25, 27, 30, + 32, 35, 37, 40, + 42, 45, 47, 50, + 52, 55}; - fuspeed = FixedDiv(stplyr->speed, mapobjectscale)/FRACUNIT; + const fixed_t spd = FixedDiv(stplyr->speed, mapobjectscale) / FRACUNIT; - for (INT32 i = 0; i < 22; ++i) + if (spd > 54) { - if (fuspeed < speedIntervals[i]) + spdpatch = (leveltime & 4) ? 24 : 23; + } + else + { + for (INT32 i = 0; i < 22; ++i) { - spdpatch = i; - break; + if (spd < spdinterval[i]) + { + spdpatch = i; + break; + } } } - if (((fuspeed < 57 && fuspeed > 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && (leveltime & 4)) - spdpatch = 24; - else if (((fuspeed < 57 && fuspeed > 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && !(leveltime & 4)) - spdpatch = 23; - V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, (speedostyle == SPEEDO_PMETER) ? kp_kartzspeedo[spdpatch] : kp_kartzspeedo_smol[spdpatch]); } } @@ -2911,10 +2910,12 @@ static boolean K_GetScreenCoords(vector2_t *vec, player_t *player, mobj_t *targe x = (fixed_t)(viewangle - R_PointToAngle(targx, targy)); distfact = FINECOSINE((x>>ANGLETOFINESHIFT) & FINEMASK); - if (!distfact) distfact = 1; + if (!distfact) + distfact = 1; if (encoremode) x = -x; + if (x < (fixed_t)ANGLE_270 || x > (fixed_t)ANGLE_90) return false; @@ -2996,7 +2997,7 @@ static boolean K_GetScreenCoords(vector2_t *vec, player_t *player, mobj_t *targe if (stplyrnum > 0) y = y + yres; } - if (splitscreen >= 2) // 3P or 4P + else if (splitscreen >= 2) // 3P or 4P { x = x>>1; y = y>>1; @@ -3056,9 +3057,11 @@ static void K_drawNameTags(void) if (players[i].kartstuff[k_hyudorotimer]) // player is invisible continue; if (maxdistance) + { distance = R_PointToDist(players[i].mo->x, players[i].mo->y); - if (distance > maxdistance) - continue; + if (distance > maxdistance) + continue; + } if (!P_CheckSightFast(stplyr->mo, players[i].mo)) continue; @@ -3267,13 +3270,12 @@ static void K_drawDriftGauge(void) if (!splitscreen && !camera->chase) return; - if (forceshowhud) - goto skipcrap; // i will skip the drift early return and you cant stop me! - - if (!stplyr->kartstuff[k_drift]) - return; - -skipcrap: + // i will skip the drift early return and you cant stop me! + if (!forceshowhud) + { + if (!stplyr->kartstuff[k_drift]) + return; + } if (P_MobjWasRemoved(stplyr->mo)) return; @@ -3637,7 +3639,7 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) V_DrawCenteredSmallStringAtFixed(amxpos + (4*FRACUNIT), amypos - (3*FRACUNIT), V_ALLOWLOWERCASE|flags|V_SkinColorToHighlightcolor(mo->color), player_names[player - players]); } - const boolean minihead = K_useSmallMinimapHead(mo->player); + const boolean minihead = K_useSmallMinimapHead(player); // thx wanted reticle for having weird offsets very cool wntdamxpos = minihead ? amxpos + (1<viewz > mo->ceilingz - FixedMul(FRACUNIT, mo->scale)) player->viewz = mo->ceilingz - FixedMul(FRACUNIT, mo->scale); } + return; } @@ -2271,7 +2272,8 @@ static void P_MovePlayer(player_t *player) } //CONS_Printf("applied turn: %d\n", angle_diff); - if (add_delta) { + if (add_delta) + { player->mo->angle += angle_diff << TICCMD_REDUCE; player->mo->angle &= ~0xFFFF; // Try to keep the turning somewhat similar to how it was before? //CONS_Printf("leftover turn (%s): %5d or %4d%%\n", @@ -2393,15 +2395,18 @@ static void P_MovePlayer(player_t *player) { mobj_t *water = P_SpawnMobj(player->mo->x, player->mo->y, ((player->mo->eflags & MFE_VERTICALFLIP) ? player->mo->waterbottom - FixedMul(mobjinfo[MT_SPLISH].height, player->mo->scale) : player->mo->watertop), MT_SPLISH); + if (player->mo->eflags & MFE_GOOWATER) S_StartSound(water, sfx_ghit); else S_StartSound(water, sfx_wslap); + if (player->mo->eflags & MFE_VERTICALFLIP) { water->flags2 |= MF2_OBJECTFLIP; water->eflags |= MFE_VERTICALFLIP; } + water->destscale = player->mo->scale; P_SetScale(water, player->mo->scale); } @@ -3970,9 +3975,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { fixed_t panmax = (dist/5); const INT32 sparkval = K_GetKartDriftSparkValue(player); + pan = FixedDiv(FixedMul(min((fixed_t)player->kartstuff[k_driftcharge], sparkval), panmax), sparkval); + if (pan > panmax) pan = panmax; + if (player->kartstuff[k_drift] < 0) pan *= -1; } @@ -4749,6 +4757,7 @@ void P_PlayerThink(player_t *player) player->mo->flags2 |= MF2_SHADOW; else player->mo->flags2 &= ~MF2_SHADOW; + P_DeathThink(player); LUA_HookPlayer(player, HOOK(PlayerThink)); return; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index b8f3fc903..24073a4d4 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -532,9 +532,12 @@ typedef struct drawcolumndata_temp_s // e6y: resolution limitation is removed UINT8 *buf; - INT32 startx; - ColumnFlushType type; - INT32 commontop, commonbot; + INT32 startx; + + ColumnFlushType type; + + INT32 commontop, commonbot; + UINT8 *transmap; // SoM 7-28-04: Fix the fuzz problem. UINT8 *translation; @@ -562,8 +565,8 @@ FUNCNORETURN static ATTRNORETURN void R_QuadFlushError(void) } static void (*R_FlushWholeColumns)(void) = R_FlushWholeError; -static void (*R_FlushHTColumns)(void) = R_FlushHTError; -static void (*R_FlushQuadColumn)(void) = R_QuadFlushError; +static void (*R_FlushHTColumns)(void) = R_FlushHTError; +static void (*R_FlushQuadColumn)(void) = R_QuadFlushError; static void R_FlushColumns(void) { @@ -595,8 +598,8 @@ void R_ResetColumnBuffer(void) temp_dc.type = FLUSH_NONE; R_FlushWholeColumns = R_FlushWholeError; - R_FlushHTColumns = R_FlushHTError; - R_FlushQuadColumn = R_QuadFlushError; + R_FlushHTColumns = R_FlushHTError; + R_FlushQuadColumn = R_QuadFlushError; } /** \brief The R_InitViewBuffer function diff --git a/src/r_patch.cpp b/src/r_patch.cpp index bca733c8b..f578a8f32 100644 --- a/src/r_patch.cpp +++ b/src/r_patch.cpp @@ -161,7 +161,7 @@ static void R_ParseSpriteInfo(boolean spr2) if (i == NUMSPRITES) I_Error("Error parsing SPRTINFO lump: Unknown sprite name \"%s\"", newSpriteName); - if (!memcmp(newSpriteName,sprnames[i], 4)) + if (!memcmp(newSpriteName, sprnames[i], 4)) { sprnum = static_cast(i); break; @@ -443,6 +443,7 @@ void *Patch_AllocateHardwarePatch(patch_t *patch) GLPatch_t *glPatch = static_cast(Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &patch->hardware)); glPatch->mipmap = static_cast(Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, &glPatch->mipmap)); } + return (void *)(patch->hardware); } diff --git a/src/r_things.cpp b/src/r_things.cpp index 2f7e1a992..787c35250 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -166,11 +166,13 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has rotations and a rot = 0 lump\n", spritename, cn); sprtemp[frame].rotate = SRF_SINGLE; + for (r = 0; r < 8; r++) { sprtemp[frame].lumppat[r] = lumppat; sprtemp[frame].lumpid[r] = lumpid; } + sprtemp[frame].flip = flipped ? UINT8_MAX : 0; // 11111111 in binary return; } @@ -267,8 +269,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 if (spritedef->numframes) // (then spriteframes is not null) { // copy the already defined sprite frames - memcpy(sprtemp, spritedef->spriteframes, - spritedef->numframes * sizeof (spriteframe_t)); + memcpy(sprtemp, spritedef->spriteframes, spritedef->numframes * sizeof (spriteframe_t)); maxframe = spritedef->numframes - 1; } @@ -1147,7 +1148,7 @@ fixed_t R_GetSpriteDirectionalLighting(angle_t angle) fixed_t extralight = 0; light = FixedMul(FINECOSINE(angle >> ANGLETOFINESHIFT), FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT)) - + FixedMul(FINESINE(angle >> ANGLETOFINESHIFT), FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); + + FixedMul(FINESINE(angle >> ANGLETOFINESHIFT), FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); light = (light + FRACUNIT) / 2; light = FixedMul(light, FRACUNIT - FSIN(abs(AngleDeltaSigned(angle, maplighting.angle)) / 2)); From a73f3a073c681b77cd61779c3a271ac736d1220b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Apr 2026 17:39:50 +0200 Subject: [PATCH 280/589] hw_main: dont need to do sprite billboarding stuff with shearing enabled within HWR_SplitSprite --- src/hardware/hw_main.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index e38b1b3c8..d2fc90472 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3864,7 +3864,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) wallVerts[1].y = endbot; // The x and y only need to be adjusted in the case that it's not a papersprite - if (cv_glspritebillboarding.value && !papersprite) + if (cv_glspritebillboarding.value && !cv_glshearing.value && !papersprite) { // Get the x and z of the vertices so billboarding draws correctly realheight = realbot - realtop; @@ -4383,9 +4383,7 @@ static int CompareDrawNodePlanes(const void *p1, const void *p2) static void HWR_RenderDrawNodes(void) { size_t i = 0, run_start = 0; - static std::vector sortindex; - - sortindex.reserve(DRAWNODES_INIT_SIZE); + static std::vector sortindex(DRAWNODES_INIT_SIZE); // Array for storing the rendering order. // A list of indices into the drawnodes array. @@ -5712,7 +5710,7 @@ static void HWR_RenderFrame(boolean skybox, boolean drawsky) viewwindowy, (viewwindowx + viewwidth), (viewwindowy + viewheight), - ZCLIP_PLANE, clipping_distances[renderdist - 1]); + ZCLIP_PLANE, clipping_distances[renderdist - 1]); current_bsp_culling_distance = bsp_culling_distances[renderdist- 1]; } @@ -6091,7 +6089,8 @@ static void HWR_DoPostProcessor(void) } } - if (cv_glscreentextures.value != 2) // screen textures are needed for the rest of the effects + // screen textures are needed for the rest of the effects + if (cv_glscreentextures.value != 2) return; // Not supported in splitscreen - someone want to add support? From 4f9ddffe2acb468f81463aecf32b5b0f16098b14 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Apr 2026 17:40:41 +0200 Subject: [PATCH 281/589] d_cliserv: check for splitscreen nodes first in clientcmd handler so we dont always have to check a bunch of things that most of the time wont apply anyways --- src/d_clisrv.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5da2b4ee2..192a2cceb 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5617,7 +5617,7 @@ static void PT_ClientCmd(INT32 netconsole, SINT8 node) realstart = ExpandTics(netbuffer->u.clientpak.client_tic, nettics[node]); realend = ExpandTics(netbuffer->u.clientpak.resendfrom, nettics[node]); - if (netbuffer->packettype == PT_CLIENTMIS || netbuffer->packettype == PT_CLIENT2MIS + if ( netbuffer->packettype == PT_CLIENTMIS || netbuffer->packettype == PT_CLIENT2MIS || netbuffer->packettype == PT_CLIENT3MIS || netbuffer->packettype == PT_CLIENT4MIS || netbuffer->packettype == PT_NODEKEEPALIVEMIS || supposedtics[node] < realend) @@ -5660,10 +5660,10 @@ static void PT_ClientCmd(INT32 netconsole, SINT8 node) return; // Splitscreen cmd - if (((netbuffer->packettype == PT_CLIENT2CMD || netbuffer->packettype == PT_CLIENT2MIS) + if ((nodetoplayer2[node] >= 0) && + ((netbuffer->packettype == PT_CLIENT2CMD || netbuffer->packettype == PT_CLIENT2MIS) || (netbuffer->packettype == PT_CLIENT3CMD || netbuffer->packettype == PT_CLIENT3MIS) - || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)) - && (nodetoplayer2[node] >= 0)) + || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))) { G_MoveTiccmd(&playercmds[(UINT8)nodetoplayer2[node]], &netbuffer->u.client2pak.cmd2, 1); @@ -5671,9 +5671,9 @@ static void PT_ClientCmd(INT32 netconsole, SINT8 node) return; } - if (((netbuffer->packettype == PT_CLIENT3CMD || netbuffer->packettype == PT_CLIENT3MIS) - || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)) - && (nodetoplayer3[node] >= 0)) + if ((nodetoplayer3[node] >= 0) && + ((netbuffer->packettype == PT_CLIENT3CMD || netbuffer->packettype == PT_CLIENT3MIS) + || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))) { G_MoveTiccmd(&playercmds[(UINT8)nodetoplayer3[node]], &netbuffer->u.client3pak.cmd3, 1); @@ -5681,8 +5681,8 @@ static void PT_ClientCmd(INT32 netconsole, SINT8 node) return; } - if ((netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS) - && (nodetoplayer4[node] >= 0)) + if ((nodetoplayer4[node] >= 0) && + (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)) { G_MoveTiccmd(&playercmds[(UINT8)nodetoplayer4[node]], &netbuffer->u.client4pak.cmd4, 1); From eed5943b0b66e97a5f0a67dcbcf5480ff6e6f3a5 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Apr 2026 17:42:48 +0200 Subject: [PATCH 282/589] optimize K_CheckOffroadCollide a little bit no need to always check both the mobjs floor and ceiling z coordinates, those are surprisingly complicated checks on slopes --- src/k_kart.c | 87 +++++++++++++++++++++++++++++------------------ src/m_textinput.c | 2 +- src/p_user.c | 2 +- 3 files changed, 56 insertions(+), 35 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index ec312cc3b..f4577eb03 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1600,8 +1600,10 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) sector_t *s2; // FOF sector shortcut ffloor_t *rover; // FOF - fixed_t flr; - fixed_t cel; // floor & ceiling for height checks to make sure we're touching the offroad sector. + fixed_t flr = 0, cel = 0; // floor & ceiling for height checks to make sure we're touching the offroad sector. + + boolean checkfloor = false; + boolean checkceiling = false; I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); @@ -1609,48 +1611,64 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (!node->m_sector) - break; // shouldn't happen. + break; // shouldn't happen. s = node->m_sector; // 1: Check for the main sector, make sure we're on the floor of that sector and see if we can apply offroad. // Make arbitrary Z checks because we want to check for 1 sector in particular, we don't want to affect the player if the offroad sector is way below them and they're lineriding a normal sector above. - flr = P_MobjFloorZ(mo, s, s, mo->x, mo->y, NULL, false, true); - cel = P_MobjCeilingZ(mo, s, s, mo->x, mo->y, NULL, true, true); // get Z coords of both floors and ceilings for this sector (this accounts for slopes properly.) + checkfloor = (s->flags & SF_FLIPSPECIAL_FLOOR); + checkceiling = (mo->eflags & MFE_VERTICALFLIP && (s->flags & SF_FLIPSPECIAL_CEILING)); + + if (checkfloor) + flr = P_MobjFloorZ(mo, s, s, mo->x, mo->y, NULL, false, true); + if (checkceiling) + cel = P_MobjCeilingZ(mo, s, s, mo->x, mo->y, NULL, true, true); // get Z coords of both floors and ceilings for this sector (this accounts for slopes properly.) // NOTE: we don't use P_GetZAt with our x/y directly because the mobj won't have the same height because of its hitbox on the slope. Complex garbage but tldr it doesn't work. - if ( ((s->flags & SF_FLIPSPECIAL_FLOOR) && mo->z == flr) // floor check - || ((mo->eflags & MFE_VERTICALFLIP && (s->flags & SF_FLIPSPECIAL_CEILING) && (mo->z + mo->height) == cel)) ) // ceiling check. - - for (i = 2; i < 5; i++) // check for sector special - - if (GETSECSPECIAL(s->special, 1) == i) - return i-1; // return offroad type + if ( (checkfloor && mo->z == flr) // floor check + || ((checkceiling && (mo->z + mo->height) == cel))) // ceiling check. + { + const INT32 special = GETSECSPECIAL(s->special, 1); + for (i = 2; i < 5; i++) // check for sector special + { + if (special == i) + return i-1; // return offroad type + } + } // 2: If we're here, we haven't found anything. So let's try looking for FOFs in the sectors using the same logic. for (rover = s->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS)) // This FOF doesn't exist anymore. + if (!(rover->flags & FF_EXISTS)) // This FOF doesn't exist anymore. continue; - s2 = §ors[rover->secnum]; // makes things easier for us + s2 = §ors[rover->secnum]; // makes things easier for us - flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL); - cel = P_GetFOFTopZ(mo, s, rover, mo->x, mo->y, NULL); // Z coords for fof top/bottom. + checkfloor = (s2->flags & SF_FLIPSPECIAL_FLOOR); + checkceiling = (s2->flags & SF_FLIPSPECIAL_CEILING); + + if (checkfloor) + flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL); + if (checkceiling) + cel = P_GetFOFTopZ(mo, s, rover, mo->x, mo->y, NULL); // Z coords for fof top/bottom. // we will do essentially the same checks as above instead of bothering with top/bottom height of the FOF. // Reminder that an FOF's floor is its bottom, silly! - if ( ((s2->flags & SF_FLIPSPECIAL_FLOOR) && mo->z == cel) // "floor" check - || ((s2->flags & SF_FLIPSPECIAL_CEILING) && (mo->z + mo->height) == flr) ) // "ceiling" check. - - for (i = 2; i < 5; i++) // check for sector special - - if (GETSECSPECIAL(s2->special, 1) == i) - return i-1; // return offroad type - + if ( (checkfloor && mo->z == cel) // "floor" check + || (checkceiling && (mo->z + mo->height) == flr)) // "ceiling" check. + { + const INT32 special = GETSECSPECIAL(s2->special, 1); + for (i = 2; i < 5; i++) // check for sector special + { + if (special == i) + return i-1; // return offroad type + } + } } } - return 0; // couldn't find any offroad + + return 0; // couldn't find any offroad } /** \brief Updates the Player's offroad value once per frame @@ -2317,10 +2335,13 @@ fixed_t K_3dKartMovement(player_t *player, boolean onground, fixed_t forwardmove finalspeed *= forwardmove/25; finalspeed /= 2; - if (forwardmove < 0 && finalspeed > mapobjectscale*2) - return finalspeed/2; - else if (forwardmove < 0) + if (forwardmove < 0) + { + if (finalspeed > mapobjectscale*2) + return finalspeed/2; + return -mapobjectscale/2; + } if (finalspeed < 0) finalspeed = 0; @@ -3693,7 +3714,7 @@ void K_DriftDustHandling(mobj_t *spawner) { angle_t anglediff; - if (!P_IsObjectOnGround(spawner) || leveltime % 2 != 0) + if (leveltime % 2 != 0 || !P_IsObjectOnGround(spawner)) return; if (spawner->player) @@ -4076,7 +4097,7 @@ static void K_DoThunderShield(player_t *player) mo->scale = player->mo->scale*3 + (player->mo->scale/2); // spawn horizontal bolts; - for (i=0; i<7; i++) + for (i = 0; i < 7; i++) { mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_THOK); mo->angle = P_RandomRange(0, 359)*ANG1; @@ -4087,7 +4108,7 @@ static void K_DoThunderShield(player_t *player) // spawn the radius thing: an = ANGLE_22h; - for (i=0; i<15; i++) + for (i = 0; i < 15; i++) { sx = player->mo->x + FixedMul((player->mo->scale*THUNDERRADIUS), FINECOSINE((an*i)>>ANGLETOFINESHIFT)); sy = player->mo->y + FixedMul((player->mo->scale*THUNDERRADIUS), FINESINE((an*i)>>ANGLETOFINESHIFT)); @@ -4179,12 +4200,12 @@ static void K_DoHyudoroSteal(player_t *player) void K_DoSneaker(player_t *player, INT32 type) { - const fixed_t intendedboost = K_GetSneakerBoostSpeed(); - if (!player->kartstuff[k_floorboost] || player->kartstuff[k_floorboost] == 3) { S_StartSound(player->mo, sfx_cdfm01); K_SpawnDashDustRelease(player); + + const fixed_t intendedboost = K_GetSneakerBoostSpeed(); if (intendedboost > player->kartstuff[k_speedboost]) player->kartstuff[k_destboostcam] = FixedMul(FRACUNIT, FixedDiv((intendedboost - player->kartstuff[k_speedboost]), intendedboost)); } diff --git a/src/m_textinput.c b/src/m_textinput.c index a7c048e66..0d68b2b5d 100644 --- a/src/m_textinput.c +++ b/src/m_textinput.c @@ -256,7 +256,7 @@ static boolean M_TextInputHandleBase(textinput_t *input, INT32 key, boolean emot return true; } - if (ctrldown && (cv_keyboardlayout.value!=3 || !altdown)) + if (ctrldown && (cv_keyboardlayout.value != 3 || !altdown)) { if (key == 'x' || key == 'X') { diff --git a/src/p_user.c b/src/p_user.c index a10da4fb3..9eddcc36d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -775,7 +775,7 @@ boolean P_IsObjectInGoop(mobj_t *mo) // boolean P_IsObjectOnGround(mobj_t *mo) { - if (UNLIKELY(P_IsObjectInGoop(mo))) + if (P_IsObjectInGoop(mo)) { // but I don't want you to ever 'stand' while submerged in goo. // You're in constant vertical momentum, even if you get stuck on something. From 64bed715097b172dbd1b0df9ebb2f45b15effb79 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Apr 2026 18:54:10 +0200 Subject: [PATCH 283/589] add toggle to allow controllers to control the game while window is unfocused can be toggled with "gamepadunfocused" or in the focus options --- src/d_netcmd.c | 1 + src/dedicated/i_system.c | 4 ++++ src/g_input.c | 1 + src/g_input.h | 1 + src/i_system.h | 2 ++ src/m_menudefs.c | 45 ++++++++++++++++++++-------------------- src/sdl/i_system.cpp | 5 +++++ 7 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 828ad136a..76495a09e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1010,6 +1010,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_gamepadled[i]); } + CV_RegisterVar(&cv_gamepadifunfocused); CV_RegisterVar(&cv_gamepadledifunfocused); CV_RegisterVar(&cv_rumbleifunfocused); diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 014533af8..9fe312eb7 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -735,6 +735,10 @@ const char *I_GetJoyName(INT32 joyindex) return NULL; } +void I_SetJoystickFocus(void) +{ +} + boolean I_GamepadHasLED(INT32 playernum) { (void)playernum; diff --git a/src/g_input.c b/src/g_input.c index 091027ada..c72ed6308 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -81,6 +81,7 @@ consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = { {"gamepadled4", "Skincolor", CV_SAVE|CV_CALL|CV_NOINIT, gamepadled_cons_t, led_off_handle4, 0, NULL, NULL, 0, 0, NULL} }; +consvar_t cv_gamepadifunfocused = {"gamepadunfocused", "Off", CV_SAVE|CV_CALL, CV_OnOff, I_SetJoystickFocus, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gamepadledifunfocused = {"gamepadledunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_rumbleifunfocused = {"rumbleifunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/g_input.h b/src/g_input.h index 154f0805d..1cf4b2956 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -116,6 +116,7 @@ extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_gamepadifunfocused; extern consvar_t cv_gamepadledifunfocused; extern consvar_t cv_rumbleifunfocused; diff --git a/src/i_system.h b/src/i_system.h index 88bb9c985..9457e9c6d 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -148,6 +148,8 @@ extern INT32 numcontrollers; */ const char *I_GetJoyName(INT32 joyindex); +void I_SetJoystickFocus(void); + boolean I_GamepadHasLED(INT32 playernum); boolean I_GamepadHasRumble(INT32 playernum); diff --git a/src/m_menudefs.c b/src/m_menudefs.c index af6deacb8..9c1da4e29 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1185,20 +1185,20 @@ static menuitem_t OP_FocusOptionsMenu[] = { {IT_HEADER, NULL, "Game Focus Options", NULL, 0}, - {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 30}, - {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 40}, + {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 10}, + {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 20}, - {IT_STRING|IT_CVAR, NULL, "Pause Game While Unfocused", &cv_pauseifunfocused, 60}, + {IT_STRING|IT_CVAR, NULL, "Pause Game While Unfocused", &cv_pauseifunfocused, 40}, - {IT_STRING|IT_CVAR, NULL, "Background FPS Cap", &cv_fpscapbg, 80}, + {IT_STRING|IT_CVAR, NULL, "Background FPS Cap", &cv_fpscapbg, 60}, - {IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 100}, + {IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 80}, - {IT_STRING|IT_CVAR, NULL, "Visible Mouse", &cv_mousevisible, 120}, - - {IT_STRING|IT_CVAR, NULL, "Gamepad LED Color While Unfocused ", &cv_gamepadledifunfocused, 140}, - {IT_STRING|IT_CVAR, NULL, "Gamepad Rumble While Unfocused", &cv_rumbleifunfocused, 150}, + {IT_STRING|IT_CVAR, NULL, "Visible Mouse", &cv_mousevisible, 100}, + {IT_STRING|IT_CVAR, NULL, "Gamepad Inputs While Unfocused", &cv_gamepadifunfocused, 120}, + {IT_STRING|IT_CVAR, NULL, "Gamepad LED Color While Unfocused ", &cv_gamepadledifunfocused, 130}, + {IT_STRING|IT_CVAR, NULL, "Gamepad Rumble While Unfocused", &cv_rumbleifunfocused, 140}, }; static const char* OP_FocusOptionsTooltips[] = @@ -1210,6 +1210,7 @@ static const char* OP_FocusOptionsTooltips[] = "Set manual framerate cap while the game is unfocused.", "Should the FOCUS LOST window appear\n while the game is unfocused?", "Displays the mouse cursor while the game is in focus.", + "Should gamepad still control the game when unfocused?", "Should gamepad LED indicator change color when unfocused?", "Should gamepad rumble apply when unfocused?", }; @@ -1304,29 +1305,29 @@ static menuitem_t OP_DiscordOptionsMenu[] = static menuitem_t OP_HUDOptionsMenu[] = { - {IT_STRING | IT_CVAR, NULL, "Show HUD (F3)", &cv_showhud, 10}, + {IT_STRING | IT_CVAR, NULL, "Show HUD (F3)", &cv_showhud, 10}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "HUD Visibility", &cv_translucenthud, 20}, + NULL, "HUD Visibility", &cv_translucenthud, 20}, - {IT_STRING | IT_SUBMENU, NULL, "Online HUD options...", &OP_ChatOptionsDef, 35}, - {IT_STRING | IT_CVAR, NULL, "Background Glass", &cons_backcolor, 45}, + {IT_STRING | IT_SUBMENU, NULL, "Online HUD options...", &OP_ChatOptionsDef, 35}, + {IT_STRING | IT_CVAR, NULL, "Background Glass", &cons_backcolor, 45}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Minimap Visibility", &cv_kartminimap, 60}, - {IT_STRING | IT_CVAR, NULL, "Speedometer Display", &cv_kartspeedometer, 70}, - {IT_STRING | IT_CVAR, NULL, "Show \"CHECK\"", &cv_kartcheck, 80}, + NULL, "Minimap Visibility", &cv_kartminimap, 60}, + {IT_STRING | IT_CVAR, NULL, "Speedometer Display", &cv_kartspeedometer, 70}, + {IT_STRING | IT_CVAR, NULL, "Show \"CHECK\"", &cv_kartcheck, 80}, - {IT_STRING | IT_CVAR, NULL, "Menu Highlights", &cons_menuhighlight, 95}, + {IT_STRING | IT_CVAR, NULL, "Menu Highlights", &cons_menuhighlight, 95}, // highlight info - (GOOD HIGHLIGHT, WARNING HIGHLIGHT) - 110 (see M_DrawHUDOptions) - {IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 120}, - {IT_STRING | IT_CVAR, NULL, "Show Console Prints in Menu",&cons_consoleprintinmenu, 130}, + {IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 120}, + {IT_STRING | IT_CVAR, NULL, "Show Console Prints in Menu",&cons_consoleprintinmenu, 130}, - {IT_STRING | IT_CVAR, NULL, "Show Track Addon Name", &cv_showtrackaddon, 145}, + {IT_STRING | IT_CVAR, NULL, "Show Track Addon Name", &cv_showtrackaddon, 145}, - {IT_STRING | IT_CVAR, NULL, "Show All Maps", &cv_showallmaps, 155}, + {IT_STRING | IT_CVAR, NULL, "Show All Maps", &cv_showallmaps, 155}, - {IT_STRING | IT_CVAR, NULL, "2D character select", &cv_skinselectmenu, 165}, + {IT_STRING | IT_CVAR, NULL, "2D character select", &cv_skinselectmenu, 165}, }; static menuitem_t OP_CamOptionsMenu[] = diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index ae11829c6..396c59b5b 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -961,6 +961,11 @@ static int joy_open(int playerIndex, int joyIndex) return SDL_CONTROLLER_AXIS_MAX; } +void I_SetJoystickFocus(void) +{ + SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, cv_gamepadifunfocused.value ? "1" : "0"); +} + // // I_InitJoystick // From ff3b73c49e2e1e18804f43a1d95f94491595291e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Apr 2026 20:53:16 +0200 Subject: [PATCH 284/589] fix offroad oopsie causing desynch ye def not confusing at all to suddenly switch the meaning of floor and ceiling --- src/k_kart.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f4577eb03..53bcae3ef 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1648,9 +1648,10 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) checkfloor = (s2->flags & SF_FLIPSPECIAL_FLOOR); checkceiling = (s2->flags & SF_FLIPSPECIAL_CEILING); - if (checkfloor) - flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL); + // def not confusing at all..... if (checkceiling) + flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL); + if (checkfloor) cel = P_GetFOFTopZ(mo, s, rover, mo->x, mo->y, NULL); // Z coords for fof top/bottom. // we will do essentially the same checks as above instead of bothering with top/bottom height of the FOF. From 31ccf9c34ae23468bba83d6dcb7544b1f084b6ee Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 18 Apr 2026 18:45:35 +0200 Subject: [PATCH 285/589] optimize K_CheckOffroadCollide further also makes this alot more readable like this most of the time we dont have to ever check the players floorz nor ceilingz at all since we check if the sector the players mobj is in is even offroad at all nothing super big but i did see an improvement of around 1fps in my usual benchmark --- src/k_kart.c | 71 +++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 53bcae3ef..b87894dae 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1600,10 +1600,8 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) sector_t *s2; // FOF sector shortcut ffloor_t *rover; // FOF - fixed_t flr = 0, cel = 0; // floor & ceiling for height checks to make sure we're touching the offroad sector. - - boolean checkfloor = false; - boolean checkceiling = false; + fixed_t flr, cel; // floor & ceiling for height checks to make sure we're touching the offroad sector. + INT32 special; I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); @@ -1614,25 +1612,28 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) break; // shouldn't happen. s = node->m_sector; + // 1: Check for the main sector, make sure we're on the floor of that sector and see if we can apply offroad. // Make arbitrary Z checks because we want to check for 1 sector in particular, we don't want to affect the player if the offroad sector is way below them and they're lineriding a normal sector above. - checkfloor = (s->flags & SF_FLIPSPECIAL_FLOOR); - checkceiling = (mo->eflags & MFE_VERTICALFLIP && (s->flags & SF_FLIPSPECIAL_CEILING)); - - if (checkfloor) - flr = P_MobjFloorZ(mo, s, s, mo->x, mo->y, NULL, false, true); - if (checkceiling) - cel = P_MobjCeilingZ(mo, s, s, mo->x, mo->y, NULL, true, true); // get Z coords of both floors and ceilings for this sector (this accounts for slopes properly.) - // NOTE: we don't use P_GetZAt with our x/y directly because the mobj won't have the same height because of its hitbox on the slope. Complex garbage but tldr it doesn't work. - - if ( (checkfloor && mo->z == flr) // floor check - || ((checkceiling && (mo->z + mo->height) == cel))) // ceiling check. + special = GETSECSPECIAL(s->special, 1); + for (i = 2; i < 5; i++) // check for sector special { - const INT32 special = GETSECSPECIAL(s->special, 1); - for (i = 2; i < 5; i++) // check for sector special + if (special != i) + continue; + + if (s->flags & SF_FLIPSPECIAL_FLOOR) { - if (special == i) + flr = P_MobjFloorZ(mo, s, s, mo->x, mo->y, NULL, false, true); + if (mo->z == flr) // floor check + return i-1; // return offroad type + } + + if (mo->eflags & MFE_VERTICALFLIP && (s->flags & SF_FLIPSPECIAL_CEILING)) + { + cel = P_MobjCeilingZ(mo, s, s, mo->x, mo->y, NULL, true, true); + // NOTE: we don't use P_GetZAt with our x/y directly because the mobj won't have the same height because of its hitbox on the slope. Complex garbage but tldr it doesn't work. + if ((mo->z + mo->height) == cel) // ceiling check return i-1; // return offroad type } } @@ -1645,24 +1646,26 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) s2 = §ors[rover->secnum]; // makes things easier for us - checkfloor = (s2->flags & SF_FLIPSPECIAL_FLOOR); - checkceiling = (s2->flags & SF_FLIPSPECIAL_CEILING); - - // def not confusing at all..... - if (checkceiling) - flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL); - if (checkfloor) - cel = P_GetFOFTopZ(mo, s, rover, mo->x, mo->y, NULL); // Z coords for fof top/bottom. - - // we will do essentially the same checks as above instead of bothering with top/bottom height of the FOF. - // Reminder that an FOF's floor is its bottom, silly! - if ( (checkfloor && mo->z == cel) // "floor" check - || (checkceiling && (mo->z + mo->height) == flr)) // "ceiling" check. + special = GETSECSPECIAL(s2->special, 1); + for (i = 2; i < 5; i++) // check for sector special { - const INT32 special = GETSECSPECIAL(s2->special, 1); - for (i = 2; i < 5; i++) // check for sector special + if (special != i) + continue; + + // we will do essentially the same checks as above instead of bothering with top/bottom height of the FOF. + // Reminder that an FOF's floor is its bottom, silly! + + if (s2->flags & SF_FLIPSPECIAL_FLOOR) { - if (special == i) + cel = P_GetFOFTopZ(mo, s, rover, mo->x, mo->y, NULL); // Z coords for fof top/bottom. + if (mo->z == cel) // "floor" check + return i-1; // return offroad type + } + + if (s2->flags & SF_FLIPSPECIAL_CEILING) + { + flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL); + if ((mo->z + mo->height) == flr) // "ceiling" check return i-1; // return offroad type } } From 7931a82b233e097c762224ab261181011ba07cad Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Apr 2026 20:48:56 +0200 Subject: [PATCH 286/589] attempt to fix a plethora of buffer overflows when trying to connect to a server that does not exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ex: if you typo´d the serveraddress this really aint pretty but idk how to make things not turn into limbo hell otherwise --- src/d_clisrv.c | 14 ++++++++++++++ src/i_tcp.c | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 192a2cceb..b62f97124 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3390,6 +3390,20 @@ static void Command_connect(void) } else CONS_Alert(CONS_ERROR, M_GetText("There is no network driver\n")); + + // invalid address + if (servernode == -1) + { + D_QuitNetGame(); // this will also call D_CloseConnection for us + CL_Reset(); + servernode = 0; // not sure if this is cool, but if this is -1 then bad things happen in alot of networking code + multiplayer = false; + netgame = false; + + D_StartTitle(); + M_StartMessage(M_GetText("Failed to connect to server\nMake sure you put in a valid Address!\n"), NULL, MM_NOTHING); + return; + } } CV_Set(&cv_lastserver, I_GetNodeAddress(servernode)); diff --git a/src/i_tcp.c b/src/i_tcp.c index 9723d5b2d..f7f4a3210 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -392,6 +392,9 @@ static const char *SOCK_GetNodeAddress(INT32 node) if (node == 0) return "self"; + if (node < 0 || node > MAXNETNODES) + return NULL; + if (!nodeconnected[node]) return NULL; From c343c524772c8a63ce1f9523006ca71a11de4439 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Apr 2026 10:07:35 +0200 Subject: [PATCH 287/589] remove "extra3" hud stuff decided to finally make smol stickers for the beta hud this was never a really great solution since it made things look pretty bad at certain resolutions/scales still keep the loading code for convenience but honestly not needed aswell at this point --- src/d_main.c | 17 ------------- src/d_main.h | 2 -- src/k_hud.c | 69 ++++++---------------------------------------------- src/k_kart.c | 3 ++- 4 files changed, 10 insertions(+), 81 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 9443c0a47..eb503b39f 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1416,8 +1416,6 @@ static inline void D_MakeTitleString(char *s) // extra graphic patches for saturn specific thingies boolean xtra_speedo = false; // extra speedometer check boolean xtra_speedo_clr = false; // extra speedometer colour check -boolean xtra_speedo3 = false; // 80x 11 extra speedometer check -boolean xtra_speedo_clr3 = false; // 80x 11 extra speedometer colour check boolean achi_speedo = false; // achiiro speedometer check boolean achi_speedo_clr = false; // extra speedometer colour check boolean dial_speedo = false; // dial speedometer check @@ -1447,7 +1445,6 @@ static void D_CheckSaturnExtraFiles(void) CV_PossibleValue_t minimapdot_cons_temp[NUMMINIMAPDOTSTUFF] = {{0, "Off"}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}; unsigned last_speedo_i = 0; - unsigned last_driftgauge_i = 3; unsigned last_inputdisplay_i = 2; unsigned last_minimapdot_i = 0; #define PUSHCONS(cons, i, id, name) { ++i; cons[i].value = id; cons[i].strvalue = name; } @@ -1606,20 +1603,6 @@ static void D_CheckSaturnExtraFiles(void) if (found_extra3_kart) { mainwads++; - - // 80x11 speedometer crap - if (W_LumpExists("SP_SM3TC")) - { - xtra_speedo3 = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 7, "Extra"); - PUSHCONS(driftgaugestyle_cons_temp, last_driftgauge_i, 5, "Extra"); - } - - // 80x11 speedometer crap but colour - if (W_LumpExists("SC_SM3TC")) - { - xtra_speedo_clr3 = true; - } } #undef PUSHCONS diff --git a/src/d_main.h b/src/d_main.h index 8f1475706..8bbf79df0 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -38,8 +38,6 @@ extern boolean found_extra3_kart; // for use in k_kart.c extern boolean xtra_speedo; // extra speedometer check extern boolean xtra_speedo_clr; // extra speedometer colour check -extern boolean xtra_speedo3; // 80x11 extra speedometer check -extern boolean xtra_speedo_clr3; // 80x11 extra speedometer colour check extern boolean achi_speedo; // achiiro speedometer check extern boolean achi_speedo_clr; // extra speedometer colour check extern boolean dial_speedo; // dial speedometer check diff --git a/src/k_hud.c b/src/k_hud.c index ce60d23c8..4e2f6477f 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -274,7 +274,6 @@ void K_RegisterKartHudStuff(void) // Smol speedo static patch_t *skp_smallsticker = NULL; -static patch_t *skp_smallsticker3 = NULL; static patch_t *skp_speedpatches[5] = {NULL}; @@ -312,7 +311,6 @@ static patch_t *kp_bumperstickerwideclr = NULL; static patch_t *kp_karmastickerclr = NULL; static patch_t *kp_timeoutstickerclr = NULL; static patch_t *skp_smallstickerclr = NULL; -static patch_t *skp_smallstickerclr3 = NULL; static patch_t *kp_itemmulstickerclr[2] = {NULL}; static patch_t *kp_itembgclr[4] = {NULL}; @@ -478,11 +476,6 @@ static void K_LoadSaturnHUDGraphics(void) skp_smallstickerclr = (patch_t *)W_CachePatchName("SC_SMSTC", PU_HUDGFX); } - if (xtra_speedo_clr3) - { - skp_smallstickerclr3 = (patch_t *)W_CachePatchName("SC_SM3TC", PU_HUDGFX); - } - if (achi_speedo_clr) { skp_smallstickerachiclr = (patch_t *)W_CachePatchName("SC_AMSTC", PU_HUDGFX); @@ -537,14 +530,6 @@ static void K_LoadSaturnHUDGraphics(void) kp_itemmulstickerclr[0] = (patch_t *)W_CachePatchName("K_ITMULC", PU_HUDGFX); } } - - if (found_extra3_kart) - { - if (xtra_speedo3) // 80x11 patch scaled to size - { - skp_smallsticker3 = (patch_t *)W_CachePatchName("SP_SM3TC", PU_HUDGFX); - } - } } // -- Kart patches -- @@ -879,7 +864,7 @@ void K_LoadKartHUDGraphics(void) kp_yougotem = (patch_t *)W_CachePatchName("YOUGOTEM", PU_HUDGFX); - if (found_extra_kart || found_extra2_kart || found_extra3_kart) + if (found_extra_kart || found_extra2_kart) K_LoadSaturnHUDGraphics(); } @@ -1149,7 +1134,6 @@ enum SPEEDO_DIAL, SPEEDO_PMETER, SPEEDO_PMETERSMOL, - SPEEDO_EXTRA3, }; static SINT8 K_GetSpeedometerStyle(void) @@ -1164,8 +1148,6 @@ static SINT8 K_GetSpeedometerStyle(void) return SPEEDO_PMETER; else if (cv_newspeedometer.value == 6 && kartz_speedo_smol) return SPEEDO_PMETERSMOL; - else if (cv_newspeedometer.value == 7 && xtra_speedo3) - return SPEEDO_EXTRA3; else return SPEEDO_VANILLA; } @@ -1183,8 +1165,6 @@ static boolean K_UseColorSpeedo(int speedostyle) return achi_speedo_clr; case SPEEDO_DIAL: return dial_speedo_clr; - case SPEEDO_EXTRA3: - return xtra_speedo_clr3; default: return false; } @@ -1196,7 +1176,6 @@ enum GAUGE_SMALL, GAUGE_BIGNUM, GAUGE_NUMONLY, - GAUGE_EXTRA, }; static SINT8 K_GetDriftgaugeStyle(void) @@ -1209,8 +1188,6 @@ static SINT8 K_GetDriftgaugeStyle(void) return GAUGE_SMALL; else if (cv_driftgaugestyle.value == 3) return GAUGE_BIGNUM; - else if (cv_driftgaugestyle.value == 5 && xtra_speedo3) - return GAUGE_EXTRA; } // Fallback @@ -1409,7 +1386,6 @@ static void K_drawKartStats(void) { case SPEEDO_EXTRA: case SPEEDO_ACHII: - case SPEEDO_EXTRA3: spdoffset = -10; break; case SPEEDO_DIAL: @@ -2748,19 +2724,6 @@ static void K_drawKartSpeedometer(void) (K_UseColorSpeedo(SPEEDO_DIAL))); } #endif - else if (speedostyle == SPEEDO_EXTRA3) // why bother if we dont? - { - if (K_UseColorSpeedo(SPEEDO_EXTRA3)) //Colourized hud - { - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((SPDM_X-1)<= driftval*4) // rainbow sparks { diff --git a/src/k_kart.c b/src/k_kart.c index b87894dae..5d8b9b37c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6225,7 +6225,8 @@ void K_KartUpdatePosition(player_t *player) players[i].kartstuff[k_prevcheck] += imo; ipcd++; } - if (isnextcheckpointi ) + + if (isnextcheckpointi) { players[i].kartstuff[k_nextcheck] += imo; incd++; From 6949ce82ab4d169270c547f8a819455d763f7bb4 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Apr 2026 10:03:36 +0200 Subject: [PATCH 288/589] k_hud: fix achii speedometer not being properly coloured with colourhud oopsie smol oversight from me --- src/k_hud.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 4e2f6477f..ebbf2d0b2 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2694,24 +2694,25 @@ static void K_drawKartSpeedometer(void) else if (speedostyle == SPEEDO_EXTRA || speedostyle == SPEEDO_ACHII) // why bother if we dont? { patch_t *speedopat; + UINT8 *colormap = NULL; if (K_UseColorSpeedo(speedostyle)) //Colourized hud { - speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_smallstickerclr : skp_smallstickerachiclr); - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_smallstickerclr : skp_smallstickerachiclr); V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat, colormap); + speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_speedpatches[cv_kartspeedometer.value] : skp_speedpatchesachiclr[cv_kartspeedometer.value]); } else { speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_smallsticker : skp_smallstickerachi); V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat); + speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_speedpatches[cv_kartspeedometer.value] : skp_speedpatchesachi[cv_kartspeedometer.value]); } V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); - - speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_speedpatches[cv_kartspeedometer.value] : skp_speedpatchesachi[cv_kartspeedometer.value]); - V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat); + V_DrawMappedPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat, colormap); } #ifdef ROTSPRITE else if (speedostyle == SPEEDO_DIAL) // why bother if we dont? From 3b00a69615b6cdc021f23f057f1ca6bc139a9fde Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Apr 2026 22:00:36 +0200 Subject: [PATCH 289/589] prevent buffer underflow within holepunching --- src/d_clisrv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b62f97124..e6ca41ab9 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2231,7 +2231,12 @@ static void CL_ReloadReceivedSavegame(void) static void SendAskInfo(INT32 node) { tic_t asktime; - doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); + doomdata_t *netbuffer; + + if (node == -1) + return; + + netbuffer = DOOMCOM_DATA(doomcom); #ifdef HOLEPUNCH if (node != 0 && node != BROADCASTADDR && From 568cb8b8c7a98725daed5a4ab240824744ef9159 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Apr 2026 22:01:50 +0200 Subject: [PATCH 290/589] check I_GetNodeAddress is set before use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this might´ve not been init yet at that point --- src/d_clisrv.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e6ca41ab9..7811b55b3 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3402,16 +3402,14 @@ static void Command_connect(void) D_QuitNetGame(); // this will also call D_CloseConnection for us CL_Reset(); servernode = 0; // not sure if this is cool, but if this is -1 then bad things happen in alot of networking code - multiplayer = false; - netgame = false; - D_StartTitle(); M_StartMessage(M_GetText("Failed to connect to server\nMake sure you put in a valid Address!\n"), NULL, MM_NOTHING); return; } } - CV_Set(&cv_lastserver, I_GetNodeAddress(servernode)); + if (I_GetNodeAddress) + CV_Set(&cv_lastserver, I_GetNodeAddress(servernode)); if (splitscreen != cv_splitplayers.value-1) { From 8868445c3c78709e0f4875052f532bd9c714206b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Apr 2026 17:49:42 +0200 Subject: [PATCH 291/589] S_UpdateSounds: init listenmobj not sure why but ubsan did complain about it sometimes S_StartSoundAtVolume also just memsets it so why not do the same here anyways --- src/s_sound.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 40efbe909..f81690b24 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -722,12 +722,12 @@ void S_UpdateSounds(void) if (dedicated || sound_disabled) return; + memset(listenmobj, 0, sizeof(listenmobj)); + for (i = 0; i <= splitscreen; i++) { player_t *player = &players[displayplayers[i]]; - listenmobj[i] = NULL; - if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; From dbf67a9670d45f0b6bef7d4e582ae18664f53265 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Apr 2026 17:51:10 +0200 Subject: [PATCH 292/589] remove some branch hints in some places should really only use those for things that are basically dead but gotta be kept for compat reasons and such --- src/hardware/hw_main.cpp | 12 ++++++------ src/lua_script.c | 10 +++++----- src/p_map.c | 6 +++--- src/p_mobj.c | 35 ++++++++++++++++++++--------------- src/r_things.cpp | 14 +++++++------- 5 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index d2fc90472..ce683bda7 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -4857,9 +4857,9 @@ static void HWR_ProjectSprite(mobj_t *thing) flip ^= (1<lumpid[0]; flip = sprframe->flip; // Will only be 0x00 or 0xFF - spr_width = spritecachedinfo[lumpoff].width; - spr_height = spritecachedinfo[lumpoff].height; - spr_offset = spritecachedinfo[lumpoff].offset; + spr_width = spritecachedinfo[lumpoff].width; + spr_height = spritecachedinfo[lumpoff].height; + spr_offset = spritecachedinfo[lumpoff].offset; spr_topoffset = spritecachedinfo[lumpoff].topoffset; if (flip) diff --git a/src/lua_script.c b/src/lua_script.c index 8982688a1..8e07f87e3 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -979,7 +979,7 @@ static void ArchiveExtVars(UINT8 **p, void *pointer, const char *ptype) if (!gL) { - if (fastcmp(ptype,"player")) // players must always be included, even if no vars + if (fastcmp(ptype, "player")) // players must always be included, even if no vars WRITEUINT16(*p, 0); return; } @@ -995,7 +995,7 @@ static void ArchiveExtVars(UINT8 **p, void *pointer, const char *ptype) if (!lua_istable(gL, -1)) { // no extra values table lua_pop(gL, 1); - if (fastcmp(ptype,"player")) // players must always be included, even if no vars + if (fastcmp(ptype, "player")) // players must always be included, even if no vars WRITEUINT16(*p, 0); return; } @@ -1007,13 +1007,13 @@ static void ArchiveExtVars(UINT8 **p, void *pointer, const char *ptype) // skip anything that has an empty table and isn't a player. if (i == 0) { - if (fastcmp(ptype,"player")) // always include players even if they have no extra variables + if (fastcmp(ptype, "player")) // always include players even if they have no extra variables WRITEUINT16(*p, 0); lua_pop(gL, 1); return; } - if (fastcmp(ptype,"mobj")) // mobjs must write their mobjnum as a header + if (fastcmp(ptype, "mobj")) // mobjs must write their mobjnum as a header WRITEUINT32(*p, ((mobj_t *)pointer)->mobjnum); WRITEUINT16(*p, i); @@ -1083,8 +1083,8 @@ static void ArchiveTables(UINT8 **p) CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1)); lua_pop(gL, 1); - } + lua_pop(gL, 1); WRITEUINT8(*p, ARCH_TEND); } diff --git a/src/p_map.c b/src/p_map.c index e51930bef..da71b169f 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -189,12 +189,12 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) } if (vertispeed) - object->momz = FixedMul(vertispeed,FixedSqrt(FixedMul(vscale, spring->scale))); + object->momz = FixedMul(vertispeed, FixedSqrt(FixedMul(vscale, spring->scale))); if (horizspeed) { if (!object->player) - P_InstaThrustEvenIn2D(object, spring->angle, FixedMul(horizspeed,FixedSqrt(FixedMul(hscale, spring->scale)))); + P_InstaThrustEvenIn2D(object, spring->angle, FixedMul(horizspeed, FixedSqrt(FixedMul(hscale, spring->scale)))); else { fixed_t finalSpeed = FixedDiv(horizspeed, hscale); @@ -203,7 +203,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (pSpeed > finalSpeed) finalSpeed = pSpeed; - P_InstaThrustEvenIn2D(object, spring->angle, FixedMul(finalSpeed,FixedSqrt(FixedMul(hscale, spring->scale)))); + P_InstaThrustEvenIn2D(object, spring->angle, FixedMul(finalSpeed, FixedSqrt(FixedMul(hscale, spring->scale)))); } } diff --git a/src/p_mobj.c b/src/p_mobj.c index a413feda8..9bd6e65dd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -890,6 +890,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f else // Well, that makes it easy. Just get the ceiling height return sector->ceilingheight; } + static void P_PlayerFlip(mobj_t *mo) { if (!mo->player) @@ -2443,6 +2444,7 @@ static void P_PlayerZMovement(mobj_t *mo) } goto nightsdone; } + // Get up if you fell. if ((mo->state == &states[mo->info->painstate] || mo->state == &states[S_KART_SPIN]) && mo->player->kartstuff[k_spinouttimer] == 0 && mo->player->kartstuff[k_squishedtimer] == 0) // SRB2kart @@ -2495,7 +2497,7 @@ static void P_PlayerZMovement(mobj_t *mo) polyobj_t *po = newsubsec->polyList; sector_t *polysec; - while(po) + while (po) { if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) { @@ -3375,20 +3377,23 @@ static void P_PlayerMobjThinker(mobj_t *mobj) mobj->eflags &= ~MFE_JUSTSTEPPEDDOWN; // Zoom tube - if (UNLIKELY(mobj->tracer && mobj->tracer->type == MT_TUBEWAYPOINT)) + if (mobj->tracer) { - P_UnsetThingPosition(mobj); - mobj->x += mobj->momx; - mobj->y += mobj->momy; - mobj->z += mobj->momz; - P_SetThingPosition(mobj); - P_CheckPosition(mobj, mobj->x, mobj->y); - goto animonly; - } - else if (UNLIKELY(mobj->player->pflags & PF_MACESPIN && mobj->tracer)) - { - P_CheckPosition(mobj, mobj->x, mobj->y); - goto animonly; + if (mobj->tracer->type == MT_TUBEWAYPOINT) + { + P_UnsetThingPosition(mobj); + mobj->x += mobj->momx; + mobj->y += mobj->momy; + mobj->z += mobj->momz; + P_SetThingPosition(mobj); + P_CheckPosition(mobj, mobj->x, mobj->y); + goto animonly; + } + else if (UNLIKELY(mobj->player->pflags & PF_MACESPIN)) + { + P_CheckPosition(mobj, mobj->x, mobj->y); + goto animonly; + } } // Needed for gravity boots @@ -3404,7 +3409,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) else P_TryMove(mobj, mobj->x, mobj->y, true); - if (LIKELY(!(netgame && mobj->player->spectator))) + if (!(netgame && mobj->player->spectator)) { // Crumbling platforms for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) diff --git a/src/r_things.cpp b/src/r_things.cpp index 787c35250..52f8be112 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1357,9 +1357,9 @@ static void R_ProjectSprite(mobj_t *thing) I_Assert(lump < max_spritelumps); - spr_width = spritecachedinfo[lump].width; - spr_height = spritecachedinfo[lump].height; - spr_offset = spritecachedinfo[lump].offset; + spr_width = spritecachedinfo[lump].width; + spr_height = spritecachedinfo[lump].height; + spr_offset = spritecachedinfo[lump].offset; spr_topoffset = spritecachedinfo[lump].topoffset; #ifdef ROTSPRITE @@ -1400,10 +1400,10 @@ static void R_ProjectSprite(mobj_t *thing) if (rotsprite != NULL) { - spr_width = rotsprite->width << FRACBITS; - spr_height = rotsprite->height << FRACBITS; - spr_offset = rotsprite->leftoffset << FRACBITS; - spr_topoffset = rotsprite->topoffset << FRACBITS; + spr_width = rotsprite->width << FRACBITS; + spr_height = rotsprite->height << FRACBITS; + spr_offset = rotsprite->leftoffset << FRACBITS; + spr_topoffset = rotsprite->topoffset << FRACBITS; spr_topoffset += FEETADJUST; // flip -> rotate, not rotate -> flip From 010b6c0361a6476233cb1d389704c1d6e4f0e9c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Apr 2026 17:52:23 +0200 Subject: [PATCH 293/589] use destructor attribute for W_Shutdown makes sure this is always called in any case also just simpler --- src/dedicated/i_system.c | 4 ---- src/sdl/i_system.cpp | 4 ---- src/w_wad.c | 2 +- src/w_wad.h | 2 -- 4 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 9fe312eb7..12932295d 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1458,7 +1458,6 @@ void I_Quit(void) free(myargv); // Deallocate allocated memory death: - W_Shutdown(); exit(0); } @@ -1504,7 +1503,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) I_OutputMsg("SRB2Kart %s Recursive Error", buffer); - W_Shutdown(); exit(-1); // recursive errors detected } } @@ -1539,8 +1537,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) I_ShutdownGraphics(); I_ShutdownSystem(); - W_Shutdown(); - #if defined (PARANOIA) && defined (__CYGWIN__) *(INT32 *)2 = 4; //Alam: Debug! #endif diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 396c59b5b..bf09ab0ca 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -2019,7 +2019,6 @@ FUNCNORETURN void ATTRNORETURN I_Quit(void) if (myargmalloc) free(myargv); // Deallocate allocated memory - W_Shutdown(); exit(0); } @@ -2079,7 +2078,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) sigttl = "SRB2Kart " VERSIONSTRING " Recursive Error"; I_ShowSimpleErrorBox(sigttl, buffer); - W_Shutdown(); exit(-1); // recursive errors detected } } @@ -2121,8 +2119,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) //I_ShowSimpleErrorBox(sigttl, buffer); I_ShowErrorBox(sigttl, buffer); - W_Shutdown(); - #if defined (PARANOIA) && defined (__CYGWIN__) *(INT32 *)2 = 4; //Alam: Debug! #endif diff --git a/src/w_wad.c b/src/w_wad.c index 53b0ed65b..1099667e0 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -128,7 +128,7 @@ wadfile_t *wadfiles[MAX_WADFILES] = {}; // 0 to numwadfiles-1 are valid // If not done on a Mac then open wad files // can prevent removable media they are on from // being ejected -void W_Shutdown(void) +DESTRUCTOR static void W_Shutdown(void) { lumpnum_map_cleanup(&lumpnumcache); diff --git a/src/w_wad.h b/src/w_wad.h index 474f72c23..a17023821 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -154,8 +154,6 @@ extern wadfile_t *wadfiles[MAX_WADFILES]; // ========================================================================= -void W_Shutdown(void); - // Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened FILE *W_OpenWadFile(const char **filename, boolean useerrors); // Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error From 9df7f3cd3f32fde37757a5063b64ce7314ae324e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Apr 2026 17:54:25 +0200 Subject: [PATCH 294/589] dont let saltyhop overwrite the players spriteyoffset let it add to it instead otherwise if we ever use it for smth else in hardcode saltyhop will work with it --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 5d8b9b37c..f7fdba2ad 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3445,7 +3445,7 @@ static void K_QuiteSaltyHop(player_t *player) pmo->spritexscale -= (FRACUNIT/8); } - pmo->spriteyoffset = FixedMul(psalt->zoffset, cv_saltyheight.value); + pmo->spriteyoffset += FixedMul(psalt->zoffset, cv_saltyheight.value); if (cv_saltyhopsfx.value) { From 1bada2810a076ebfc77c3d12df05e6496c26287b Mon Sep 17 00:00:00 2001 From: minenice55 Date: Sun, 26 Apr 2026 19:36:07 -0400 Subject: [PATCH 295/589] cap download size to total size in the connection UI --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7811b55b3..ffb43ee86 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1491,8 +1491,8 @@ static void CL_DrawConnectionStatus(void) static char tempname[28]; fileneeded_t *file = &fileneeded[filedownload.current]; char *filename = file->filename; - UINT32 currentsize = file->currentsize; UINT32 totalsize = file->totalsize; + UINT32 currentsize = min(file->currentsize, file->totalsize); // Draw the bottom box. M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); From 093ed023ef36bb2e8608116ef39d7710366ccf84 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Apr 2026 17:47:55 +0200 Subject: [PATCH 296/589] cleanup CL_DrawConnectionStatus a little --- src/d_clisrv.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ffb43ee86..2228eb172 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1255,20 +1255,18 @@ static void CL_DrawConnectionStatus(void) case CL_DOWNLOADSAVEGAME: if (filedownload.current != -1) { - INT32 dldlength = 0; + UINT32 dldlength = 0; fileneeded_t *file = &fileneeded[filedownload.current]; - UINT32 currentsize = file->currentsize; UINT32 totalsize = file->totalsize; + UINT32 currentsize = min(file->currentsize, totalsize); cltext = M_GetText("Downloading game state..."); Net_GetNetStat(); if (totalsize != 0) - dldlength = (INT32)((currentsize/(double)totalsize) * 256); - if (dldlength > 256) - dldlength = 256; + dldlength = (UINT32)((currentsize/(double)totalsize) * 256); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 111); - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, dldlength, 8, 96); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, (INT32)dldlength, 8, 96); V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, va(" %4uK/%4uK", currentsize>>10, totalsize>>10)); @@ -1485,14 +1483,14 @@ static void CL_DrawConnectionStatus(void) } else if (filedownload.current != -1) { - INT32 dldlength = 0; - INT32 totalfileslength = 0; + UINT32 dldlength = 0; UINT32 totaldldsize = 0; + UINT32 totalfileslength = filedownload.totalsize; static char tempname[28]; fileneeded_t *file = &fileneeded[filedownload.current]; char *filename = file->filename; UINT32 totalsize = file->totalsize; - UINT32 currentsize = min(file->currentsize, file->totalsize); + UINT32 currentsize = min(file->currentsize, totalsize); // Draw the bottom box. M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); @@ -1500,11 +1498,9 @@ static void CL_DrawConnectionStatus(void) Net_GetNetStat(); if (totalsize != 0) - dldlength = (INT32)((currentsize/(double)totalsize) * 256); - if (dldlength > 256) - dldlength = 256; + dldlength = (UINT32)((currentsize/(double)totalsize) * 256); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, 256, 8, 175); - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, dldlength, 8, 160); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, (INT32)dldlength, 8, 160); memset(tempname, 0, sizeof(tempname)); @@ -1545,18 +1541,18 @@ static void CL_DrawConnectionStatus(void) totaldldsize = filedownload.completedsize; V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP|MENUCAPS, "Overall Download Progress"); - if (filedownload.totalsize != 0) - totalfileslength = (INT32)((totaldldsize/(double)filedownload.totalsize) * 256); + if (totalfileslength != 0) + totalfileslength = (UINT32)((totaldldsize/(double)totalfileslength) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, (INT32)totalfileslength, 8, 160); - if (filedownload.totalsize>>20 >= 10) // display in MB if over 10MB + if (totalfileslength>>20 >= 10) // display in MB if over 10MB V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uM/%4uM", totaldldsize>>20, filedownload.totalsize>>20)); + va(" %4uM/%4uM", (INT32)(totaldldsize>>20), (INT32)(totalfileslength>>20))); else V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uK/%4uK", totaldldsize>>10, filedownload.totalsize>>10)); + va(" %4uK/%4uK", (INT32)(totaldldsize>>10), (INT32)(totalfileslength>>10))); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va("%2u/%2u Files ", filedownload.completednum, filedownload.totalnum)); From 6460ae94f119b224291a9addd0132e135dd45d6b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Apr 2026 17:43:10 +0200 Subject: [PATCH 297/589] remove magic number for P_CalculatePrecipFloor stuff --- 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 9bd6e65dd..605395816 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3627,7 +3627,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj) return true; // only recalc this twice a second (doubt anyone will notice this lulul) - if ((leveltime % 17) == 0) + if ((leveltime % (TICRATE/2)) == 0) P_CalculatePrecipFloor(mobj); // adjust height From 535c2073f1512311c2a9fb64b6cd615070e106b1 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 1 May 2026 03:51:28 +0200 Subject: [PATCH 298/589] move palshader code out of HWR_DrawScreenFinalTexture and make the whole handling safer so we have less chance of ending up with blackscreens should the palette render shader fail --- src/hardware/hw_gl.h | 3 ++- src/hardware/hw_main.h | 4 ++-- src/hardware/r_opengl/r_opengl.c | 15 ++++++++------- src/sdl/ogl_sdl.c | 15 +++++++++++++-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_gl.h b/src/hardware/hw_gl.h index de5ac6338..351b36353 100644 --- a/src/hardware/hw_gl.h +++ b/src/hardware/hw_gl.h @@ -63,7 +63,7 @@ void GL_FlushScreenTextures(void); void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags); void GL_DoScreenWipe(int wipeStart, int wipeEnd); void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize); -void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean useshader); +void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height); void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]); @@ -72,6 +72,7 @@ void GL_LoadShader(int slot, char *code, hwdshaderstage_t stage); boolean GL_CompileShader(int slot); void GL_SetShader(int slot); void GL_UnSetShader(void); +void GL_EnableShader(void); void GL_SetShaderInfo(hwdshaderinfo_t info, INT32 value); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index cbd8e11e7..a632946c1 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -161,9 +161,9 @@ FUNCINLINE static ATTRINLINE void HWR_MakeScreenFinalTexture(void) GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); } -FUNCINLINE static ATTRINLINE void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader) +FUNCINLINE static ATTRINLINE void HWR_DrawScreenFinalTexture(INT32 width, INT32 height) { - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height, useshader); + GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height); } // hw_main.c: Segs diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index a759b8b2b..1a8e2a8c4 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1068,6 +1068,13 @@ void GL_SetShader(int slot) gl_shadersenabled = false; } +void GL_EnableShader(void) +{ + // we can just use GL_Shader_SetUniforms as itll enable the shader for us + // and handle any failures + GL_Shader_SetUniforms(NULL, NULL, NULL, NULL); +} + void GL_UnSetShader(void) { if (gl_shadersenabled) // don't repeatedly call glUseProgram if not needed @@ -3718,7 +3725,7 @@ void GL_MakeScreenTexture(int tex) tex_downloaded = screenTextures[tex]; } -void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean useshader) +void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height) { float xfix, yfix; float origaspect, newaspect; @@ -3771,9 +3778,6 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]); - if (useshader) - pglUseProgram(gl_shaders[SHADER_PALETTE_POSTPROCESS].program); // Final postprocess step of palette rendering, after everything else has been drawn. - pglColor4ubv(white); pglTexCoordPointer(2, GL_FLOAT, 0, fix); @@ -3781,9 +3785,6 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); - if (useshader) - pglUseProgram(0); - tex_downloaded = screenTextures[tex]; } diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 46af6e178..f5e7f2aea 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -240,7 +240,18 @@ void OglSdlFinishUpdate(SDL_Window *window) } #endif - HWR_DrawScreenFinalTexture(sdlw, sdlh, HWR_ShouldUsePaletteRendering()); + if (HWR_ShouldUsePaletteRendering()) + { + // Final postprocess step of palette rendering, after everything else has been drawn. + GL_SetShader(HWR_GetShaderFromTarget(SHADER_PALETTE_POSTPROCESS)); + GL_EnableShader(); + HWR_DrawScreenFinalTexture(sdlw, sdlh); + GL_UnSetShader(); + } + else + { + HWR_DrawScreenFinalTexture(sdlw, sdlh); + } #ifdef USE_FBO_OGL if (usefbo) @@ -261,7 +272,7 @@ void OglSdlFinishUpdate(SDL_Window *window) #else if (!I_CheckNativeRes() || WipeInAction) #endif - HWR_DrawScreenFinalTexture(realwidth, realheight, false); + HWR_DrawScreenFinalTexture(realwidth, realheight); } #endif //HWRENDER From 370ed1583bd9838401926c71c348f58d4afb4620 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 May 2026 21:02:38 +0200 Subject: [PATCH 299/589] comment out unused spritescale/offset fields from gl_vissprite_t yes those are in fact unused not deleting since they might be useful for something sometime.... --- src/hardware/hw_glob.h | 4 ++-- src/hardware/hw_main.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index e6b6734a5..fa8993b4c 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -34,8 +34,8 @@ typedef struct gl_vissprite_s float gz, gzt; float tz; float scale; - float spritexscale, spriteyscale; - float spritexoffset, spriteyoffset; + //float spritexscale, spriteyscale; + //float spritexoffset, spriteyoffset; patch_t *gpatch; boolean flip; UINT8 translucency; //alpha level 0-255 diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index ce683bda7..971627477 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5008,10 +5008,10 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->flip = flip; vis->scale = thing_scale; - vis->spritexscale = spritexscale; + /*vis->spritexscale = spritexscale; vis->spriteyscale = spriteyscale; vis->spritexoffset = FixedToFloat(spr_offset); - vis->spriteyoffset = FixedToFloat(spr_topoffset); + vis->spriteyoffset = FixedToFloat(spr_topoffset);*/ #ifdef ROTSPRITE if (rotsprite != NULL) From 45067e00a5113ab4c8b70836602e4247670bfd77 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 May 2026 08:04:00 +0200 Subject: [PATCH 300/589] fix compiler warnings + "support" gcc16 --- src/Makefile.d/detect.mk | 3 ++- src/hardware/hw_md3load.c | 7 +++---- src/y_inter.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk index 0816c5a03..766b497c3 100644 --- a/src/Makefile.d/detect.mk +++ b/src/Makefile.d/detect.mk @@ -64,6 +64,7 @@ endif # This must have high to low order. gcc_versions:=\ + 161 160 16\ 152 151 150 15\ 142 141 140 14\ 133 132 131 130 13\ @@ -77,7 +78,7 @@ gcc_versions:=\ 55 54 53 52 51 50\ 49 48 47 46 45 44 43 42 41 40 -latest_gcc_version:=15.2 +latest_gcc_version:=16.1 # Automatically set version flag, but not if one was # manually set. And don't bother if this is a clean only diff --git a/src/hardware/hw_md3load.c b/src/hardware/hw_md3load.c index b536c7e73..06aa6507e 100644 --- a/src/hardware/hw_md3load.c +++ b/src/hardware/hw_md3load.c @@ -154,7 +154,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) char *buffer; int surfEnd; int i, t; - int matCount; + //int matCount; FILE *f; if (!latlnginit) @@ -227,7 +227,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, NULL); - matCount = 0; + //matCount = 0; for (i = 0, surfEnd = 0; i < mdh->numSurfaces; i++) { int j; @@ -237,7 +237,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) mdShader = (md3Shader*)((char*)mdS + mdS->offsetShaders); - for (j = 0; j < mdS->numShaders; j++, matCount++) + for (j = 0; j < mdS->numShaders; j++ /*, matCount++*/) { size_t len = strlen(mdShader[j].name); mdShader[j].name[len-1] = 'z'; @@ -503,7 +503,6 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) } }*/ - free(buffer); return retModel; diff --git a/src/y_inter.c b/src/y_inter.c index 684797999..5fbd4d86e 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -330,7 +330,7 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) V_DrawCenteredString(x+6, y, 0, va("%d", standings->pos[i])); // localskins are amazing - if (standings->color[i] != SKINCOLOR_NONE) + if (*standings->color[i] != SKINCOLOR_NONE) { UINT8 *colormap = R_GetTranslationColormap(*standings->character[i], *standings->color[i], GTC_CACHE); INT32 skinnum = (player->localskin ? (player->localskin - 1) : *standings->character[i]); From 3c409b4a4670d57784c19c1c39c93d9ac574e8cf Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 May 2026 10:01:14 +0200 Subject: [PATCH 301/589] detect kill signal when printing signal from signalhandler bit more informative than "signal number 9" --- src/dedicated/i_system.c | 9 +++++++-- src/sdl/i_system.cpp | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 12932295d..f2c6c76ef 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1023,8 +1023,13 @@ static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_ms sigmsg = ("SIGSEGV - SRB2Kart-Saturn has attempted to access a memory location that it shouldn't and needs to close."); break; #ifdef SIGTERM - case SIGTERM: // Software termination signal from kill - sigmsg = ("SIGTERM - SRB2Kart-Saturn was terminated by a kill signal."); + case SIGTERM: // Software termination signal from terminate + sigmsg = ("SIGTERM - SRB2Kart-Saturn was terminated by a terminate signal."); + break; +#endif +#ifdef SIGKILL + case SIGKILL: // Software termination signal from kill + sigmsg = ("SIGKILL - SRB2Kart-Saturn was terminated by a kill signal."); break; #endif #ifdef SIGBREAK diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index bf09ab0ca..9b9e49305 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1662,11 +1662,17 @@ static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_ms signame = "SIGSEGV"; break; #ifdef SIGTERM - case SIGTERM: // Software termination signal from kill - sigmsg = ("SRB2Kart-Saturn was terminated by a kill signal."); + case SIGTERM: // Software termination signal from terminate + sigmsg = ("SRB2Kart-Saturn was terminated by a terminate signal."); signame = "SIGTERM"; break; #endif +#ifdef SIGKILL + case SIGKILL: // Software termination signal from kill + sigmsg = ("SRB2Kart-Saturn was terminated by a kill signal."); + signame = "SIGKILL"; + break; +#endif #ifdef SIGBREAK case SIGBREAK: // Ctrl-Break sequence sigmsg =("SIGBREAK - SRB2Kart-Saturn was terminated by a Ctrl-Break sequence."); From 4fe34956523ea453afec48a7c93965c2f4794e25 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 May 2026 10:25:52 +0200 Subject: [PATCH 302/589] fallback to srb2back instead of hoping the map is still loaded for intermission bg timescale and replay fastforward caused stuff to crash and well this is better than a whitescreen ig --- src/d_main.c | 21 +++++---------------- src/doomstat.h | 1 + src/hardware/hw_main.cpp | 5 ++--- src/screen.c | 5 +---- src/y_inter.c | 2 ++ 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index eb503b39f..c1e96ebc9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -138,6 +138,7 @@ boolean devparm = false; // started game with -devparm boolean singletics = false; // timedemo boolean lastdraw = false; +boolean intermissionbginit = false; #ifdef MOTIONBLUR INT32 postimgparam[MAXSPLITSCREENPLAYERS]; @@ -370,23 +371,10 @@ static void D_MakeIntermissionBG(void) if (rendermode == render_none) { lastdraw = false; + intermissionbginit = false; return; } - // no more valid map - // shouldnt happen at this point, but better safe than sorry! - if (!numsectors) - { - lastdraw = false; - return; - } - - // need to render level again for this - // should be fine since at this point we did not unload it yet - if (cv_renderview.value) - { - D_Renderview(); - } #ifdef HWRENDER if (rendermode == render_opengl) { @@ -399,6 +387,7 @@ static void D_MakeIntermissionBG(void) } lastdraw = false; + intermissionbginit = true; } static boolean D_Display(void) @@ -558,8 +547,6 @@ static boolean D_Display(void) break; } - D_MakeIntermissionBG(); - if (gamestate == GS_LEVEL) { // draw the view directly @@ -568,6 +555,8 @@ static boolean D_Display(void) PS_START_TIMING(ps_rendercalltime); D_Renderview(); PS_STOP_TIMING(ps_rendercalltime); + + D_MakeIntermissionBG(); } PS_START_TIMING(ps_uitime); diff --git a/src/doomstat.h b/src/doomstat.h index e8eae7a4f..86d742183 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -113,6 +113,7 @@ extern UINT8 window_notinfocus; // are we in focus? (backend independant -- hand extern boolean nodrawers; extern boolean lastdraw; +extern boolean intermissionbginit; #ifdef MOTIONBLUR extern INT32 postimgparam[MAXSPLITSCREENPLAYERS]; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 971627477..f603b58a2 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -258,9 +258,7 @@ static void CV_screentextures_OnChange(void) if (cv_glframebuffer.value != 0) CV_SetValue(&cv_glframebuffer, 0); #endif - // HACK: set lastdraw so intermission bg can refresh after toggling screentextures - if (gamestate == GS_INTERMISSION) - lastdraw = true; + intermissionbginit = false; } GL_SetSpecialState(HWD_SET_SCREEN_TEXTURES, cv_glscreentextures.value); M_UpdateOGLMenu(); @@ -277,6 +275,7 @@ static void CV_glframebuffer_OnChange(void) I_DownSample(); RefreshOGLSDLSurface(); M_UpdateOGLMenu(); + intermissionbginit = false; } #endif diff --git a/src/screen.c b/src/screen.c index 84e81617a..a874ed530 100644 --- a/src/screen.c +++ b/src/screen.c @@ -277,10 +277,7 @@ void SCR_Recalc(void) // vid.recalc lasts only for the next refresh... con_recalc = true; am_recalc = true; - - // HACK: set lastdraw so intermission bg can refresh after resolution change - if (gamestate == GS_INTERMISSION) - lastdraw = true; + intermissionbginit = false; } // Check for screen cmd-line parms: to force a resolution. diff --git a/src/y_inter.c b/src/y_inter.c index 5fbd4d86e..19b696b0e 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -433,6 +433,7 @@ void Y_IntermissionDrawer(void) return; if (cv_betainterscreen.value == 1 + || !intermissionbginit #ifdef HWRENDER || (rendermode == render_opengl && cv_glscreentextures.value != 2) // use the neato kart bg for intermission on disabled screen textures #endif @@ -794,6 +795,7 @@ void Y_EndIntermission(void) endtic = -1; sorttic = -1; intertype = int_none; + intermissionbginit = false; // not sure if this is the right place to reset, but i guess it works for now.... } // From 7f4804f98c2e3099be946887e3dfe9a9329cbc10 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 May 2026 14:10:39 +0200 Subject: [PATCH 303/589] fix super rare underflow within FixedHypot if input is -2147483648 this has an insanely rare chance of happening in certain cases (train rush map has a few spots where this is somewhat likely) abs does not really handle -2147483648 and its result is pretty much implementation defined/ub, since we compile with fwrapv flag it would just return -2147483648 which will cause this to try and access tantoangle at a negative index we can just return INT32_MAX here since treating either as 2147483647 would return 2147483647 eitherways --- src/m_fixed.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/m_fixed.c b/src/m_fixed.c index d7aa13254..3bab22815 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -62,6 +62,9 @@ FUNCMATH fixed_t FixedHypot(fixed_t x, fixed_t y) angle_t angle; fixed_t dist; + I_Assert(x != INT32_MIN); + I_Assert(y != INT32_MIN); + x = abs(x); y = abs(y); @@ -77,6 +80,10 @@ FUNCMATH fixed_t FixedHypot(fixed_t x, fixed_t y) if (!y) return x; + // prevent underflow + if (y == INT32_MIN) + return INT32_MAX; + angle = (tantoangle[FixedDiv(y, x)>>DBITS] + ANGLE_90) >> ANGLETOFINESHIFT; // use as cosine From d0ea4d20d095f2325a81e707b0475f25c3b51766 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 May 2026 22:59:39 +0200 Subject: [PATCH 304/589] fix parent process being killed before child per interrupt/terminate signals by ignoring those signals otherwise the terminal will be left in a weird state, aswell as the parent exit stuff wont be properly run this was "fine" before https://github.com/Indev450/SRB2Kart-Saturn/commit/f4dc161831a988e725e8639b9674984ebdf5f6bb but now needs to be handled like this --- src/dedicated/i_system.c | 12 ++++++++++++ src/sdl/i_system.cpp | 17 ++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index f2c6c76ef..2e32b2b11 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1362,6 +1362,18 @@ static void I_Fork(void) I_RegisterChildSignals(); break; default: + // ignore those, those are handled by child process + // otherwise parent might exit before it + // and the below stuff wont run and your terminal will be left in an awkward state +#ifdef SIGINT + signal(SIGINT, SIG_IGN); +#endif +#ifdef SIGBREAK + signal(SIGBREAK, SIG_IGN); +#endif +#ifdef SIGTERM + signal(SIGTERM, SIG_IGN); +#endif if (logstream) fclose(logstream);/* the child has this */ diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 9b9e49305..87fec2f2f 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1868,9 +1868,7 @@ static void I_RegisterChildSignals(void) signal(SIGABRT, signal_handler_child); signal(SIGFPE, signal_handler_child); } -#endif -#ifdef NEWSIGNALHANDLER FUNCNORETURN static ATTRNORETURN void newsignalhandler_Warn(const char *pr) { char text[128]; @@ -1906,6 +1904,18 @@ static void I_Fork(void) I_RegisterChildSignals(); break; default: + // ignore those, those are handled by child process + // otherwise parent might exit before it + // and the below stuff wont run and your terminal will be left in an awkward state +#ifdef SIGINT + signal(SIGINT, SIG_IGN); +#endif +#ifdef SIGBREAK + signal(SIGBREAK, SIG_IGN); +#endif +#ifdef SIGTERM + signal(SIGTERM, SIG_IGN); +#endif #ifdef LOGMESSAGES if (logstream) fclose(logstream);/* the child has this */ @@ -1914,6 +1924,8 @@ static void I_Fork(void) #ifdef LOGMESSAGES /* By the way, exit closes files. */ logstream = fopen(logfilename, "at"); +#else + logstream = 0; #endif if (c == -1) { @@ -2325,7 +2337,6 @@ char *I_GetUserName(void) strncpy(username, p, MAXPLAYERNAME); } - if (!fastcmp(username, "")) return username; From b1620a3fce888ee085457d31197f2fab699b9f00 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 May 2026 23:01:43 +0200 Subject: [PATCH 305/589] delet I_ShutdownConsole spam without process forking I_ShutdownSystem will handle it, otherwise the parent process calls it before exiting --- src/dedicated/i_system.c | 10 +++------- src/sdl/i_system.cpp | 3 --- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 2e32b2b11..fb3cc2731 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1378,14 +1378,12 @@ static void I_Fork(void) fclose(logstream);/* the child has this */ c = wait(&status); - #ifdef LOGMESSAGES /* By the way, exit closes files. */ logstream = fopen(logfilename, "at"); #else logstream = 0; #endif - if (c == -1) { kill(child, SIGKILL); @@ -1447,7 +1445,6 @@ void I_Quit(void) goto death; quiting = false; - I_ShutdownConsole(); M_SaveConfig(NULL); //save game config, cvars.. D_SaveBan(); // save the ban list G_SaveGameData(false); // Tails 12-08-2002 @@ -1537,8 +1534,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) #endif // --- - I_ShutdownConsole(); - M_SaveConfig(NULL); // save game config, cvars.. D_SaveBan(); // save the ban list G_SaveGameData(false); // Tails 12-08-2002 @@ -1659,9 +1654,10 @@ void I_ShutdownSystem(void) { INT32 c; -#ifndef NEWSIGNALHANDLER - I_ShutdownConsole(); +#ifdef NEWSIGNALHANDLER + if (M_CheckParm("-nofork")) #endif + I_ShutdownConsole(); for (c = MAX_QUIT_FUNCS-1; c >= 0; c--) if (quit_funcs[c]) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 87fec2f2f..7e1a93835 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -2008,7 +2008,6 @@ FUNCNORETURN void ATTRNORETURN I_Quit(void) is_quitting = true; SDL_ShowCursor(SDL_TRUE); - I_ShutdownConsole(); M_SaveConfig(NULL); //save game config, cvars.. D_SaveBan(); // save the ban list G_SaveGameData(false); // Tails 12-08-2002 @@ -2114,8 +2113,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) // --- - I_ShutdownConsole(); - M_SaveConfig(NULL); // save game config, cvars.. D_SaveBan(); // save the ban list G_SaveGameData(false); // Tails 12-08-2002 From f1ded992625fd046279d399054cfc376a6c4b248 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 6 May 2026 12:28:05 +0200 Subject: [PATCH 306/589] some code style cleanups --- src/d_main.c | 8 ++++---- src/hardware/hw_clip.c | 11 +++++----- src/hardware/hw_draw.c | 40 ++++++++++++++++++++----------------- src/hardware/hw_main.cpp | 43 ++++++++++++++++++++-------------------- src/p_map.c | 28 +++++++++++++++----------- src/p_mobj.c | 24 ++++++++++++++-------- 6 files changed, 85 insertions(+), 69 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index c1e96ebc9..e24c66fea 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -722,13 +722,15 @@ void D_SRB2Loop(void) precise_t elapsed; precise_t enterprecise, finishprecise; + boolean ranwipe = false; + + enterprecise = I_GetPreciseTime(); + if (I_Interrupted()) { I_Quit(); } - enterprecise = I_GetPreciseTime(); - memset(&g_dc, 0, sizeof(g_dc)); Z_Frame_Reset(); @@ -736,8 +738,6 @@ void D_SRB2Loop(void) const UINT32 framecap = R_GetFramerateCap(); capbudget = (framecap == 0) ? 0 : (precise_t)((double)precision / (double)framecap + 0.5); // + 0.5 instead of round - boolean ranwipe = false; - I_UpdateTime(cv_timescale.value); if (lastwipetic) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 6790823f2..68bbc98e3 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -319,16 +319,17 @@ angle_t gld_FrustumAngle(angle_t tiltangle) double clipfov; double floatangle; angle_t a1; - - float tilt = fabsf(((float)(int)tiltangle) / (float)ANG1); - - if (tilt > 90.0f) - tilt = 90.0f; + float tilt; // If the pitch is larger than this you can look all around at a FOV of 90 if (abs((signed)tiltangle) > 46 * ANG1) return 0xffffffff; + tilt = fabsf(((float)(int)tiltangle) / (float)ANG1); + + if (tilt > 90.0f) + tilt = 90.0f; + // ok, this is a gross hack that barely works... // but at least it doesn't overestimate too much... clipfov = atan(1 / (GLdouble)projMatrix[0]) * 360.0 / M_PI; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 7bccbe198..981e54f0a 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -32,20 +32,6 @@ #include -typedef struct -{ - UINT8 id_field_length ; // 1 - UINT8 color_map_type ; // 2 - UINT8 image_type ; // 3 - UINT8 dummy[5] ; // 4, 8 - INT16 x_origin ; // 9, 10 - INT16 y_origin ; //11, 12 - INT16 width ; //13, 14 - INT16 height ; //15, 16 - UINT8 image_pix_size ; //17 - UINT8 image_descriptor; //18 -} ATTRPACK TGAHeader; // sizeof is 18 - static const UINT8 softwaretranstogl[11] = { 0, 25, 51, 76,102,127,153,178,204,229,255}; static const UINT8 softwaretranstogl_hi[11] = { 0, 51,102,153,204,255,255,255,255,255,255}; static const UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111,127}; @@ -57,8 +43,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p { FOutVector v[4]; FBITFIELD flags; - float cx = FIXED_TO_FLOAT(x); - float cy = FIXED_TO_FLOAT(y); + float cx, cy; UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); UINT8 blendmode = ((bflags & V_BLENDMASK) >> V_BLENDSHIFT); GLPatch_t *hwrPatch; @@ -72,6 +57,9 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p if (alphalevel >= 10 && alphalevel < 13) return; + cx = FIXED_TO_FLOAT(x); + cy = FIXED_TO_FLOAT(y); + const float fvw = (float)vid.width; const float fvh = (float)vid.height; @@ -244,8 +232,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, { FOutVector v[4]; FBITFIELD flags; - float cx = FIXED_TO_FLOAT(x); - float cy = FIXED_TO_FLOAT(y); + float cx, cy; UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); GLPatch_t *hwrPatch; @@ -258,6 +245,9 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, if (alphalevel >= 10 && alphalevel < 13) return; + cx = FIXED_TO_FLOAT(x); + cy = FIXED_TO_FLOAT(y); + const float fvw = (float)vid.width; const float fvh = (float)vid.height; @@ -964,6 +954,20 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) #endif #ifndef USE_PNG +typedef struct +{ + UINT8 id_field_length ; // 1 + UINT8 color_map_type ; // 2 + UINT8 image_type ; // 3 + UINT8 dummy[5] ; // 4, 8 + INT16 x_origin ; // 9, 10 + INT16 y_origin ; //11, 12 + INT16 width ; //13, 14 + INT16 height ; //15, 16 + UINT8 image_pix_size ; //17 + UINT8 image_descriptor; //18 +} ATTRPACK TGAHeader; // sizeof is 18 + // -------------------------------------------------------------------------- // save screenshots with TGA format // -------------------------------------------------------------------------- diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index f603b58a2..e106454aa 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -511,7 +511,7 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg, extracolormap_t *colo { INT16 finallight = lightnum; - if (cv_glfakecontrast.value == 0 || (HWR_ShouldUsePaletteRendering() && colormap)) + if (cv_glfakecontrast.value == 0 || (colormap && HWR_ShouldUsePaletteRendering())) return (FUINT)finallight; if (seg != NULL && P_ApplyLightOffsetFine(lightnum, seg->frontsector)) @@ -3801,7 +3801,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) { const fixed_t h = P_GetLightZAt(§or->lightlist[i], sprmo->x, sprmo->y); - if (!(h <= temp)) + if (h > temp) continue; if (!lightset) @@ -3936,7 +3936,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) mobj_t *sprmo = spr->mobj; - if (UNLIKELY(!sprmo->subsector)) + if (!sprmo->subsector) return; const boolean papersprite = (sprmo->frame & FF_PAPERSPRITE); @@ -4100,7 +4100,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) const precipmobj_t *sprmo = spr->precip; - if (UNLIKELY(!sprmo->subsector)) + if (!sprmo->subsector) return; // cache sprite graphics @@ -4300,22 +4300,23 @@ static std::vector drawnodes; static void *HWR_CreateDrawNode(gl_drawnode_type_t type) { - // if we didnt alloc anything yet, reserve atleast 64 nodes - // dont declare with it as we want our size to be 0! + gl_drawnode_t *drawnode; drawnodes.reserve(DRAWNODES_INIT_SIZE); drawnodes.emplace_back(); - drawnodes.back().type = type; + + drawnode = &drawnodes.back(); + drawnode->type = type; // not sure if returning different pointers to a union is necessary switch (type) { case DRAWNODE_PLANE: - return &drawnodes.back().u.plane; + return &drawnode->u.plane; case DRAWNODE_POLYOBJECT_PLANE: - return &drawnodes.back().u.polyplane; + return &drawnode->u.polyplane; case DRAWNODE_WALL: - return &drawnodes.back().u.wall; + return &drawnode->u.wall; } return NULL; @@ -4817,11 +4818,9 @@ static void HWR_ProjectSprite(mobj_t *thing) ) { ang = R_PointToAngle(interp.x, interp.y); - #ifdef ROTSPRITE camang = ang; #endif - ang -= interp.angle; if (mirrored) @@ -4944,11 +4943,11 @@ static void HWR_ProjectSprite(mobj_t *thing) // if the sprite is out of our view, dont need to draw it X) if (!gld_SphereInFrustum( (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, - FixedToFloat(interp.z) + (y1 + y2) / 2.0f, - FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, - //1.5 == sqrt(2) + small delta for MF_FOREGROUND - std::max(FixedToFloat(spr_width) * spritexscale, - FixedToFloat(spr_height) * spriteyscale) / 2.0f * 1.5f)) + FixedToFloat(interp.z) + (y1 + y2) / 2.0f, + FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + //1.5 == sqrt(2) + small delta for MF_FOREGROUND + std::max(FixedToFloat(spr_width) * spritexscale, + FixedToFloat(spr_height) * spriteyscale) / 2.0f * 1.5f)) { return; } @@ -5164,11 +5163,11 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) if (!gld_SphereInFrustum( (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, - FixedToFloat(interp.z) + (y1 + y2) / 2.0f, - FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, - //1.5 == sqrt(2) + small delta for MF_FOREGROUND - std::max(FixedToFloat(spr_width) * thing_scale, - FixedToFloat(spr_height) * thing_scale) / 2.0f * 1.5f)) + FixedToFloat(interp.z) + (y1 + y2) / 2.0f, + FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + //1.5 == sqrt(2) + small delta for MF_FOREGROUND + std::max(FixedToFloat(spr_width) * thing_scale, + FixedToFloat(spr_height) * thing_scale) / 2.0f * 1.5f)) { return; } diff --git a/src/p_map.c b/src/p_map.c index da71b169f..10b55f65b 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -321,7 +321,7 @@ static boolean PIT_CheckThing(mobj_t *thing) // Ignore spectators if ((tmthing->player && tmthing->player->spectator) - || (thing->player && thing->player->spectator)) + || (thing->player && thing->player->spectator)) return true; #ifdef SEENAMES @@ -1509,14 +1509,14 @@ static boolean PIT_CheckThing(mobj_t *thing) // Adjusts tmfloorz and tmceilingz as lines are contacted - FOR CAMERA ONLY static boolean PIT_CheckCameraLine(line_t *ld) { - if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) + if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return true; - if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - { + if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return true; - } if (P_BoxOnLineSide(tmbbox, ld) != -1) return true; @@ -1571,11 +1571,13 @@ static boolean PIT_CheckCameraLine(line_t *ld) // static boolean PIT_CheckLine(line_t *ld) { - if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) + if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return true; - if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return true; if (P_BoxOnLineSide(tmbbox, ld) != -1) @@ -1584,10 +1586,12 @@ static boolean PIT_CheckLine(line_t *ld) if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag. { fixed_t cosradius, sinradius; + cosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT)); sinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT)); + if (P_PointOnLineSide(tmx - cosradius, tmy - sinradius, ld) - == P_PointOnLineSide(tmx + cosradius, tmy + sinradius, ld)) + == P_PointOnLineSide(tmx + cosradius, tmy + sinradius, ld)) return true; // the line doesn't cross between collider's start or end } @@ -4001,10 +4005,10 @@ static inline boolean PIT_GetSectors(line_t *ld) tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return true; - if (P_BoxOnLineSide(tmbbox, ld) != -1) + if (ld->polyobj) // line belongs to a polyobject, don't add it return true; - if (ld->polyobj) // line belongs to a polyobject, don't add it + if (P_BoxOnLineSide(tmbbox, ld) != -1) return true; // This line crosses through the object. diff --git a/src/p_mobj.c b/src/p_mobj.c index 605395816..cdc25a3e0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -596,8 +596,10 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t fixed_t highline; ld = boundsec->lines[i]; - if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) continue; if (P_BoxOnLineSide(bbox, ld) != -1) @@ -683,8 +685,10 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed fixed_t highline; ld = boundsec->lines[i]; - if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) continue; if (P_BoxOnLineSide(bbox, ld) != -1) @@ -771,8 +775,10 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix fixed_t highline; ld = boundsec->lines[i]; - if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) continue; if (P_BoxOnLineSide(bbox, ld) != -1) @@ -858,8 +864,10 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f fixed_t highline; ld = boundsec->lines[i]; - if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) continue; if (P_BoxOnLineSide(bbox, ld) != -1) From 50c1263e7d4ff1a44d3676615a36422b90951bea Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 6 May 2026 12:27:06 +0200 Subject: [PATCH 307/589] OpenGL: only enable stencil testing during level render MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit not 100% sure if this is the most correct thing, but this causes issues with Nvidia Gpu´s under x11 should fix https://github.com/Indev450/SRB2Kart-Saturn/issues/226 --- src/hardware/hw_gl.h | 4 ++++ src/hardware/hw_main.cpp | 4 ++++ src/hardware/r_opengl/r_opengl.c | 12 +++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_gl.h b/src/hardware/hw_gl.h index 351b36353..b808ed09a 100644 --- a/src/hardware/hw_gl.h +++ b/src/hardware/hw_gl.h @@ -32,8 +32,12 @@ void GL_SetSpecialState(hwdspecialstate_t IdState, INT32 Value); void GL_SetTransform(FTransform *stransform); void GL_SetBlend(FBITFIELD PolyFlags); void GL_SetPalette(RGBA_t *palette); + void GL_ClearBuffer(FBOOLEAN ColorMask, FBOOLEAN DepthMask, FBOOLEAN StencilMask, FRGBAFloat * ClearColor); +void GL_EnableStencilTest(void); +void GL_DisableStencilTest(void); + void GL_DrawPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags); void GL_DrawIndexedTriangles(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, unsigned int *IndexArray); void GL_Draw2DLine(F2DCoord *v1, F2DCoord *v2, RGBA_t Color); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index e106454aa..8919e3ed4 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5691,6 +5691,8 @@ extern "C" { // ========================================================================== static void HWR_RenderFrame(boolean skybox, boolean drawsky) { + GL_EnableStencilTest(); + // Clear view, set viewport (glViewport), set perspective... HWR_ClearView(); @@ -5721,6 +5723,8 @@ static void HWR_RenderFrame(boolean skybox, boolean drawsky) else HWR_RenderViewpoint(NULL, 0, !skybox); + GL_DisableStencilTest(); + // Check for new console commands. NetUpdate(); } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 1a8e2a8c4..518181f69 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1284,7 +1284,7 @@ void GL_SetStates(void) pglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - pglEnable(GL_STENCIL_TEST); + pglDisable(GL_STENCIL_TEST); pglEnable(GL_DEPTH_TEST); // check the depth buffer pglDepthMask(GL_TRUE); // enable writing to depth buffer pglClearDepth(1.0f); @@ -1314,6 +1314,16 @@ void GL_SetStates(void) #endif } +void GL_EnableStencilTest(void) +{ + pglEnable(GL_STENCIL_TEST); +} + +void GL_DisableStencilTest(void) +{ + pglDisable(GL_STENCIL_TEST); +} + // -----------------+ // DeleteTexture : Deletes a texture from the GPU and frees its data // -----------------+ From 2344552ba8b96f13287e9b6b60ecd1c53426c4f7 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 7 May 2026 16:26:30 +0200 Subject: [PATCH 308/589] Opengl: enable stencil testing only when portals are used maybe a bit of perf on non portal maps, prob neglible but why not --- src/hardware/hw_main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 8919e3ed4..7de18f756 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5691,7 +5691,11 @@ extern "C" { // ========================================================================== static void HWR_RenderFrame(boolean skybox, boolean drawsky) { - GL_EnableStencilTest(); + // NetUpdate below may cause this to be false midrender if toggled + const boolean useportals = HWR_UsePortals(); + + if (useportals) + GL_EnableStencilTest(); // Clear view, set viewport (glViewport), set perspective... HWR_ClearView(); @@ -5718,12 +5722,13 @@ static void HWR_RenderFrame(boolean skybox, boolean drawsky) NetUpdate(); portalclipline = NULL; - if (UNLIKELY(HWR_UsePortals())) + if (useportals) HWR_RenderViewpoint(NULL, 0, !skybox); else HWR_RenderViewpoint(NULL, 0, !skybox); - GL_DisableStencilTest(); + if (useportals) + GL_DisableStencilTest(); // Check for new console commands. NetUpdate(); From 1b3050028e182bbf68ce8c1c87f7a41997fa2091 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 8 May 2026 14:36:42 +0200 Subject: [PATCH 309/589] save a few mobjfloorz/ceilingz calls in some cases gave a small speedup on my test setup (+~3fps) on slopes those are rather expensive --- src/p_maputl.cpp | 14 +++++++++----- src/p_user.c | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 37b31c4ac..3bb205afa 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -823,16 +823,20 @@ void P_SetThingPosition(mobj_t *thing) // sector's floor is the same height. if (thing->player && oldsec != NULL && thing->subsector && oldsec != thing->subsector->sector) { - tfloorz = P_GetFloorZ(thing, ss->sector, thing->x, thing->y, NULL); - tceilz = P_GetCeilingZ(thing, ss->sector, thing->x, thing->y, NULL); - if (thing->eflags & MFE_VERTICALFLIP) { + tceilz = P_GetCeilingZ(thing, ss->sector, thing->x, thing->y, NULL); + if (thing->z + thing->height >= tceilz) thing->eflags |= MFE_JUSTSTEPPEDDOWN; } - else if (thing->z <= tfloorz) - thing->eflags |= MFE_JUSTSTEPPEDDOWN; + else + { + tfloorz = P_GetFloorZ(thing, ss->sector, thing->x, thing->y, NULL); + + if (thing->z <= tfloorz) + thing->eflags |= MFE_JUSTSTEPPEDDOWN; + } } } diff --git a/src/p_user.c b/src/p_user.c index 9eddcc36d..3b2f90dd7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1513,11 +1513,12 @@ static void P_CheckBouncySectors(player_t *player) continue; // this sector type is required for FOFs to be bouncy topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); - bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); if (player->mo->z > topheight) continue; + bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); + if (player->mo->z + player->mo->height < bottomheight) continue; From ce982d170fd8e80c2ad605d19073eeb7b010ace7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 8 May 2026 14:38:40 +0200 Subject: [PATCH 310/589] change "important" hook_state field to be bool type matches the others prob no diff in practice at all --- src/lua_hooklib.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index af15120ba..6294a5ab7 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -293,17 +293,17 @@ typedef struct Hook_State Hook_State; typedef void (*Hook_Callback)(Hook_State *); struct Hook_State { - INT32 status;/* return status to calling function */ - void * userdata; - int hook_type; - mobjtype_t mobj_type;/* Date: Sat, 9 May 2026 15:31:51 +0200 Subject: [PATCH 311/589] add "HAVE_IPV6" to passtrough compiler flags to allow compiling with ipv6 support to note this is unsupported from our side, as purely ipv6 servers are unreachable from vanilla clients --- src/Makefile.d/features.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk index b191ae2c1..410077939 100644 --- a/src/Makefile.d/features.mk +++ b/src/Makefile.d/features.mk @@ -8,6 +8,7 @@ passthru_opts+=\ HAVE_MINIUPNPC\ HAVE_DISCORDRPC DEVELOP\ NOHOLEPUNCH\ + HAVE_IPV6\ # build with debugging information ifdef DEBUGMODE From 9328825a7c93d9f191ee847eb8e727cff19b5b16 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 9 May 2026 19:50:15 +0200 Subject: [PATCH 312/589] fix potential null pointer deref in P_MobjFloorZ/CeilingZ dont think this ever really hit, but boundsec indeed can be null it also gets checked if its null above anyways, so why not here? --- src/p_mobj.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index cdc25a3e0..71dd21996 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -577,7 +577,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point - if (perfect) + if (perfect && boundsec) { size_t i; line_t *ld; @@ -666,7 +666,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point - if (perfect) + if (perfect && boundsec) { size_t i; line_t *ld; @@ -756,7 +756,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point - if (perfect) + if (perfect && boundsec) { size_t i; line_t *ld; @@ -845,7 +845,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point - if (perfect) + if (perfect && boundsec) { size_t i; line_t *ld; From 88116368bb2091dadbe8df392f9b144f65c6e72c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 9 May 2026 19:58:28 +0200 Subject: [PATCH 313/589] fix potential null pointer deref in P_LineOpening again ive never seen this hit, but the mobj gets checked right below its radius get dereferenced within the floorz/ceilingz functions which kinda annoyed me lol as a fallback i just the floor/ceiling sectorheights, which were used before the addition of slopes --- src/p_maputl.cpp | 101 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 31 deletions(-) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 3bb205afa..ebf4a08fa 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -423,40 +423,42 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // Set open and high/low values here fixed_t frontheight, backheight; - frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); - - if (frontheight < backheight) - { - opentop = frontheight; - highceiling = backheight; - opentopslope = front->c_slope; - } - else - { - opentop = backheight; - highceiling = frontheight; - opentopslope = back->c_slope; - } - - frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); - - if (frontheight > backheight) - { - openbottom = frontheight; - lowfloor = backheight; - openbottomslope = front->f_slope; - } - else - { - openbottom = backheight; - lowfloor = frontheight; - openbottomslope = back->f_slope; - } + I_Assert(mobj != NULL); if (mobj) { + frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); + + if (frontheight < backheight) + { + opentop = frontheight; + highceiling = backheight; + opentopslope = front->c_slope; + } + else + { + opentop = backheight; + highceiling = frontheight; + opentopslope = back->c_slope; + } + + frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); + + if (frontheight > backheight) + { + openbottom = frontheight; + lowfloor = backheight; + openbottomslope = front->f_slope; + } + else + { + openbottom = backheight; + lowfloor = frontheight; + openbottomslope = back->f_slope; + } + fixed_t thingtop = mobj->z + mobj->height; // Check for collision with front side's midtexture if Effect 4 is set @@ -650,6 +652,43 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) lowfloor = lowestfloor; } } + else + { + // this is what P_LineOpening did before the addition of slopes + // so i´ll just use it as the fallback case + // not that we will ever likely hit this + frontheight = front->ceilingheight; + backheight = back->ceilingheight; + + if (frontheight < backheight) + { + opentop = frontheight; + highceiling = backheight; + opentopslope = front->c_slope; + } + else + { + opentop = backheight; + highceiling = frontheight; + opentopslope = back->c_slope; + } + + frontheight = front->floorheight; + backheight = back->floorheight; + + if (frontheight > backheight) + { + openbottom = frontheight; + lowfloor = backheight; + openbottomslope = front->f_slope; + } + else + { + openbottom = backheight; + lowfloor = frontheight; + openbottomslope = back->f_slope; + } + } openrange = opentop - openbottom; } From 54f3d7b5e0e5817c18c6c9b5be1ec4b72bcc719b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 10 May 2026 16:33:12 +0200 Subject: [PATCH 314/589] move lua_tostring out of the loop in mapheaderinfo_get does not need to be reevaluated constantly --- src/lua_maplib.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 606d54383..279b02883 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1658,17 +1658,22 @@ static int mapheaderinfo_get(lua_State *L) { // Read custom vars now // (note: don't include the "LUA." in your lua scripts!) - UINT8 j = 0; - for (;j < header->numCustomOptions && !fastcmp(lua_tostring(L, 2), header->customopts[j].option); ++j); + if (!header->numCustomOptions) { + lua_pushnil(L); + break; + } - if(j < header->numCustomOptions) + UINT8 j = 0; + const char *cusoptstr = lua_tostring(L, 2); + for (;j < header->numCustomOptions && !fastcmp(cusoptstr, header->customopts[j].option); ++j); + + if (j < header->numCustomOptions) lua_pushstring(L, header->customopts[j].value); else lua_pushnil(L); } } return 1; - } int LUA_MapLib(lua_State *L) From 39fd31c4b93e5775dc0b454a2c3112c4e09b713c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 10 May 2026 20:15:24 +0200 Subject: [PATCH 315/589] p_mobj: potentially save a few more floor/ceiling z checks in some cases + some other crap --- src/p_mobj.c | 178 +++++++++++++++++++++++++++++---------------------- 1 file changed, 102 insertions(+), 76 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 71dd21996..b30e4ecd4 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -420,14 +420,18 @@ boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover) if (!(rover->flags & FF_EXISTS)) return false; - if ((((rover->flags & FF_BLOCKPLAYER) && mobj->player) - || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) + if ((((rover->flags & FF_BLOCKPLAYER) && mobj->player) || + ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) + return false; + + topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + + if (mobj->z > topheight) return false; - topheight = P_GetFFloorTopZAt (rover, mobj->x, mobj->y); bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); - if (mobj->z > topheight || (mobj->z + mobj->height < bottomheight)) + if (mobj->z + mobj->height < bottomheight) return false; return true; @@ -1420,7 +1424,7 @@ void P_XYMovement(mobj_t *mo) // blocked move moved = false; - if (player && player->bot) + if (UNLIKELY(player && player->bot)) { B_MoveBlocked(player); } @@ -1455,24 +1459,24 @@ void P_XYMovement(mobj_t *mo) else fx->eflags &= ~MFE_VERTICALFLIP; fx->scale = mo->scale; - } - if (mo->type == MT_ORBINAUT) // Orbinaut speed decreasing - { - if (mo->health > 1) + if (mo->type == MT_ORBINAUT) // Orbinaut speed decreasing { - S_StartSound(mo, mo->info->attacksound); - mo->health--; - mo->threshold = 0; - } - else if (mo->health == 1) - { - // This Item Damage - S_StartSound(mo, mo->info->deathsound); - P_KillMobj(mo, NULL, NULL); + if (mo->health > 1) + { + S_StartSound(mo, mo->info->attacksound); + mo->health--; + mo->threshold = 0; + } + else if (mo->health == 1) + { + // This Item Damage + S_StartSound(mo, mo->info->deathsound); + P_KillMobj(mo, NULL, NULL); - P_SetObjectMomZ(mo, 8*FRACUNIT, false); - P_InstaThrust(mo, R_PointToAngle2(mo->x, mo->y, mo->x, mo->y)+ANGLE_90, 16*FRACUNIT); + P_SetObjectMomZ(mo, 8*FRACUNIT, false); + P_InstaThrust(mo, R_PointToAngle2(mo->x, mo->y, mo->x, mo->y)+ANGLE_90, 16*FRACUNIT); + } } } //} @@ -1576,43 +1580,46 @@ void P_XYMovement(mobj_t *mo) if (P_MobjWasRemoved(mo)) // MF_SPECIAL touched a player! O_o;; return; - if (moved && oldslope) // Check to see if we ran off + if (moved) { - if (oldslope != mo->standingslope) // First, compare different slopes + if (oldslope) // Check to see if we ran off { - angle_t oldangle, newangle; - angle_t moveangle = R_PointToAngle2(0, 0, mo->momx, mo->momy); + if (oldslope != mo->standingslope) // First, compare different slopes + { + angle_t oldangle, newangle; + angle_t moveangle = R_PointToAngle2(0, 0, mo->momx, mo->momy); - oldangle = FixedMul((signed)oldslope->zangle, FINECOSINE((moveangle - oldslope->xydirection) >> ANGLETOFINESHIFT)); + oldangle = FixedMul((signed)oldslope->zangle, FINECOSINE((moveangle - oldslope->xydirection) >> ANGLETOFINESHIFT)); - if (mo->standingslope) - newangle = FixedMul((signed)mo->standingslope->zangle, FINECOSINE((moveangle - mo->standingslope->xydirection) >> ANGLETOFINESHIFT)); - else - newangle = 0; + if (mo->standingslope) + newangle = FixedMul((signed)mo->standingslope->zangle, FINECOSINE((moveangle - mo->standingslope->xydirection) >> ANGLETOFINESHIFT)); + else + newangle = 0; - // Now compare the Zs of the different quantizations - if (oldangle-newangle > ANG30 && oldangle-newangle < ANGLE_180) // Allow for a bit of sticking - this value can be adjusted later + // Now compare the Zs of the different quantizations + if (oldangle-newangle > ANG30 && oldangle-newangle < ANGLE_180) // Allow for a bit of sticking - this value can be adjusted later + { + mo->standingslope = oldslope; + P_SlopeLaunch(mo); + } + } + else if (predictedz-mo->z > abs(slopemom.z/2) // Sryder 2018-11-26: Don't launch here if it's a slope without physics, we stick to those like glue anyway + && !(mo->standingslope->flags & SL_NOPHYSICS)) // Now check if we were supposed to stick to this slope { - mo->standingslope = oldslope; P_SlopeLaunch(mo); } } - else if (predictedz-mo->z > abs(slopemom.z/2) // Sryder 2018-11-26: Don't launch here if it's a slope without physics, we stick to those like glue anyway - && !(mo->standingslope->flags & SL_NOPHYSICS)) // Now check if we were supposed to stick to this slope + else if (mo->standingslope && predictedz) { - P_SlopeLaunch(mo); - } - } - else if (moved && mo->standingslope && predictedz) - { - angle_t moveangle = R_PointToAngle2(0, 0, mo->momx, mo->momy); - angle_t newangle = FixedMul((signed)mo->standingslope->zangle, FINECOSINE((moveangle - mo->standingslope->xydirection) >> ANGLETOFINESHIFT)); + angle_t moveangle = R_PointToAngle2(0, 0, mo->momx, mo->momy); + angle_t newangle = FixedMul((signed)mo->standingslope->zangle, FINECOSINE((moveangle - mo->standingslope->xydirection) >> ANGLETOFINESHIFT)); - if (ANGLE_MAX-newangle > ANG30 && newangle > ANGLE_180) - { - mo->momz = P_MobjFlip(mo)*FRACUNIT/2; - mo->z = predictedz + P_MobjFlip(mo); - mo->standingslope = NULL; + if (ANGLE_MAX-newangle > ANG30 && newangle > ANGLE_180) + { + mo->momz = P_MobjFlip(mo)*FRACUNIT/2; + mo->z = predictedz + P_MobjFlip(mo); + mo->standingslope = NULL; + } } } @@ -1821,7 +1828,7 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec) while (po) { - if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) + if (!(po->flags & POF_SOLID) || !P_MobjInsidePolyobj(po, mo)) { po = (polyobj_t *)(po->link.next); continue; @@ -2733,6 +2740,7 @@ static boolean P_SceneryZMovement(mobj_t *mo) P_RemoveMobj(mo); return false; } + if ((!(mo->eflags & MFE_VERTICALFLIP) && mo->z <= mo->floorz) || (mo->eflags & MFE_VERTICALFLIP && mo->z+mo->height >= mo->ceilingz)) // Hit the floor, so split! { @@ -2770,6 +2778,7 @@ static boolean P_SceneryZMovement(mobj_t *mo) P_RemoveMobj(mo); return false; } + // Soniccd seed turns into a flower! if ((!(mo->eflags & MFE_VERTICALFLIP) && mo->z <= mo->floorz) || (mo->eflags & MFE_VERTICALFLIP && mo->z+mo->height >= mo->ceilingz)) @@ -2880,22 +2889,29 @@ void P_MobjCheckWater(mobj_t *mobj) || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) continue; - topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); - bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); + fixed_t topcheck, bottomcheck; if (mobj->eflags & MFE_VERTICALFLIP) { - if (topheight < (thingtop - FixedMul(mobj->info->height/2, mobj->scale)) - || bottomheight > thingtop) - continue; + topcheck = (thingtop - FixedMul(mobj->info->height/2, mobj->scale)); + bottomcheck = thingtop; } else { - if (topheight < mobj->z - || bottomheight > (mobj->z + FixedMul(mobj->info->height/2, mobj->scale))) - continue; + topcheck = mobj->z; + bottomcheck = (mobj->z + FixedMul(mobj->info->height/2, mobj->scale)); } + topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + + if (topheight < topcheck) + continue; + + bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); + + if (bottomheight > bottomcheck) + continue; + // Set the watertop and waterbottom mobj->watertop = topheight; mobj->waterbottom = bottomheight; @@ -3101,11 +3117,14 @@ static void P_SceneryCheckWater(mobj_t *mobj) if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKOTHERS) continue; - topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + + if (topheight <= mobj->z) + continue; + bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); - if (topheight <= mobj->z - || bottomheight > (mobj->z + FixedMul(mobj->info->height >> 1, mobj->scale))) + if (bottomheight > (mobj->z + FixedMul(mobj->info->height >> 1, mobj->scale))) continue; if (mobj->z + FixedMul(mobj->info->height, mobj->scale) > topheight) @@ -3422,19 +3441,25 @@ static void P_PlayerMobjThinker(mobj_t *mobj) // Crumbling platforms for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) { - fixed_t topheight, bottomheight; ffloor_t *rover; for (rover = node->m_sector->ffloors; rover; rover = rover->next) { + boolean oncrumble; + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_CRUMBLE)) continue; - topheight = P_GetSpecialTopZ(mobj, sectors + rover->secnum, node->m_sector); - bottomheight = P_GetSpecialBottomZ(mobj, sectors + rover->secnum, node->m_sector); + if (mobj->eflags & MFE_VERTICALFLIP) + { + oncrumble = P_GetSpecialBottomZ(mobj, sectors + rover->secnum, node->m_sector) == mobj->z + mobj->height; // You nut. + } + else + { + oncrumble = P_GetSpecialTopZ(mobj, sectors + rover->secnum, node->m_sector) == mobj->z; + } - if ((topheight == mobj->z && !(mobj->eflags & MFE_VERTICALFLIP)) - || (bottomheight == mobj->z + mobj->height && mobj->eflags & MFE_VERTICALFLIP)) // You nut. + if (oncrumble) EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), mobj->player, rover->alpha, !(rover->flags & FF_NORETURN)); } } @@ -3537,11 +3562,9 @@ animonly: static void P_CalculatePrecipFloor(precipmobj_t *mobj) { // recalculate floorz each time - const sector_t *sec; + const sector_t *sec = (mobj && mobj->subsector) ? mobj->subsector->sector : NULL; - if (mobj && mobj->subsector && mobj->subsector->sector) - sec = mobj->subsector->sector; - else + if (!sec) return; mobj->floorz = P_GetSectorFloorZAt(sec, mobj->x, mobj->y); @@ -3636,7 +3659,9 @@ boolean P_PrecipThinker(precipmobj_t *mobj) // only recalc this twice a second (doubt anyone will notice this lulul) if ((leveltime % (TICRATE/2)) == 0) + { P_CalculatePrecipFloor(mobj); + } // adjust height if ((mobj->z += mobj->momz) <= mobj->floorz) @@ -4299,7 +4324,7 @@ static void P_Boss4PopSpikeballs(mobj_t *mobj) { mobj_t *base = mobj->tracer, *seg, *next; P_SetTarget(&mobj->tracer, NULL); - while(base) + while (base) { next = base->tracer; P_SetTarget(&base->tracer, NULL); @@ -9023,7 +9048,7 @@ void P_MobjThinker(mobj_t *mobj) I_Assert(mobj != NULL); I_Assert(!P_MobjWasRemoved(mobj)); - if (UNLIKELY(mobj->flags & MF_NOTHINK)) + if (mobj->flags & MF_NOTHINK) return; // Remove dead target/tracer. @@ -9284,12 +9309,13 @@ void P_PushableThinker(mobj_t *mobj) x = mobj->spawnpoint->x << FRACBITS; y = mobj->spawnpoint->y << FRACBITS; - ss = R_PointInSubsector(x, y); - if (mobj->spawnpoint->z != 0) z = mobj->spawnpoint->z << FRACBITS; else + { + ss = R_PointInSubsector(x, y); z = ss->sector->floorheight; + } spawnmo = P_SpawnMobj(x, y, z, mobj->type); if (spawnmo) @@ -10270,7 +10296,7 @@ void P_SpawnPrecipitation(void) if (curWeather == PRECIP_BLANK) rainmo->precipflags |= PCF_INVISIBLE; - floorz = rainmo->floorz >> FRACBITS; + floorz = rainmo->floorz >> FRACBITS; ceilingz = rainmo->ceilingz >> FRACBITS; if (floorz < ceilingz) @@ -10337,8 +10363,6 @@ void P_PrecipitationEffects(void) return; } - boolean sounds_rain = ((cv_drawdist_precip.value != 0) && rainsfx && (!leveltime || leveltime % 80 == 1)); - // Currently thunderstorming with lightning, and we're sounding the thunder... // and where there's thunder, there's gotta be lightning! if (effects_lightning && lightningStrike) @@ -10360,6 +10384,8 @@ void P_PrecipitationEffects(void) if (sound_disabled) return; // Sound off? D'aw, no fun. + const boolean sounds_rain = ((cv_drawdist_precip.value != 0) && rainsfx && (!leveltime || leveltime % 80 == 1)); + if (!sounds_rain && !sounds_thunder) return; // no need to calculate volume at ALL @@ -11848,8 +11874,6 @@ void P_SpawnHoops(mapthing_t *mthing) x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; - sec = R_PointInSubsector(x, y)->sector; - // Save our flags! if (mthing->type == 1713) z = (mthing->options >> ZSHIFT) << FRACBITS; @@ -11861,6 +11885,8 @@ void P_SpawnHoops(mapthing_t *mthing) if (P_MobjWasRemoved(hoopcenter)) return; + sec = R_PointInSubsector(x, y)->sector; + hoopcenter->spawnpoint = mthing; z += P_GetSectorFloorZAt(sec, x, y); From a868844bdf0c2ac42e483d1f7bd02631309a94fa Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 10 May 2026 20:14:28 +0200 Subject: [PATCH 316/589] remove outdated comment about precipmobj --- src/d_netcmd.c | 1 - src/p_mobj.h | 4 ---- src/p_slopes.c | 3 ++- src/p_user.c | 3 ++- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 76495a09e..42f14f3cc 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5816,7 +5816,6 @@ static void BaseNumLaps_OnChange(void) } } - static void KartFrantic_OnChange(void) { if ((boolean)cv_kartfrantic.value != franticitems && gamestate == GS_LEVEL && leveltime > starttime) diff --git a/src/p_mobj.h b/src/p_mobj.h index 892ffdad4..682b2fb1b 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -421,10 +421,6 @@ typedef struct mobj_s // // For precipitation // -// Sometimes this is casted to a mobj_t, -// so please keep the start of the -// structure the same. -// typedef struct precipmobj_s { // List: thinker links. diff --git a/src/p_slopes.c b/src/p_slopes.c index 627052236..ac3a56c17 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -166,7 +166,8 @@ static void P_ReconfigureVertexSlope(pslope_t *slope) slope->real_xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180; slope->real_zangle = InvAngle(R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta)); - if (slope->normal.x == 0 && slope->normal.y == 0) // Set some defaults for a non-sloped "slope" + // Set some defaults for a non-sloped "slope" + if (slope->normal.x == 0 && slope->normal.y == 0) { slope->zangle = slope->xydirection = 0; slope->zdelta = slope->d.x = slope->d.y = 0; diff --git a/src/p_user.c b/src/p_user.c index 3b2f90dd7..ae5983935 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1393,7 +1393,8 @@ static void P_CheckBustableBlocks(player_t *player) for (rover = node->m_sector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS)) continue; + if (!(rover->flags & FF_EXISTS)) + continue; if ((rover->flags & FF_BUSTUP)/* && !rover->master->frontsector->crumblestate*/) { From d6946d4d4455b6c464698d6f47bc77869ca8ee0f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 May 2026 15:07:51 +0200 Subject: [PATCH 317/589] fix HWR_RenderPolyObjectPlane smol oopsie that was supposed to be float fixes the rotating skybox thing in Zero Space --- src/hardware/hw_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 7de18f756..2587055c5 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2673,7 +2673,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, float anglef = 0.0f, cosangf = 0.0f, sinangf = 0.0f; angle_t angle = 0; FSurfaceInfo Surf = {}; - fixed_t tempxsow, tempytow; + float tempxsow, tempytow; size_t nrPlaneVerts; static FOutVector *planeVerts = NULL; From 9aaa7cc5bff21d25765b403d8485d72febfde57e Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 12 May 2026 03:52:56 +0300 Subject: [PATCH 318/589] Don't break non-string keys in ArchiveTables when printing error message --- src/lua_script.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index 8e07f87e3..2649a57c7 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1065,8 +1065,9 @@ static void ArchiveTables(UINT8 **p) n++; // the table contained a new table we'll have to archive. :( else if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise) { - CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i); - lua_pop(gL, 1); + lua_pushvalue(gL, -2); // copy key for error message (lua_tostring may mutate it which confuses lua_next) + CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -1), luaL_typename(gL, -1), i); + lua_pop(gL, 2); // pop key copy and value continue; } else if (e == 3) // nil key due to invalid userdata. NOT an error. @@ -1080,7 +1081,11 @@ static void ArchiveTables(UINT8 **p) if (e == 1) n++; // the table contained a new table we'll have to archive. :( else if (e == 2) // invalid value type - CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1)); + { + lua_pushvalue(gL, -2); // copy key for error message (same as above) + CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -1), luaL_typename(gL, -2)); + lua_pop(gL, 1); // pop key copy + } lua_pop(gL, 1); } From 6aabdc86c0e01fec78c2a418e9df209826360e54 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 12 May 2026 15:02:44 +0200 Subject: [PATCH 319/589] P_TryMove: reduce the amount of R_PointInSubsector per call and also P_PlayerTouchingSectorSpecial since either are in a loop that often runs multiple times per call improves perf a bit per usual testing --- src/p_floor.c | 1 - src/p_map.c | 33 ++++++++++++++++++--------------- src/p_mobj.c | 2 +- src/p_spec.c | 3 ++- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index bd7a2655e..ef42b02a3 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1894,7 +1894,6 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies) { if (nobaddies->sector->lines[i]->special == 223) { - upperbound = nobaddies->sector->ceilingheight; lowerbound = nobaddies->sector->floorheight; diff --git a/src/p_map.c b/src/p_map.c index 10b55f65b..1befc4933 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2373,6 +2373,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) fixed_t radius = thing->radius; fixed_t thingtop ;//= thing->z + thing->height; fixed_t startingonground = P_IsObjectOnGround(thing); + INT32 special = -1; floatok = false; if (radius < MAXRADIUS/2) @@ -2406,21 +2407,31 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (!(thing->flags & MF_NOCLIP)) { - //All things are affected by their scale. - fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale); - INT32 special = 0; + // All things are affected by their scale. + fixed_t maxstep; + + if (tmceilingz - tmfloorz < thing->height) + { + if (tmfloorthing) + tmhitthing = tmfloorthing; + + return false; // doesn't fit + } + + maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale); if (thing->player) { - special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1); + if (special == -1) + special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1); // If using type Section1:13, double the maxstep. - if (P_PlayerTouchingSectorSpecial(thing->player, 1, 13) || special == 13) + if (special == 13 || P_PlayerTouchingSectorSpecial(thing->player, 1, 13)) { maxstep <<= 1; } // If using type Section1:12, no maxstep. For ledges you don't want the player to climb! (see: Egg Zeppelin & SMK port walls) - else if (P_PlayerTouchingSectorSpecial(thing->player, 1, 12) || special == 12) + else if (special == 12 || P_PlayerTouchingSectorSpecial(thing->player, 1, 12)) { maxstep = 0; } @@ -2431,14 +2442,6 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) maxstep = 0; } - if (tmceilingz - tmfloorz < thing->height) - { - if (tmfloorthing) - tmhitthing = tmfloorthing; - - return false; // doesn't fit - } - floatok = true; thingtop = thing->z + thing->height; @@ -2469,7 +2472,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) } } else if (maxstep > 0 && !(thing->player && - (P_PlayerTouchingSectorSpecial(thing->player, 1, 14) || special == 14))) // Step down + (special == 14 || P_PlayerTouchingSectorSpecial(thing->player, 1, 14)))) // Step down { // If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS // step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more. diff --git a/src/p_mobj.c b/src/p_mobj.c index b30e4ecd4..614797247 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1828,7 +1828,7 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec) while (po) { - if (!(po->flags & POF_SOLID) || !P_MobjInsidePolyobj(po, mo)) + if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) { po = (polyobj_t *)(po->link.next); continue; diff --git a/src/p_spec.c b/src/p_spec.c index 919be8031..605a34861 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4441,12 +4441,13 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) } f_affectpoint = P_GetSpecialBottomZ(player->mo, sector, sector); - c_affectpoint = P_GetSpecialTopZ(player->mo, sector, sector); // Only go further if on the ground if ((sector->flags & SF_FLIPSPECIAL_FLOOR) && !(sector->flags & SF_FLIPSPECIAL_CEILING) && player->mo->z != f_affectpoint) return; + c_affectpoint = P_GetSpecialTopZ(player->mo, sector, sector); + if ((sector->flags & SF_FLIPSPECIAL_CEILING) && !(sector->flags & SF_FLIPSPECIAL_FLOOR) && player->mo->z + player->mo->height != c_affectpoint) return; From 55a57a10368b60a5dbe558d077c5d1c7e509bf2f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 12 May 2026 20:48:30 +0200 Subject: [PATCH 320/589] fix checking for fbo completeness too early this should come after everything apparently all this shit really needs to be cleaned up again --- src/hardware/r_opengl/r_opengl.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 518181f69..c8d60871b 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3260,14 +3260,6 @@ static void GL_Framebuffer_Generate(void) if (!framebufferobject.fboobj) pglGenFramebuffers(1, &framebufferobject.fboobj); - if (pglCheckFramebufferStatus(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) - { - // if this fails, dont retry it a gazillion times - // this wouldnt recover - supportFBO = false; - return; - } - // Bind the framebuffer pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj); @@ -3319,6 +3311,18 @@ static void GL_Framebuffer_Generate(void) pglBindRenderbuffer(GL_RENDERBUFFER_EXT, 0); } + if (pglCheckFramebufferStatus(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) + { + //pglGetError(); TODO:implement this or smth + GL_MSG_Error("GL_Framebuffer_Generate: Failed to create Framebuffer Object"); + + // if this fails, dont retry it a gazillion times + // this wouldnt recover + supportFBO = false; + pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); + return; + } + // Unbind the framebuffer pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); @@ -3341,6 +3345,10 @@ void GL_Framebuffer_Enable(void) GL_Framebuffer_Generate(); + // failed + if (!supportFBO || !framebufferobject.init) + return; + pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj); pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.rboobj); } From 2ce4e866e33de86a5e0d6b8a8a66a1c53b6c60a9 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 14 May 2026 18:53:52 +0200 Subject: [PATCH 321/589] reorder seg_t struct a bit fixes a 4byte hole so we can fit everything important into cacheline 1 even when compiled without HWRENDER this should be a better layout checked per pahole --- src/r_defs.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/r_defs.h b/src/r_defs.h index e6c5866c6..217314028 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -531,11 +531,10 @@ typedef struct seg_s vertex_t *v1; vertex_t *v2; - INT32 side; - - fixed_t offset; - - angle_t angle; +#ifdef HWRENDER + floatvertex_t fv1; // v1 in floats - precalculated + floatvertex_t fv2; // v2 in floats - precalculated +#endif side_t *sidedef; line_t *linedef; @@ -545,11 +544,13 @@ typedef struct seg_s sector_t *frontsector; sector_t *backsector; + INT32 side; + fixed_t length; // precalculated seg length -#ifdef HWRENDER - floatvertex_t fv1; // v1 in floats - precalculated - floatvertex_t fv2; // v2 in floats - precalculated -#endif + fixed_t offset; + + angle_t angle; + polyobj_t *polyseg; // Fake contrast calculated on level load From e113027ce6799060e7e7b82efc7aae0e8e2a6c78 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 14 May 2026 21:11:45 +0200 Subject: [PATCH 322/589] d_netcmd: fix snacpending stuff also move all of it behind PARANOIA define, since nothing else was using it eitherway --- src/d_netcmd.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 42f14f3cc..7501234d7 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1496,7 +1496,9 @@ static void ForceAllSkins(INT32 forcedskin) } static INT32 chmappending; +#ifdef PARANOIA static INT32 snacpending[MAXSPLITSCREENPLAYERS]; +#endif // wonky compat, idk if anything uses this.... #define playerisbot (splitplayer == 1 && botingame) @@ -1596,7 +1598,9 @@ static void SendNameAndColor(UINT8 splitplayer) return; } +#ifdef PARANOIA snacpending[splitplayer]++; +#endif // Don't change name if muted if (player_name_changes[pnum] >= MAXNAMECHANGES) @@ -1632,7 +1636,7 @@ static void SendNameAndColor(UINT8 splitplayer) static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) { - player_t *player = &players[playernum]; + player_t *player; char name[MAXPLAYERNAME+1] = {}; UINT8 color, skin; @@ -1641,14 +1645,18 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) I_Error("There is no player %d!", playernum); #endif + player = &players[playernum]; + +#ifdef PARANOIA if (P_IsLocalPlayer(player)) { - snacpending[playernum]--; -#ifdef PARANOIA - if (snacpending[playernum] < 0) + const INT32 localpnum = P_GetLocalPlayerNumForPlayer(player); + snacpending[localpnum]--; + + if (snacpending[localpnum] < 0) I_Error("snacpending negative!"); -#endif } +#endif READSTRINGN(*cp, name, MAXPLAYERNAME); color = READUINT8(*cp); @@ -2189,7 +2197,6 @@ void D_SetupVote(void) WRITEUINT8(p, secondgt); secondgt &= ~0x80; - for (i = 0; i < 4; i++) { UINT16 m; From e75a696ee55dbce8e92570c21174abe9b1a94dff Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 15 May 2026 01:06:04 +0300 Subject: [PATCH 323/589] Remove outdated PARANOIA assert in P_SetMobjState, it uses P_SetPlayerMobjState automatically for players now --- src/p_mobj.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 614797247..e740dfc94 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -222,11 +222,6 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) INT32 recursion = 0; -#ifdef PARANOIA - if (mobj->player != NULL) - I_Error("P_SetMobjState used for player mobj. Use P_SetPlayerMobjState instead!\n(State called: %d)", state); -#endif - if (mobj->player != NULL) return P_SetPlayerMobjState(mobj, state); From a28d79818927adc505fc9337400c67b61ce1cb1a Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 15 May 2026 01:24:14 +0300 Subject: [PATCH 324/589] Remove some redundant mo != NULL asserts if they are followed by !P_MobjWasRemoved(mo) asserts --- src/k_kart.c | 7 ------- src/p_enemy.c | 2 -- src/p_maputl.cpp | 4 ---- src/p_mobj.c | 20 -------------------- src/p_user.c | 1 - 5 files changed, 34 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f7fdba2ad..eed4ebfed 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1603,7 +1603,6 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) fixed_t flr, cel; // floor & ceiling for height checks to make sure we're touching the offroad sector. INT32 special; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) @@ -1743,7 +1742,6 @@ static void K_SpawnDashDustRelease(player_t *player) INT32 i; I_Assert(player != NULL); - I_Assert(player->mo != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); if (!player->speed && !player->kartstuff[k_startboost]) @@ -1781,7 +1779,6 @@ static void K_SpawnBrakeDriftSparks(player_t *player) // Be sure to update the m mobj_t *sparks; I_Assert(player != NULL); - I_Assert(player->mo != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); // Position & etc are handled in its thinker, and its spawned invisible. @@ -3181,7 +3178,6 @@ static void K_SpawnDriftSparks(player_t *player) INT32 i; I_Assert(player != NULL); - I_Assert(player->mo != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); if (leveltime % 2 == 1) @@ -3553,7 +3549,6 @@ void K_SpawnBoostTrail(player_t *player) INT32 i; I_Assert(player != NULL); - I_Assert(player->mo != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); if (!P_IsObjectOnGround(player->mo) @@ -3635,7 +3630,6 @@ void K_SpawnSparkleTrail(mobj_t *mo) mobj_t *sparkle; INT32 i; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); const boolean shouldblend = (mo->player && K_PlayerEffectsShouldBlend(mo->player)); @@ -3669,7 +3663,6 @@ mobj_t *K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) mobj_t *dust; angle_t aoff; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); if (mo->player) diff --git a/src/p_enemy.c b/src/p_enemy.c index f1a0ed535..15410747a 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -306,7 +306,6 @@ void P_NewChaseDir(mobj_t *actor) dirtype_t d[3]; dirtype_t tdir = DI_NODIR, olddir, turnaround; - I_Assert(actor->target != NULL); I_Assert(!P_MobjWasRemoved(actor->target)); olddir = actor->movedir; @@ -619,7 +618,6 @@ void A_Chase(void *thing) if (LUA_CallAction(A_CHASE, actor)) return; - I_Assert(actor != NULL); I_Assert(!P_MobjWasRemoved(actor)); if (actor->reactiontime) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index ebf4a08fa..592f57e92 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -423,8 +423,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // Set open and high/low values here fixed_t frontheight, backheight; - I_Assert(mobj != NULL); - if (mobj) { frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); @@ -707,7 +705,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // void P_UnsetThingPosition(mobj_t *thing) { - I_Assert(thing != NULL); I_Assert(!P_MobjWasRemoved(thing)); if (!(thing->flags & MF_NOSECTOR)) @@ -811,7 +808,6 @@ void P_SetThingPosition(mobj_t *thing) sector_t *oldsec = NULL; fixed_t tfloorz, tceilz; - I_Assert(thing != NULL); I_Assert(!P_MobjWasRemoved(thing)); if (thing->player && thing->z <= thing->floorz && thing->subsector) diff --git a/src/p_mobj.c b/src/p_mobj.c index e740dfc94..d9b4a08ba 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -334,7 +334,6 @@ void P_ExplodeMissile(mobj_t *mo) { mobj_t *explodemo; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); mo->momx = mo->momy = mo->momz = 0; @@ -948,7 +947,6 @@ fixed_t P_GetMobjGravity(mobj_t *mo) boolean goopgravity = false; boolean wasflip; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); wasflip = (mo->eflags & MFE_VERTICALFLIP) != 0; @@ -1121,7 +1119,6 @@ void P_CheckGravity(mobj_t *mo, boolean affect) // static void P_SceneryXYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) { - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); const fixed_t fric_scale = FixedMul(FRACUNIT/32, mo->scale); @@ -1165,7 +1162,6 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) { player_t *player; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); player = mo->player; @@ -1217,7 +1213,6 @@ static void P_PushableCheckBustables(mobj_t *mo) fixed_t oldx; fixed_t oldy; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); if (netgame && mo->player && mo->player->spectator) @@ -1336,7 +1331,6 @@ void P_XYMovement(mobj_t *mo) vector3_t slopemom = {0, 0, 0}; fixed_t predictedz = 0; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); // if it's stopped @@ -1690,7 +1684,6 @@ void P_XYMovement(mobj_t *mo) static void P_RingXYMovement(mobj_t *mo) { - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); if (!P_SceneryTryMove(mo, mo->x + mo->momx, mo->y + mo->momy)) @@ -1701,7 +1694,6 @@ static void P_SceneryXYMovement(mobj_t *mo) { fixed_t oldx, oldy; // reducing bobbing/momentum on ice when up against walls - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); oldx = mo->x; @@ -1739,7 +1731,6 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp fixed_t delta1, delta2, thingtop; fixed_t topheight, bottomheight; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); thingtop = mo->z + mo->height; @@ -1816,7 +1807,6 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec) fixed_t delta1, delta2, thingtop; fixed_t polytop, polybottom; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); thingtop = mo->z + mo->height; @@ -1860,7 +1850,6 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec) static void P_RingZMovement(mobj_t *mo) { - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); // Intercept the stupid 'fall through 3dfloors' bug @@ -1895,7 +1884,6 @@ static void P_RingZMovement(mobj_t *mo) boolean P_CheckDeathPitCollide(mobj_t *mo) { - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); const INT32 secspecial = GETSECSPECIAL(mo->subsector->sector->special, 1); @@ -1912,7 +1900,6 @@ boolean P_CheckDeathPitCollide(mobj_t *mo) boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover) { - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3 @@ -1931,7 +1918,6 @@ static boolean P_ZMovement(mobj_t *mo) { fixed_t dist, delta; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); // Intercept the stupid 'fall through 3dfloors' bug @@ -2388,7 +2374,6 @@ static boolean P_ZMovement(mobj_t *mo) static void P_PlayerZMovement(mobj_t *mo) { - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); if (!mo->player) @@ -3384,7 +3369,6 @@ static void P_PlayerMobjThinker(mobj_t *mobj) { msecnode_t *node; - I_Assert(mobj != NULL); I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); @@ -9040,7 +9024,6 @@ static void P_FiringThink(mobj_t *mobj) // void P_MobjThinker(mobj_t *mobj) { - I_Assert(mobj != NULL); I_Assert(!P_MobjWasRemoved(mobj)); if (mobj->flags & MF_NOTHINK) @@ -9144,7 +9127,6 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->fuse && !P_FuseThink(mobj)) return; - I_Assert(mobj != NULL); I_Assert(!P_MobjWasRemoved(mobj)); if (mobj->momx || mobj->momy || (mobj->flags2 & MF2_SKULLFLY)) @@ -9240,7 +9222,6 @@ boolean P_RailThinker(mobj_t *mobj) { fixed_t x, y, z; - I_Assert(mobj != NULL); I_Assert(!P_MobjWasRemoved(mobj)); x = mobj->x, y = mobj->y, z = mobj->z; @@ -9266,7 +9247,6 @@ void P_PushableThinker(mobj_t *mobj) { sector_t *sec; - I_Assert(mobj != NULL); I_Assert(!P_MobjWasRemoved(mobj)); if (!mobj) diff --git a/src/p_user.c b/src/p_user.c index ae5983935..9df7d2735 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2112,7 +2112,6 @@ void P_ElementalFireTrail(player_t *player) INT32 i; I_Assert(player != NULL); - I_Assert(player->mo != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); if (player->mo->eflags & MFE_VERTICALFLIP) From 459beeb000ffbb768d36f427fc9b5e25bdb8f15e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 00:36:22 +0200 Subject: [PATCH 325/589] fix oopsie from https://github.com/Indev450/SRB2Kart-Saturn/commit/093ed023ef36bb2e8608116ef39d7710366ccf84 --- src/d_clisrv.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2228eb172..fb163acfa 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1485,12 +1485,13 @@ static void CL_DrawConnectionStatus(void) { UINT32 dldlength = 0; UINT32 totaldldsize = 0; - UINT32 totalfileslength = filedownload.totalsize; + UINT32 totalfileslength = 0; static char tempname[28]; fileneeded_t *file = &fileneeded[filedownload.current]; char *filename = file->filename; UINT32 totalsize = file->totalsize; UINT32 currentsize = min(file->currentsize, totalsize); + UINT32 fdtotalsize = filedownload.totalsize; // Draw the bottom box. M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); @@ -1541,18 +1542,18 @@ static void CL_DrawConnectionStatus(void) totaldldsize = filedownload.completedsize; V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP|MENUCAPS, "Overall Download Progress"); - if (totalfileslength != 0) - totalfileslength = (UINT32)((totaldldsize/(double)totalfileslength) * 256); + if (fdtotalsize != 0) + totalfileslength = (UINT32)((totaldldsize/(double)fdtotalsize) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, (INT32)totalfileslength, 8, 160); - if (totalfileslength>>20 >= 10) // display in MB if over 10MB + if ((fdtotalsize>>20) >= 10) // display in MB if over 10MB V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uM/%4uM", (INT32)(totaldldsize>>20), (INT32)(totalfileslength>>20))); + va(" %4uM/%4uM", (INT32)(totaldldsize>>20), (INT32)(fdtotalsize>>20))); else V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uK/%4uK", (INT32)(totaldldsize>>10), (INT32)(totalfileslength>>10))); + va(" %4uK/%4uK", (INT32)(totaldldsize>>10), (INT32)(fdtotalsize>>10))); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va("%2u/%2u Files ", filedownload.completednum, filedownload.totalnum)); From b652d802f5927f4b5efe253b99c4bb4773fbcfa7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 01:08:53 +0200 Subject: [PATCH 326/589] blua: fix copy paste error for "slow path" in auxgetstr/lua_getfield lets hope this fixes the random crashes from gc sometime stimky from https://github.com/Indev450/SRB2Kart-Saturn/pull/223/changes/e4e51f0f80fb7deb9213c72bb374d0a7e4c3f03b --- src/blua/lapi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index bca24a90f..e494e9fc9 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -526,13 +526,12 @@ static void auxgetstr (lua_State *L, TValue *t, const char *k) { api_checkvalidindex(L, t); if (luaV_fastget(L, t, str, slot, luaH_getstr)) { setobj2s(L, L->top, slot); - api_incr_top(L); } else { setsvalue(L, &key, str); - luaV_finishget(L, t, L->top, L->top, slot); - api_incr_top(L); + luaV_finishget(L, t, &key, L->top, slot); } + api_incr_top(L); lua_unlock(L); } From 24c9f88262efba801c2e272c81bfb0f5be1ed41d Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 01:27:55 +0200 Subject: [PATCH 327/589] make snacpending error print player number bit more informative :chaosleep: --- src/d_netcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7501234d7..7121c3e6b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1654,7 +1654,7 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) snacpending[localpnum]--; if (snacpending[localpnum] < 0) - I_Error("snacpending negative!"); + I_Error("snacpending negative for player %d!", localpnum); } #endif From 3d9d14b353abbf5b3a41a3e31eeff1d120b74357 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 18 Mar 2024 19:24:42 +0000 Subject: [PATCH 328/589] EnsurePlayerNameIsGood: Remove trailing whitespace, instead of just failing on it Interesting error with its recursive duplication resolving exposed by the previous commit! --- src/d_netcmd.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7121c3e6b..a0ee1607c 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1214,13 +1214,22 @@ static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum) if (len == 0 || len > MAXPLAYERNAME) return false; // Empty or too long. - if (name[0] == ' ' || name[len-1] == ' ') - return false; // Starts or ends with a space. + if (name[0] == ' ') + return false; // Starts with a space. if (isdigit(name[0])) return false; // Starts with a digit. if (name[0] == '@' || name[0] == '~') return false; // Starts with an admin symbol. + // Clean up trailing whitespace. + while (len && name[len-1] == ' ') + { + name[len-1] = '\0'; + len--; + } + if (len == 0) + return false; + // Check if it contains a non-printing character. // Note: ANSI C isprint() considers space a printing character. // Also don't allow semicolons, since they are used as From 83a60ea8577405b71193afebdcaae062b6bcb08b Mon Sep 17 00:00:00 2001 From: toaster Date: Tue, 30 Nov 2021 21:24:00 +0000 Subject: [PATCH 329/589] Some fixes for bad player info on joining servers. * Don't overwrite the first player's name when joining with multiple local splitscreen players. (resolves #151) * The defaults for unprovided names are now consistently "Player A/B/C/D" as opposed to some being letter-based and some being number-based. * Send local player info once per local splitscreen player, rather than n^2 times (where n is the number of local splitscreen players). * Since the packet *requires* four names to be sent every time you join a server, send dummy names for local splitscreen players who aren't connecting, instead of your actual cvars (no data leakage you didn't ask for!) --- src/d_clisrv.c | 4 ++-- src/d_netcmd.c | 50 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index fb163acfa..e29a559d1 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2200,7 +2200,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXPLAYERS; i++) { LUA_InvalidatePlayer(&players[i]); - sprintf(player_names[i], "Player %d", i + 1); + sprintf(player_names[i], "Player %c", 'A' + i); } CL_LoadReceivedSavegame(true); @@ -4436,7 +4436,7 @@ void SV_ResetServer(void) for (i = 0; i < MAXPLAYERS; i++) { LUA_InvalidatePlayer(&players[i]); - sprintf(player_names[i], "Player %d", i + 1); + sprintf(player_names[i], "Player %c", 'A' + i); } memset(player_name_changes, 0, sizeof(player_name_changes)); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a0ee1607c..8fbac60a6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1282,7 +1282,8 @@ static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum) * is restored to what it was before. * * We assume that if playernum is ::consoleplayer or ::secondarydisplayplayer - * the console variable ::cv_playername or ::cv_playername2 respectively is + * (unless clientjoin is true, a necessary evil) + * the console variable ::cv_playername to ::cv_playername4 respectively is * already set to newname. However, the player name table is assumed to * contain the old name. * @@ -1302,6 +1303,10 @@ static void CleanupPlayerName(INT32 playernum, const char *newname) char *tmpname = NULL; INT32 i; boolean namefailed = true; + boolean clientjoin = !!(playernum >= MAXPLAYERS); + + if (clientjoin) + playernum -= MAXPLAYERS; buf = Z_StrDup(newname); @@ -1358,17 +1363,20 @@ static void CleanupPlayerName(INT32 playernum, const char *newname) } // no stealing another player's name - for (i = 0; i < MAXPLAYERS; i++) + if (!clientjoin) { - if (i != playernum && playeringame[i] - && fasticmp(tmpname, player_names[i])) + for (i = 0; i < MAXPLAYERS; i++) { - break; + if (i != playernum && playeringame[i] + && fasticmp(tmpname, player_names[i])) + { + break; + } } - } - if (i < MAXPLAYERS) - break; + if (i < MAXPLAYERS) + break; + } // name is okay then namefailed = false; @@ -1379,15 +1387,23 @@ static void CleanupPlayerName(INT32 playernum, const char *newname) // set consvars whether namefailed or not, because even if it succeeded, // spaces may have been removed - if (playernum == consoleplayer) - CV_StealthSet(&cv_playername, tmpname); - else if (playernum == displayplayers[1] || (!netgame && playernum == 1)) - CV_StealthSet(&cv_playername2, tmpname); - else if (playernum == displayplayers[2] || (!netgame && playernum == 2)) - CV_StealthSet(&cv_playername3, tmpname); - else if (playernum == displayplayers[3] || (!netgame && playernum == 3)) - CV_StealthSet(&cv_playername4, tmpname); - else I_Assert(((void)"CleanupPlayerName used on non-local player", 0)); + if (clientjoin) + { + consvar_t *namevars[] = {&cv_playername, &cv_playername2, &cv_playername3, &cv_playername4}; + CV_StealthSet(namevars[playernum], tmpname); + } + else + { + if (playernum == consoleplayer) + CV_StealthSet(&cv_playername, tmpname); + else if (playernum == displayplayers[1] || (!netgame && playernum == 1)) + CV_StealthSet(&cv_playername2, tmpname); + else if (playernum == displayplayers[2] || (!netgame && playernum == 2)) + CV_StealthSet(&cv_playername3, tmpname); + else if (playernum == displayplayers[3] || (!netgame && playernum == 3)) + CV_StealthSet(&cv_playername4, tmpname); + else I_Assert(((void)"CleanupPlayerName used on non-local player", 0)); + } Z_Free(buf); } From e854096ca0609ed4312146668be2d62382cacf7a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 03:10:08 +0200 Subject: [PATCH 330/589] revert back to number based player names fallbacks well need our player 1-16 not player a-z :chonkbuncle: --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e29a559d1..fb163acfa 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2200,7 +2200,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXPLAYERS; i++) { LUA_InvalidatePlayer(&players[i]); - sprintf(player_names[i], "Player %c", 'A' + i); + sprintf(player_names[i], "Player %d", i + 1); } CL_LoadReceivedSavegame(true); @@ -4436,7 +4436,7 @@ void SV_ResetServer(void) for (i = 0; i < MAXPLAYERS; i++) { LUA_InvalidatePlayer(&players[i]); - sprintf(player_names[i], "Player %c", 'A' + i); + sprintf(player_names[i], "Player %d", i + 1); } memset(player_name_changes, 0, sizeof(player_name_changes)); From 1c75dd0401c47ac21f3459f2425d5fc826cd137b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 11:53:26 +0200 Subject: [PATCH 331/589] Revert "blua: fix copy paste error for "slow path" in auxgetstr/lua_getfield" This reverts commit b652d802f5927f4b5efe253b99c4bb4773fbcfa7. --- src/blua/lapi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index e494e9fc9..bca24a90f 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -526,12 +526,13 @@ static void auxgetstr (lua_State *L, TValue *t, const char *k) { api_checkvalidindex(L, t); if (luaV_fastget(L, t, str, slot, luaH_getstr)) { setobj2s(L, L->top, slot); + api_incr_top(L); } else { setsvalue(L, &key, str); - luaV_finishget(L, t, &key, L->top, slot); + luaV_finishget(L, t, L->top, L->top, slot); + api_incr_top(L); } - api_incr_top(L); lua_unlock(L); } From 9f9e6450f2c8ec1597fbaabad4e1ca14412ae517 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 11:53:33 +0200 Subject: [PATCH 332/589] Revert "Blua: opcode OP_SELF operate only with string keys, so they can use fast-track table access" This reverts commit 7684e6aa0750744e61cee0a29b948209c140d717. --- src/blua/lcode.c | 12 ------------ src/blua/lopcodes.h | 2 -- 2 files changed, 14 deletions(-) diff --git a/src/blua/lcode.c b/src/blua/lcode.c index 562ad3506..567b88500 100644 --- a/src/blua/lcode.c +++ b/src/blua/lcode.c @@ -626,20 +626,8 @@ static void codenot (FuncState *fs, expdesc *e) { removevalues(fs, e->t); } -/* -** Check whether expression 'e' is a literal string -*/ -static int isKstr (FuncState *fs, expdesc *e) { - return (e->k == VK && ttisstring(&fs->f->k[e->u.s.info])); -} -/* -** Create expression 't[k]'. 't' must have its final result already in a -** register or upvalue. Upvalues can only be indexed by literal strings. -*/ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { - if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non string? */ - luaK_exp2anyreg(fs, t); /* put it in a register */ t->u.s.aux = luaK_exp2RK(fs, k); t->k = VINDEXED; } diff --git a/src/blua/lopcodes.h b/src/blua/lopcodes.h index aa84da8d0..8b08b04e0 100644 --- a/src/blua/lopcodes.h +++ b/src/blua/lopcodes.h @@ -232,8 +232,6 @@ OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ (*) In OP_SETLIST, if (B == 0) then B = `top'; if (C == 0) then next `instruction' is real C - (*) In OP_SELF, the index must be a string. - (*) For comparisons, A specifies what condition the test should accept (true or false). From 4fa937728b50cdb6b33d9bf2d1dab26059de50f8 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 11:53:42 +0200 Subject: [PATCH 333/589] Revert "Blua: OP_SELF can use 'luaV_fastget' specialized for strings, as it is applied only to string keys" This reverts commit 0fb752b7459673d8a3b38c917f9593602b03c4a0. --- src/blua/lvm.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 4d617d62c..9db792fd6 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -529,16 +529,11 @@ void luaV_execute (lua_State *L, int nexeccalls) { continue; } case OP_SELF: { - TValue *slot; StkId ra = RA(i); StkId rb = RB(i); TValue *rc = RKC(i); - TString *key = rawtsvalue(rc); /* key must be a string */ setobjs2s(L, ra + 1, rb); - if (luaV_fastget(L, rb, key, slot, luaH_getstr)) { - setobj2s(L, ra, slot); - } - else Protect(luaV_finishget(L, rb, rc, ra, slot)); + gettableProtected(L, rb, rc, ra); continue; } case OP_ADD: { From 8e82256827b12d6e90d9347a7800f225afcbd263 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 11:53:46 +0200 Subject: [PATCH 334/589] Revert "Blua: 'luaV_fastget' only treats the real fast case (table with a non-nil value at given key, so that it does not need to check metamethods)" This reverts commit 019812db0843e0d8a6678ae0ad13f018603d73a5. --- src/blua/lapi.c | 16 ++++++------ src/blua/lvm.c | 66 +++++++++++++++++++------------------------------ src/blua/lvm.h | 25 ++++++++++--------- 3 files changed, 46 insertions(+), 61 deletions(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index bca24a90f..420e4e20b 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -520,17 +520,17 @@ LUA_API int lua_pushthread (lua_State *L) { */ static void auxgetstr (lua_State *L, TValue *t, const char *k) { - TValue *slot; + TValue *aux; TValue key; TString *str = luaS_new(L, k); api_checkvalidindex(L, t); - if (luaV_fastget(L, t, str, slot, luaH_getstr)) { - setobj2s(L, L->top, slot); + if (luaV_fastget(L, t, str, aux, luaH_getstr)) { + setobj2s(L, L->top, aux); api_incr_top(L); } else { setsvalue(L, &key, str); - luaV_finishget(L, t, L->top, L->top, slot); + luaV_finishget(L, t, L->top, L->top, aux); api_incr_top(L); } lua_unlock(L); @@ -643,17 +643,17 @@ LUA_API void lua_getfenv (lua_State *L, int idx) { static void auxsetstr (lua_State *L, TValue *t, const char *k) { TValue key; - TValue *slot; + TValue *aux; TString *str = luaS_new(L, k); api_checknelems(L, 1); api_checkvalidindex(L, t); - if (luaV_fastset(L, t, str, slot, luaH_setstr, L->top)) { - setobj2t(L, cast(TValue *, slot), L->top - 1); + if (luaV_fastset(L, t, str, aux, luaH_setstr, L->top)) { + setobj2t(L, cast(TValue *, aux), L->top - 1); L->top--; /* pop value */ } else { setsvalue2s(L, &key, str); - luaV_finishset(L, t, &key, L->top - 1, slot); + luaV_finishset(L, t, &key, L->top - 1, aux); L->top--; /* pop value */ } lua_unlock(L); diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 9db792fd6..7540bcdec 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -106,67 +106,51 @@ static void callTM (lua_State *L, const TValue *f, const TValue *p1, /* -** Finish the table access 'val = t[key]'. -** if 'slot' is NULL, 't' is not a table; otherwise, 'slot' points to -** t[k] entry (which must be nil). +** Complete a table access: if 't' is a table, 'tm' has its metamethod; +** otherwise, 'tm' is NULL. */ void luaV_finishget (lua_State *L, TValue *t, TValue *key, StkId val, - TValue *slot) { + TValue *tm) { int loop; /* counter to avoid infinite loops */ - TValue *tm; /* metamethod */ + lua_assert(tm != NULL || !ttistable(t)); for (loop = 0; loop < MAXTAGLOOP; loop++) { - if (slot == NULL) { /* 't' is not a table? */ - lua_assert(!ttistable(t)); - tm = luaT_gettmbyobj(L, t, TM_INDEX); - if (l_unlikely(ttisnil(tm))) + if (tm == NULL) { /* no metamethod (from a table)? */ + if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))) luaG_typeerror(L, t, "index"); /* no metamethod */ - /* else will try the metamethod */ } - else { /* 't' is a table */ - lua_assert(ttisnil(slot)); - tm = fasttm(L, hvalue(t)->metatable, TM_INDEX); /* table's metamethod */ - if (tm == NULL) { /* no metamethod? */ - setnilvalue(val); /* result is nil */ - return; - } - /* else will try the metamethod */ - } - if (ttisfunction(tm)) { /* is metamethod a function? */ + if (ttisfunction(tm)) { /* metamethod is a function */ callTMres(L, val, tm, t, key); /* call it */ return; } - t = tm; /* else try to access 'tm[key]' */ - if (luaV_fastget(L,t,key,slot,luaH_get)) { /* fast track? */ - setobj2s(L, val, slot); /* done */ + t = tm; /* else repeat access over 'tm' */ + if (luaV_fastget(L,t,key,tm,luaH_get)) { /* try fast track */ + setobj2s(L, val, tm); /* done */ return; } - /* else repeat (tail call 'luaV_finishget') */ + /* else repeat */ } - luaG_runerror(L, "'__index' chain too long; possible loop"); + luaG_runerror(L, "gettable chain too long; possible loop"); } /* -** Finish a table assignment 't[key] = val'. -** If 'slot' is NULL, 't' is not a table. Otherwise, 'slot' points -** to the entry 't[key]', or to 'luaO_nilobject' if there is no such -** entry. (The value at 'slot' must be nil, otherwise 'luaV_fastset' -** would have done the job.) +** Main function for table assignment (invoking metamethods if needed). +** Compute 't[key] = val' */ void luaV_finishset (lua_State *L, TValue *t, TValue *key, - StkId val, TValue *slot) { + StkId val, TValue *oldval) { int loop; /* counter to avoid infinite loops */ for (loop = 0; loop < MAXTAGLOOP; loop++) { TValue *tm; - if (slot != NULL) { - lua_assert(ttistable(t) && ttisnil(slot)); + if (oldval != NULL) { + lua_assert(ttistable(t) && ttisnil(oldval)); Table *h = hvalue(t); /* must check the metamethod */ - /* slot is nil=> look for newindex, slot is not nil => look for usedindex */ - if (!((ttisnil(slot) && ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) != NULL)) || - ((!ttisnil(slot)) && ((tm = fasttm(L, h->metatable, TM_USEDINDEX)) != NULL)))) { + /* oldval is nil=> look for newindex, oldval is not nil => look for usedindex */ + if (!((ttisnil(oldval) && ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) != NULL)) || + ((!ttisnil(oldval)) && ((tm = fasttm(L, h->metatable, TM_USEDINDEX)) != NULL)))) { /* no metamethod and (now) there is an entry with given key */ - setobj2t(L, cast(TValue *, slot), val); + setobj2t(L, cast(TValue *, oldval), val); luaC_barriert(L, h, val); return; } @@ -182,7 +166,7 @@ void luaV_finishset (lua_State *L, TValue *t, TValue *key, return; } t = tm; /* else repeat assignment over 'tm' */ - if (luaV_fastset(L, t, key, slot, luaH_set, val)) + if (luaV_fastset(L, t, key, oldval, luaH_set, val)) return; /* done */ /* else loop */ } @@ -413,9 +397,9 @@ static void Arith (lua_State *L, StkId ra, TValue *rb, ** copy of 'luaV_gettable', but protecting call to potential metamethod ** (which can reallocate the stack) */ -#define gettableProtected(L,t,k,v) { TValue *slot; \ - if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ - else Protect(luaV_finishget(L,t,k,v,slot)); } +#define gettableProtected(L,t,k,v) { TValue *aux; \ + if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ + else Protect(luaV_finishget(L,t,k,v,aux)); } /* same for 'luaV_settable' */ diff --git a/src/blua/lvm.h b/src/blua/lvm.h index 0c4c877f2..2f65098f0 100644 --- a/src/blua/lvm.h +++ b/src/blua/lvm.h @@ -23,24 +23,25 @@ /* -** fast track for 'gettable': if 't' is a table and 't[k]' is not nil, -** return 1 with 'slot' pointing to 't[k]' (final result). Otherwise, -** return 0 (meaning it will have to check metamethod) with 'slot' -** pointing to a nil 't[k]' (if 't' is a table) or NULL (otherwise). -** 'f' is the raw get function to use. +** fast track for 'gettable': 1 means 'aux' points to resulted value; +** 0 means 'aux' is metamethod (if 't' is a table) or NULL. 'f' is +** the raw get function to use. */ -#define luaV_fastget(L,t,k,slot,f) \ +#define luaV_fastget(L,t,k,aux,f) \ (!ttistable(t) \ - ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ - : (slot = f(hvalue(t), k), /* else, do raw access */ \ - !ttisnil(slot))) /* result not nil? */ + ? (aux = NULL, 0) /* not a table; 'aux' is NULL and result is 0 */ \ + : (aux = f(hvalue(t), k), /* else, do raw access */ \ + !ttisnil(aux) ? 1 /* result not nil? 'aux' has it */ \ + : (aux = fasttm(L, hvalue(t)->metatable, TM_INDEX), /* get metamethod */\ + aux != NULL ? 0 /* has metamethod? must call it */ \ + : (aux = luaO_nilobject, 1)))) /* else, final result is nil */ /* ** standard implementation for 'gettable' */ -#define luaV_gettable(L,t,k,v) { TValue *slot; \ - if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \ - else luaV_finishget(L,t,k,v,slot); } +#define luaV_gettable(L,t,k,v) { TValue *aux; \ + if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ + else luaV_finishget(L,t,k,v,aux); } /* From 2b650e4b6142b9facea3416f89bc7bf7d7c7ac31 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 11:53:53 +0200 Subject: [PATCH 335/589] Revert "Blua: 'Protect' in table operations is not needed in the fast track" This reverts commit 537a50b9b3d7f33d95e142910ef5880cc8cc57cf. --- src/blua/lvm.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 7540bcdec..484329825 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -393,21 +393,6 @@ static void Arith (lua_State *L, StkId ra, TValue *rb, } -/* -** copy of 'luaV_gettable', but protecting call to potential metamethod -** (which can reallocate the stack) -*/ -#define gettableProtected(L,t,k,v) { TValue *aux; \ - if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ - else Protect(luaV_finishget(L,t,k,v,aux)); } - - -/* same for 'luaV_settable' */ -#define settableProtected(L,t,k,v) { TValue *slot; \ - if (!luaV_fastset(L,t,k,slot,luaH_set,v)) \ - Protect(luaV_finishset(L,t,k,v,slot)); } - - void luaV_execute (lua_State *L, int nexeccalls) { LClosure *cl; @@ -417,9 +402,9 @@ void luaV_execute (lua_State *L, int nexeccalls) { reentry: /* entry point */ lua_assert(isLua(L->ci)); pc = L->savedpc; - cl = &clvalue(L->ci->func)->l; /* local reference to function's closure */ - k = cl->p->k; /* local reference to function's constant table */ - base = L->base; /* local copy of function's base */ + cl = &clvalue(L->ci->func)->l; + base = L->base; + k = cl->p->k; /* main loop of interpreter */ for (;;) { const Instruction i = *pc++; @@ -479,7 +464,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { StkId ra = RA(i); StkId rb = RB(i); TValue *rc = RKC(i); - gettableProtected(L, rb, rc, ra); + Protect(luaV_gettable(L, rb, rc, ra)); continue; } case OP_SETGLOBAL: { @@ -501,7 +486,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { StkId ra = RA(i); TValue *rb = RKB(i); TValue *rc = RKC(i); - settableProtected(L, ra, rb, rc); + Protect(luaV_settable(L, ra, rb, rc)); continue; } case OP_NEWTABLE: { @@ -515,9 +500,8 @@ void luaV_execute (lua_State *L, int nexeccalls) { case OP_SELF: { StkId ra = RA(i); StkId rb = RB(i); - TValue *rc = RKC(i); - setobjs2s(L, ra + 1, rb); - gettableProtected(L, rb, rc, ra); + setobjs2s(L, ra+1, rb); + Protect(luaV_gettable(L, rb, RKC(i), ra)); continue; } case OP_ADD: { From bd27a6276900d81fa1d232f9b9724cbc6b5ffc14 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 11:53:59 +0200 Subject: [PATCH 336/589] Revert "Blua: fast track for 'settable'" This reverts commit bdae0ef4aec9e01de1e15593e49499dbb93267aa. --- src/blua/lapi.c | 29 +++++++++-------------------- src/blua/lvm.c | 36 +++++++++++------------------------- src/blua/lvm.h | 30 ++---------------------------- 3 files changed, 22 insertions(+), 73 deletions(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index 420e4e20b..990e17b6e 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -641,25 +641,6 @@ LUA_API void lua_getfenv (lua_State *L, int idx) { */ -static void auxsetstr (lua_State *L, TValue *t, const char *k) { - TValue key; - TValue *aux; - TString *str = luaS_new(L, k); - api_checknelems(L, 1); - api_checkvalidindex(L, t); - if (luaV_fastset(L, t, str, aux, luaH_setstr, L->top)) { - setobj2t(L, cast(TValue *, aux), L->top - 1); - L->top--; /* pop value */ - } - else { - setsvalue2s(L, &key, str); - luaV_finishset(L, t, &key, L->top - 1, aux); - L->top--; /* pop value */ - } - lua_unlock(L); -} - - LUA_API void lua_settable (lua_State *L, int idx) { StkId t; lua_lock(L); @@ -673,8 +654,16 @@ LUA_API void lua_settable (lua_State *L, int idx) { LUA_API void lua_setfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; lua_lock(L); - auxsetstr(L, index2adr(L, idx), k); + api_checknelems(L, 1); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_settable(L, t, &key, L->top - 1); + L->top--; /* pop value */ + lua_unlock(L); } diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 484329825..64e670d2f 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -132,45 +132,31 @@ void luaV_finishget (lua_State *L, TValue *t, TValue *key, StkId val, luaG_runerror(L, "gettable chain too long; possible loop"); } - -/* -** Main function for table assignment (invoking metamethods if needed). -** Compute 't[key] = val' -*/ -void luaV_finishset (lua_State *L, TValue *t, TValue *key, - StkId val, TValue *oldval) { - int loop; /* counter to avoid infinite loops */ +void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val) { + int loop; for (loop = 0; loop < MAXTAGLOOP; loop++) { - TValue *tm; - if (oldval != NULL) { - lua_assert(ttistable(t) && ttisnil(oldval)); + TValue *tm = NULL; + if (ttistable(t)) { /* `t' is a table? */ Table *h = hvalue(t); - /* must check the metamethod */ + TValue *oldval = luaH_set(L, h, key); /* do a primitive set */ /* oldval is nil=> look for newindex, oldval is not nil => look for usedindex */ if (!((ttisnil(oldval) && ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) != NULL)) || ((!ttisnil(oldval)) && ((tm = fasttm(L, h->metatable, TM_USEDINDEX)) != NULL)))) { - /* no metamethod and (now) there is an entry with given key */ - setobj2t(L, cast(TValue *, oldval), val); + setobj2t(L, oldval, val); luaC_barriert(L, h, val); return; } - /* else will try the metamethod */ + /* else will try the tag method */ } - else { /* not a table; check metamethod */ - if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))) - luaG_typeerror(L, t, "index"); - } - /* try the metamethod */ + else if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))) + luaG_typeerror(L, t, "index"); if (ttisfunction(tm)) { callTM(L, tm, t, key, val); return; } - t = tm; /* else repeat assignment over 'tm' */ - if (luaV_fastset(L, t, key, oldval, luaH_set, val)) - return; /* done */ - /* else loop */ + t = tm; /* else repeat with `tm' */ } - luaG_runerror(L, "settable chain too long; possible loop"); + luaG_runerror(L, "loop in settable"); } diff --git a/src/blua/lvm.h b/src/blua/lvm.h index 2f65098f0..2ffc80ace 100644 --- a/src/blua/lvm.h +++ b/src/blua/lvm.h @@ -44,32 +44,6 @@ else luaV_finishget(L,t,k,v,aux); } -/* -** Fast track for set table. If 't' is a table and 't[k]' is not nil, -** call GC barrier, do a raw 't[k]=v', and return true; otherwise, -** return false with 'slot' equal to NULL (if 't' is not a table) or -** 'nil'. (This is needed by 'luaV_finishget'.) Note that, if the macro -** returns true, there is no need to 'invalidateTMcache', because the -** call is not creating a new entry. -*/ -#define luaV_fastset(L,t,k,slot,f,v) \ - (!ttistable(t) \ - ? (slot = NULL, 0) \ - : (slot = f(L, hvalue(t), k), \ - ttisnil(slot) ? 0 \ - : (__extension__ ({ \ - if (valiswhite(v) && isblack(obj2gco(hvalue(t)))) \ - luaC_barrierback(L, hvalue(t)); \ - setobj2t(L, cast(TValue *,slot), v); \ - 1; \ - })))) - - -#define luaV_settable(L,t,k,v) { TValue *slot; \ - if (!luaV_fastset(L,t,k,slot,luaH_set,v)) \ - luaV_finishset(L,t,k,v,slot); } - - LUAI_FUNC int luaV_lessthan (lua_State *L, TValue *l, TValue *r); LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); @@ -77,8 +51,8 @@ LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); LUAI_FUNC void luaV_finishget (lua_State *L, TValue *t, TValue *key, StkId val, TValue *tm); -LUAI_FUNC void luaV_finishset (lua_State *L, TValue *t, TValue *key, - StkId val, TValue *oldval); +LUAI_FUNC void luaV_settable (lua_State *L, TValue *t, TValue *key, + StkId val); LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); LUAI_FUNC void luaV_concat (lua_State *L, int total, int last); From e7332a3efe77a651f2c122df07642ae3d8033fa5 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 11:54:10 +0200 Subject: [PATCH 337/589] Revert "Blua: implementation of fast track for gettable operations" This reverts commit e4e51f0f80fb7deb9213c72bb374d0a7e4c3f03b. --- src/blua/lapi.c | 26 ++++++++------------------ src/blua/lvm.c | 39 +++++++++++++++++++-------------------- src/blua/lvm.h | 27 ++------------------------- 3 files changed, 29 insertions(+), 63 deletions(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index 990e17b6e..6a33983fe 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -519,23 +519,6 @@ LUA_API int lua_pushthread (lua_State *L) { ** get functions (Lua -> stack) */ -static void auxgetstr (lua_State *L, TValue *t, const char *k) { - TValue *aux; - TValue key; - TString *str = luaS_new(L, k); - api_checkvalidindex(L, t); - if (luaV_fastget(L, t, str, aux, luaH_getstr)) { - setobj2s(L, L->top, aux); - api_incr_top(L); - } - else { - setsvalue(L, &key, str); - luaV_finishget(L, t, L->top, L->top, aux); - api_incr_top(L); - } - lua_unlock(L); -} - LUA_API void lua_gettable (lua_State *L, int idx) { StkId t; @@ -548,8 +531,15 @@ LUA_API void lua_gettable (lua_State *L, int idx) { LUA_API void lua_getfield (lua_State *L, int idx, const char *k) { + StkId t; + TValue key; lua_lock(L); - auxgetstr(L, index2adr(L, idx), k); + t = index2adr(L, idx); + api_checkvalidindex(L, t); + setsvalue(L, &key, luaS_new(L, k)); + luaV_gettable(L, t, &key, L->top); + api_incr_top(L); + lua_unlock(L); } diff --git a/src/blua/lvm.c b/src/blua/lvm.c index 64e670d2f..7afbbd572 100644 --- a/src/blua/lvm.c +++ b/src/blua/lvm.c @@ -105,33 +105,32 @@ static void callTM (lua_State *L, const TValue *f, const TValue *p1, } -/* -** Complete a table access: if 't' is a table, 'tm' has its metamethod; -** otherwise, 'tm' is NULL. -*/ -void luaV_finishget (lua_State *L, TValue *t, TValue *key, StkId val, - TValue *tm) { - int loop; /* counter to avoid infinite loops */ - lua_assert(tm != NULL || !ttistable(t)); +void luaV_gettable (lua_State *L, TValue *t, TValue *key, StkId val) { + int loop; for (loop = 0; loop < MAXTAGLOOP; loop++) { - if (tm == NULL) { /* no metamethod (from a table)? */ - if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))) - luaG_typeerror(L, t, "index"); /* no metamethod */ + TValue *tm; + if (ttistable(t)) { /* `t' is a table? */ + Table *h = hvalue(t); + const TValue *res = luaH_get(h, key); /* do a primitive get */ + if (!ttisnil(res) || /* result is no nil? */ + (tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */ + setobj2s(L, val, res); + return; + } + /* else will try the tag method */ } - if (ttisfunction(tm)) { /* metamethod is a function */ - callTMres(L, val, tm, t, key); /* call it */ + else if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))) + luaG_typeerror(L, t, "index"); + if (ttisfunction(tm)) { + callTMres(L, val, tm, t, key); return; } - t = tm; /* else repeat access over 'tm' */ - if (luaV_fastget(L,t,key,tm,luaH_get)) { /* try fast track */ - setobj2s(L, val, tm); /* done */ - return; - } - /* else repeat */ + t = tm; /* else repeat with `tm' */ } - luaG_runerror(L, "gettable chain too long; possible loop"); + luaG_runerror(L, "loop in gettable"); } + void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val) { int loop; for (loop = 0; loop < MAXTAGLOOP; loop++) { diff --git a/src/blua/lvm.h b/src/blua/lvm.h index 2ffc80ace..f9226ee5d 100644 --- a/src/blua/lvm.h +++ b/src/blua/lvm.h @@ -22,35 +22,12 @@ (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) -/* -** fast track for 'gettable': 1 means 'aux' points to resulted value; -** 0 means 'aux' is metamethod (if 't' is a table) or NULL. 'f' is -** the raw get function to use. -*/ -#define luaV_fastget(L,t,k,aux,f) \ - (!ttistable(t) \ - ? (aux = NULL, 0) /* not a table; 'aux' is NULL and result is 0 */ \ - : (aux = f(hvalue(t), k), /* else, do raw access */ \ - !ttisnil(aux) ? 1 /* result not nil? 'aux' has it */ \ - : (aux = fasttm(L, hvalue(t)->metatable, TM_INDEX), /* get metamethod */\ - aux != NULL ? 0 /* has metamethod? must call it */ \ - : (aux = luaO_nilobject, 1)))) /* else, final result is nil */ - -/* -** standard implementation for 'gettable' -*/ -#define luaV_gettable(L,t,k,v) { TValue *aux; \ - if (luaV_fastget(L,t,k,aux,luaH_get)) { setobj2s(L, v, aux); } \ - else luaV_finishget(L,t,k,v,aux); } - - - LUAI_FUNC int luaV_lessthan (lua_State *L, TValue *l, TValue *r); LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2); LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); -LUAI_FUNC void luaV_finishget (lua_State *L, TValue *t, TValue *key, - StkId val, TValue *tm); +LUAI_FUNC void luaV_gettable (lua_State *L, TValue *t, TValue *key, + StkId val); LUAI_FUNC void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val); LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls); From f82d1384828d7a6eb55ee27f5e8571f9dc291d8a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 13:00:24 +0200 Subject: [PATCH 338/589] cleanup some things --- src/hardware/hw_main.cpp | 2 +- src/k_hud.c | 2 +- src/p_mobj.c | 12 ++++++------ src/r_bsp.cpp | 12 +++++++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 2587055c5..86efff5ba 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -696,7 +696,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool vert->z = (vy);\ \ } - for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++, pv++) + for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++, v3d++, pv++) SETUP3DVERT(v3d, pv->x, pv->y); if (slope) diff --git a/src/k_hud.c b/src/k_hud.c index ebbf2d0b2..4e930023c 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4448,7 +4448,7 @@ static void K_drawLapStartAnim(void) char *lapnum = va("%02d", stplyr->laps + 1); const size_t laplength = strlen(lapnum); - for (int i = 0; i < (int)laplength; i++) + for (size_t i = 0; i < laplength; i++) { int digit = lapnum[i] - '0'; int frame = min(2, progress/2 - 8 - (i*2)); diff --git a/src/p_mobj.c b/src/p_mobj.c index d9b4a08ba..96a8e11d5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -905,7 +905,12 @@ static void P_PlayerFlip(mobj_t *mo) G_GhostAddFlip((INT32) (mo->player - players)); // Flip aiming to match! - if (mo->player->pflags & PF_FLIPCAM) + if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) // NiGHTS doesn't use flipcam + { + if (mo->tracer) + mo->tracer->eflags ^= MFE_VERTICALFLIP; + } + else if (mo->player->pflags & PF_FLIPCAM) { UINT8 i; @@ -927,11 +932,6 @@ static void P_PlayerFlip(mobj_t *mo) camera[i].z += FixedMul(20*FRACUNIT, mo->scale); } } - else if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) // NiGHTS doesn't use flipcam - { - if (mo->tracer) - mo->tracer->eflags ^= MFE_VERTICALFLIP; - } } // diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 60d84c57f..a3e67a5e3 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -221,8 +221,9 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, tempsec->floorheight = s->floorheight; tempsec->ceilingheight = s->ceilingheight; - if ((underwater && (tempsec-> floorheight = sec->floorheight, - tempsec->ceilingheight = s->floorheight - 1, !back)) || viewz <= s->floorheight) + if ((underwater && (tempsec->floorheight = sec->floorheight, + tempsec->ceilingheight = s->floorheight - 1, !back)) || + viewz <= s->floorheight) { // head-below-floor hack tempsec->floorpic = s->floorpic; tempsec->floor_xoffs = s->floor_xoffs; @@ -258,8 +259,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, *ceilinglightlevel = s->ceilinglightsec == -1 ? s->lightlevel : sectors[s->ceilinglightsec].lightlevel; } - else if (heightsec != -1 && viewz >= sectors[heightsec].ceilingheight - && sec->ceilingheight > s->ceilingheight) + else if (heightsec != -1 && viewz >= sectors[heightsec].ceilingheight && + sec->ceilingheight > s->ceilingheight) { // Above-ceiling hack tempsec->ceilingheight = s->ceilingheight; tempsec->floorheight = s->ceilingheight + 1; @@ -296,7 +297,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, *ceilinglightlevel = s->ceilinglightsec == -1 ? s->lightlevel : sectors[s->ceilinglightsec].lightlevel; } - sec = tempsec; + + sec = tempsec; // Use other sector } return sec; From da103f54d6b5a80b432bcc129aba8361a2b7f08d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 18 May 2026 18:20:58 +0200 Subject: [PATCH 339/589] hw_main: reorder plane stuff in HWR_Subsector check for subsector validcount first, then if its a sky plane so we can skip checking sector heights for sky planes, which may save a bit of maths on maps with many slopes --- src/hardware/hw_main.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 86efff5ba..3f4ccf23e 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2977,9 +2977,6 @@ static void HWR_Subsector(size_t num) floorcolormap = ceilingcolormap = gl_frontsector->extra_colormap; - cullFloorHeight = P_GetSectorFloorZAt (gl_frontsector, viewx, viewy); - cullCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, viewx, viewy); - if (gl_frontsector->ffloors) { locFloorHeight = P_GetSectorFloorZAt (gl_frontsector, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); @@ -3029,13 +3026,15 @@ static void HWR_Subsector(size_t num) sub->sector->extra_colormap = gl_frontsector->extra_colormap; - // render floor ? - // yeah, easy backface cull! :) - if (cullFloorHeight < viewz) + if (sub->validcount != validcount) { if (gl_frontsector->floorpic != skyflatnum) { - if (sub->validcount != validcount) + cullFloorHeight = P_GetSectorFloorZAt(gl_frontsector, viewx, viewy); + + // render floor ? + // yeah, easy backface cull! :) + if (cullFloorHeight < viewz) { HWR_GetFlat(levelflats[gl_frontsector->floorpic].lumpnum, R_NoEncore(gl_frontsector, false)); HWR_RenderPlane(sub, &extrasubsectors[num], false, @@ -3044,13 +3043,12 @@ static void HWR_Subsector(size_t num) PF_Occlude, floorlightlevel, levelflats[gl_frontsector->floorpic].lumpnum, NULL, 255, floorcolormap); } } - } - if (cullCeilingHeight > viewz) - { if (gl_frontsector->ceilingpic != skyflatnum) { - if (sub->validcount != validcount) + cullCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, viewx, viewy); + + if (cullCeilingHeight > viewz) { HWR_GetFlat(levelflats[gl_frontsector->ceilingpic].lumpnum, R_NoEncore(gl_frontsector, true)); HWR_RenderPlane(sub, &extrasubsectors[num], true, @@ -3070,6 +3068,7 @@ static void HWR_Subsector(size_t num) if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) continue; + if (sub->validcount == validcount) continue; From b5c7fd5a2b69388bdfada42c1384f889b38183e2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 18 May 2026 18:00:40 +0200 Subject: [PATCH 340/589] HWR_Subsector: check for sub->polyList instead of numpolys numpolys sometimes might not get reset, checking for sub->polyList is what was actually intended --- src/hardware/hw_main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 3f4ccf23e..5a45090de 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2632,7 +2632,6 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) return gld_clipper_SafeCheckRange(angle2, angle1); } - // // HWR_AddPolyObjectSegs // @@ -3231,11 +3230,11 @@ doaddline: // without talking about the overdraw of course. sub->sector->validcount = validcount;/// \todo fix that in a better way - if (UNLIKELY(numpolys)) + if (UNLIKELY(sub->polyList)) { while (count--) { - if (LIKELY(!line->polyseg)) // ignore segs that belong to polyobjects + if (!line->polyseg) // ignore segs that belong to polyobjects { HWR_AddLine(line); } From ac86f36186a5e3c0735389e4524d5968171da7b3 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 18 May 2026 20:31:46 +0300 Subject: [PATCH 341/589] Skip empty lines in renderer.txt --- src/sdl/i_video.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index aa0c5c72d..a30da7f0a 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1855,6 +1855,9 @@ void I_StartupGraphics(void) { word = strtok(line, " \n"); + if (!word) + continue; + if (rendermode == render_none) { if (fasticmp(word, "software")) From d59ac7d01bd3b8956223ffa699bc8cfe21f99cb6 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 20 May 2026 19:03:28 +0200 Subject: [PATCH 342/589] fix weird gap in opengl options menu --- src/m_menudefs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 9c1da4e29..3189bbc1a 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1018,17 +1018,17 @@ static menuitem_t OP_OpenGLOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Shaders", &cv_glshaders, 25}, {IT_STRING | IT_CVAR, NULL, "Palette Rendering", &cv_glpaletterendering, 30}, - {IT_STRING | IT_CVAR, NULL, "Texture Quality", &cv_gltexturedepth, 45}, - {IT_STRING | IT_CVAR, NULL, "Texture Filter", &cv_glfiltermode, 50}, - {IT_STRING | IT_CVAR, NULL, "Anisotropic", &cv_glanisotropicmode, 55}, - {IT_STRING | IT_CVAR, NULL, "Visual Portals", &cv_glportals, 60}, + {IT_STRING | IT_CVAR, NULL, "Texture Quality", &cv_gltexturedepth, 40}, + {IT_STRING | IT_CVAR, NULL, "Texture Filter", &cv_glfiltermode, 45}, + {IT_STRING | IT_CVAR, NULL, "Anisotropic", &cv_glanisotropicmode, 50}, + {IT_STRING | IT_CVAR, NULL, "Visual Portals", &cv_glportals, 55}, - {IT_STRING | IT_CVAR, NULL, "Wall Contrast Style", &cv_glfakecontrast, 70}, - {IT_STRING | IT_CVAR, NULL, "Slope Contrast", &cv_glslopecontrast, 75}, - {IT_STRING | IT_CVAR, NULL, "Dithered Lightning", &cv_gllightdither, 80}, - {IT_STRING | IT_CVAR, NULL, "Sprite Billboarding", &cv_glspritebillboarding, 85}, - {IT_STRING | IT_CVAR, NULL, "Software Perspective", &cv_glshearing, 90}, - {IT_STRING | IT_CVAR, NULL, "Rendering Distance", &cv_glrenderdistance, 95}, + {IT_STRING | IT_CVAR, NULL, "Wall Contrast Style", &cv_glfakecontrast, 65}, + {IT_STRING | IT_CVAR, NULL, "Slope Contrast", &cv_glslopecontrast, 70}, + {IT_STRING | IT_CVAR, NULL, "Dithered Lightning", &cv_gllightdither, 75}, + {IT_STRING | IT_CVAR, NULL, "Sprite Billboarding", &cv_glspritebillboarding, 80}, + {IT_STRING | IT_CVAR, NULL, "Software Perspective", &cv_glshearing, 85}, + {IT_STRING | IT_CVAR, NULL, "Rendering Distance", &cv_glrenderdistance, 90}, }; static const char* OP_OpenGLTooltips[] = From 261c02f4b6ab492313194a26ad1835108d1e9772 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 22 May 2026 23:12:42 +0200 Subject: [PATCH 343/589] few more hw_ file cleanups --- src/hardware/hw_main.cpp | 52 ++++++++++++++++++++-------------------- src/hardware/hw_main.h | 2 +- src/hardware/hw_portal.c | 2 +- src/r_bsp.cpp | 2 +- src/v_video.c | 6 ++--- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 5a45090de..d451ccc29 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1078,15 +1078,15 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, { bheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v1x, v1y)); endbheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v2x, v2y)); - } - if (endheight >= endtop && height >= top) - { - if (solid && top > bheight) - top = bheight; + if (endheight >= endtop && height >= top) + { + if (top > bheight) + top = bheight; - if (solid && endtop > endbheight) - endtop = endbheight; + if (endtop > endbheight) + endtop = endbheight; + } } if (i + 1 < sector->numlights) @@ -2504,11 +2504,11 @@ static void HWR_AddLine(seg_t *line) gl_curline = line; - v1x = gl_curline->v1->x; - v1y = gl_curline->v1->y; + v1x = line->v1->x; + v1y = line->v1->y; - v2x = gl_curline->v2->x; - v2y = gl_curline->v2->y; + v2x = line->v2->x; + v2y = line->v2->y; // OPTIMIZE: quickly reject orthogonal back sides. angle1 = R_PointToAngle64(v1x, v1y); @@ -2544,6 +2544,7 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) { fixed_t px1, py1, px2, py2; angle_t angle1, angle2; + const INT32* check; // Find the corners of the box // that define the edges from current viewpoint. @@ -2555,10 +2556,12 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) if (boxpos == 5) return true; - px1 = bspcoord[checkcoord[boxpos][0]]; - py1 = bspcoord[checkcoord[boxpos][1]]; - px2 = bspcoord[checkcoord[boxpos][2]]; - py2 = bspcoord[checkcoord[boxpos][3]]; + check = checkcoord[boxpos]; + + px1 = bspcoord[check[0]]; + py1 = bspcoord[check[1]]; + px2 = bspcoord[check[2]]; + py2 = bspcoord[check[3]]; if (current_bsp_culling_distance) { @@ -3212,15 +3215,12 @@ doaddline: // hurdler: false: we only add the sprites, the walls are drawn first if (line) { - if (sub->sector->validcount != validcount) - { - // draw sprites first, coz they are clipped to the solidsegs of - // subsectors more 'in front' - if (cv_drawdist.value || current_bsp_culling_distance) - HWR_AddSprites(gl_frontsector); - else - HWR_AddSprites(gl_frontsector); - } + // draw sprites first, coz they are clipped to the solidsegs of + // subsectors more 'in front' + if (cv_drawdist.value || current_bsp_culling_distance) + HWR_AddSprites(gl_frontsector); + else + HWR_AddSprites(gl_frontsector); //Hurdler: at this point validcount must be the same, but is not because // gl_frontsector doesn't point anymore to sub->sector due to @@ -5679,8 +5679,8 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool }; extern "C" { - void HWR_RenderPortalViewpoint(gl_portal_t *rootportal, int stencil_level, boolean allow_portals) { - HWR_RenderViewpoint(rootportal, stencil_level, allow_portals); + void HWR_RenderPortalViewpoint(gl_portal_t *rootportal, int stencil_level) { + HWR_RenderViewpoint(rootportal, stencil_level, true); } } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index a632946c1..4856f7574 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -102,7 +102,7 @@ void HWR_SetViewSize(void); void HWR_AddCommands(void); void HWR_RenderPlayerView(void); -void HWR_RenderPortalViewpoint(gl_portal_t *rootportal, int stencil_level, boolean allow_portals); +void HWR_RenderPortalViewpoint(gl_portal_t *rootportal, int stencil_level); void HWR_ClearSkyDome(void); void HWR_BuildSkyDome(void); diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index e588adea1..117d59725 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -170,7 +170,7 @@ void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float HWR_PortalFrame(portal); // call HWR_RenderViewpoint - HWR_RenderPortalViewpoint(portal, stencil_level + 1, true); + HWR_RenderPortalViewpoint(portal, stencil_level + 1); // return to current frame if (rootportal) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index a3e67a5e3..8fd66299c 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -320,7 +320,7 @@ static void R_AddLine(seg_t *line) INT32 x1, x2; angle_t angle1, angle2, span, tspan; static sector_t tempsec; - boolean bothfloorssky = false; + boolean bothfloorssky = false; g_portal = NULL; diff --git a/src/v_video.c b/src/v_video.c index 078e65b3c..585478c3a 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -423,9 +423,9 @@ static void ApplyPaletteDelta(const RGBA_t *pal_in, RGBA_t *pal_out, const INT16 INT16 r = (INT16)pal_in[i].s.red + pal_delta[i][0]; INT16 g = (INT16)pal_in[i].s.green + pal_delta[i][1]; INT16 b = (INT16)pal_in[i].s.blue + pal_delta[i][2]; - pal_out[i].s.red = (UINT8)CLAMP(r, 0 , 255); - pal_out[i].s.green = (UINT8)CLAMP(g, 0 , 255); - pal_out[i].s.blue = (UINT8)CLAMP(b, 0 , 255); + pal_out[i].s.red = (UINT8)CLAMP(r, 0, 255); + pal_out[i].s.green = (UINT8)CLAMP(g, 0, 255); + pal_out[i].s.blue = (UINT8)CLAMP(b, 0, 255); pal_out[i].s.alpha = 0xFF; // pal_in[i].s.alpha } } From 2bffe443ed39c56838d9838fc668eb510ebc50d9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 25 May 2026 17:08:52 +0200 Subject: [PATCH 344/589] simplify analogue throwdir stuff in K_drawInput --- src/k_hud.c | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 4e930023c..440b614a8 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4254,6 +4254,7 @@ static void K_drawInput(void) y -= FRACUNIT; + // stick displays if (cv_showinput.value == 2 || cv_showinput.value == 3) { INT32 axis; @@ -4281,40 +4282,20 @@ static void K_drawInput(void) // kart does not have anything we can get analogue joystick y axis values from // during normal gameplay, so replicate shit here - // this is horrid but we cant get actual input in replays so uhh - if (demo.playback || !P_IsLocalPlayer(stplyr)) // yeah........... + const boolean analogjoystickmove = (!demo.playback && P_IsLocalPlayer(stplyr) && cv_usejoystick[stplyrnum].value && !Joystick[stplyrnum].bGamepadStyle); + axis = analogjoystickmove ? JoyAxis(AXISAIM, stplyrnum+1) : 0; + + if (axis != 0) { - hudforward = stplyr->kartstuff[k_throwdir] * KART_FULLTURN; + hudforward -= ((axis * KART_FULLTURN) / JOYAXISRANGE); } else { - const boolean analogjoystickmove = cv_usejoystick[stplyrnum].value && !Joystick[stplyrnum].bGamepadStyle; - const boolean gamepadjoystickmove = cv_usejoystick[stplyrnum].value && Joystick[stplyrnum].bGamepadStyle; - const UINT8 ssplayer = stplyrnum+1; - - axis = JoyAxis(AXISAIM, ssplayer); - - if (analogjoystickmove && axis != 0) - { - // JOYAXISRANGE is supposed to be 1023 (divide by 1024) - hudforward -= ((axis * KART_FULLTURN) / (JOYAXISRANGE-1)); - } - else - { - if (InputDown(gc_aimforward, ssplayer) || (gamepadjoystickmove && axis < 0)) - { - hudforward += KART_FULLTURN; - } - - if (InputDown(gc_aimbackward, ssplayer) || (gamepadjoystickmove && axis > 0)) - { - hudforward -= KART_FULLTURN; - } - } - - hudforward = CLAMP(hudforward, -KART_FULLTURN, KART_FULLTURN); + hudforward = stplyr->kartstuff[k_throwdir] * KART_FULLTURN; } + hudforward = CLAMP(hudforward, -KART_FULLTURN, KART_FULLTURN); + if (cmd->driftturn || hudforward) { INT16 turning = encoremode ? -cmd->driftturn : cmd->driftturn; @@ -4347,7 +4328,7 @@ static void K_drawInput(void) } } } - else + else // wheel { if (!cmd->driftturn) // no turn target = 0; From 58d5bab1813b6acb63f9bf757091660ab434a218 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 30 May 2026 05:31:50 +0200 Subject: [PATCH 345/589] tiny optimization K_SpawnKartMissile by avoiding "min/max" reevaluation --- src/k_hud.c | 2 +- src/k_kart.c | 39 +++++++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 440b614a8..07d065219 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4264,7 +4264,7 @@ static void K_drawInput(void) const INT32 joyy = y>>FRACBITS; static const INT32 joyxoffs = -8; static const INT32 joyyoffs = -24; - const boolean usejoysprite = (cv_showinput.value == 3 && joystickicon); + const boolean usejoysprite = (cv_showinput.value == 3 && joystickicon); // O backing if (usejoysprite) diff --git a/src/k_kart.c b/src/k_kart.c index eed4ebfed..ad29d1cb5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3046,17 +3046,24 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I fixed_t finalspeed = speed; mobj_t *throwmo; - if (source->player && source->player->speed > K_GetKartSpeed(source->player, false)) + if (source->player) { - angle_t input = source->angle - an; - boolean invert = (input > ANGLE_180); - if (invert) - input = InvAngle(input); + const fixed_t kartspd = K_GetKartSpeed(source->player, false); - finalspeed = max(speed, FixedMul(speed, FixedMul( - FixedDiv(source->player->speed, K_GetKartSpeed(source->player, false)), // Multiply speed to be proportional to your own, boosted maxspeed. - (((180<player->speed > kartspd) + { + angle_t input = source->angle - an; + boolean invert = (input > ANGLE_180); + if (invert) + input = InvAngle(input); + + finalspeed = FixedMul(speed, FixedMul( + FixedDiv(source->player->speed, kartspd), // Multiply speed to be proportional to your own, boosted maxspeed. + (((180<x + source->momx + FixedMul(finalspeed, FINECOSINE(an>>ANGLETOFINESHIFT)); @@ -3298,6 +3305,8 @@ static void K_SpawnAIZDust(player_t *player) static void K_StretchPlayerGravity(player_t *player) { + fixed_t stretchScaleFactor; + I_Assert(player != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); @@ -3306,7 +3315,8 @@ static void K_StretchPlayerGravity(player_t *player) fixed_t tempxscale = pmo->realxscale; fixed_t tempyscale = pmo->realyscale; - const fixed_t stretchScaleFactor = min(FixedDiv(FRACUNIT*60, cv_gravstretch.value), MAXSTRETCHDIV); + stretchScaleFactor = FixedDiv(FRACUNIT*60, cv_gravstretch.value); + stretchScaleFactor = min(stretchScaleFactor, MAXSTRETCHDIV); if (pmo->slamsoundtimer) pmo->slamsoundtimer--; @@ -3362,7 +3372,7 @@ static void K_SaltySquish(player_t *player) if (pmo->stretchslam > 0) { - const fixed_t slamDiv = FixedDiv(pmo->stretchslam, 3932160); // stretchScaleFactor = FixedDiv(FRACUNIT*60, FRACUNIT) + const fixed_t slamDiv = FixedDiv(pmo->stretchslam, FRACUNIT*60); // stretchScaleFactor = FixedDiv(FRACUNIT*60, FRACUNIT) pmo->spritexscale = (tempxscale + (((slamDiv*2)/3)*2)); pmo->spriteyscale = (tempyscale - slamDiv); @@ -3892,6 +3902,7 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map // Shoot forward mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height/2, mapthing); //K_FlipFromObject(mo, player->mo); + // These are really weird so let's make it a very specific case to make SURE it works... if (player->mo->eflags & MFE_VERTICALFLIP) { @@ -5322,7 +5333,7 @@ static void K_UpdateEngineSounds(player_t *player, ticcmd_t *cmd) } dist = P_AproxDistance( - P_AproxDistance( + P_AproxDistance( player->mo->x - players[i].mo->x, player->mo->y - players[i].mo->y), player->mo->z - players[i].mo->z) / 2; @@ -5450,7 +5461,7 @@ typedef INT32 (*randomFunc)(INT32 min, INT32 max); FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, boolean synched) { - randomFunc randomfunc = synched ? P_RandomRange : M_RandomRange; + const randomFunc randomfunc = synched ? P_RandomRange : M_RandomRange; fixed_t rand_x; fixed_t rand_y; @@ -5890,7 +5901,7 @@ static INT16 K_GetKartDriftValue(player_t *player, fixed_t countersteer) //basedrift = 90*player->kartstuff[k_drift]; // 450 //basedrift = 93*player->kartstuff[k_drift] - driftweight*3*player->kartstuff[k_drift]/10; // 447 - 303 - basedrift = 83*player->kartstuff[k_drift] - (driftweight - 14)*player->kartstuff[k_drift]/5; // 415 - 303 + basedrift = 83*player->kartstuff[k_drift] - (driftweight - 14)*player->kartstuff[k_drift]/5; // 415 - 303 driftangle = abs((252 - driftweight)*player->kartstuff[k_drift]/5); return basedrift + FixedMul(driftangle, countersteer); From 7521b3abd27fa100177fdf6ff43fb0f485129f8b Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 30 May 2026 05:33:35 +0200 Subject: [PATCH 346/589] tiny optimize PIT_RadiusAttack in some cases by checking simpler things before distance checks which may avoid two P_AproxDistance/FixedHypot calls --- src/p_map.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 1befc4933..ee013a2ab 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3544,6 +3544,12 @@ static boolean PIT_RadiusAttack(mobj_t *thing) if (thing->flags & MF_MONITOR) return true; + if (thing->floorz > bombspot->z && bombspot->ceilingz < thing->z) + return true; + + if (thing->ceilingz < bombspot->z && bombspot->floorz > thing->z) + return true; + dx = abs(thing->x - bombspot->x); dy = abs(thing->y - bombspot->y); dz = abs(thing->z + (thing->height>>1) - bombspot->z); @@ -3557,14 +3563,9 @@ static boolean PIT_RadiusAttack(mobj_t *thing) if (dist >= bombdamage) return true; // out of range - if (thing->floorz > bombspot->z && bombspot->ceilingz < thing->z) - return true; - - if (thing->ceilingz < bombspot->z && bombspot->floorz > thing->z) - return true; - + // must be in direct path if (P_CheckSight(thing, bombspot)) - { // must be in direct path + { P_DamageMobj(thing, bombspot, bombsource, 1); // Tails 01-11-2001 } From bed6306cdf8747bde8dc94df6a2d99a59018bbef Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 30 May 2026 05:30:31 +0200 Subject: [PATCH 347/589] p_sight: let P_CrossSubsecPolyObj also use "fast" P_DivlineCrossed for P_CheckSight on polyobjects --- src/p_sight.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index b02ffd786..896da76d6 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -73,7 +73,7 @@ static inline INT32 P_DivlineCrossedFast(fixed_t x1, fixed_t y1, fixed_t x2, fix return (P_DivlineSideFast(x1, y1, node) == P_DivlineSideFast(x2, y2, node)); } -static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) +static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los, boolean fast) { size_t i; sector_t *polysec; @@ -81,6 +81,8 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) if (!(po->flags & POF_RENDERALL)) return true; // the polyobject isn't visible, so we can ignore it + const divlinecrossfunc divlinecrossFunc = fast ? P_DivlineCrossedFast : P_DivlineCrossed; + polysec = po->lines[0]->backsector; for (i = 0; i < po->numLines; ++i) @@ -108,21 +110,21 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, 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; frac = P_InterceptVector(&los->strace, &divl); // get slopes of top and bottom of this polyobject line - topslope = FixedDiv(polysec->ceilingheight - los->sightzstart , frac); - bottomslope = FixedDiv(polysec->floorheight - los->sightzstart , frac); + topslope = FixedDiv(polysec->ceilingheight - los->sightzstart, frac); + bottomslope = FixedDiv(polysec->floorheight - los->sightzstart, frac); if (topslope >= los->topslope && bottomslope <= los->bottomslope) return false; // view completely blocked @@ -147,6 +149,8 @@ static boolean P_CrossSubsector(size_t num, register los_t *los, boolean fast) I_Error("P_CrossSubsector: ss %s with numss = %s\n", sizeu1(num), sizeu2(numsubsectors)); #endif + const divlinecrossfunc divlinecrossFunc = fast ? P_DivlineCrossedFast : P_DivlineCrossed; + // haleyjd 02/23/06: this assignment should be after the above check seg = segs + subsectors[num].firstline; @@ -158,15 +162,13 @@ static boolean P_CrossSubsector(size_t num, register los_t *los, boolean fast) if (po->validcount != validcount) { po->validcount = validcount; - if (!P_CrossSubsecPolyObj(po, los)) + if (!P_CrossSubsecPolyObj(po, los, fast)) return false; } po = (polyobj_t *)(po->link.next); } } - const divlinecrossfunc divlinecrossFunc = fast ? P_DivlineCrossedFast : P_DivlineCrossed; - for (count = subsectors[num].numlines; --count >= 0; seg++) // check lines { line_t *line = seg->linedef; @@ -214,14 +216,17 @@ static boolean P_CrossSubsector(size_t num, register los_t *los, boolean fast) front = seg->frontsector; back = seg->backsector; + // calculate position at intercept fracx = los->strace.x + FixedMul(los->strace.dx, frac); fracy = los->strace.y + FixedMul(los->strace.dy, frac); + // calculate sector heights frontf = P_GetSectorFloorZAt (front, fracx, fracy); frontc = P_GetSectorCeilingZAt(front, fracx, fracy); backf = P_GetSectorFloorZAt (back , fracx, fracy); backc = P_GetSectorCeilingZAt(back , fracx, fracy); + // crosses a two sided line // no wall to block sight with? if (frontf == backf && frontc == backc @@ -262,6 +267,7 @@ static boolean P_CrossSubsector(size_t num, register los_t *los, boolean fast) ffloor_t *rover; fixed_t topslope, bottomslope; fixed_t topz, bottomz; + // check front sector's FOFs first for (rover = front->ffloors; rover; rover = rover->next) { @@ -275,9 +281,11 @@ static boolean P_CrossSubsector(size_t num, register los_t *los, boolean fast) bottomz = P_GetFFloorBottomZAt(rover, fracx, fracy); topslope = FixedDiv( topz - los->sightzstart, frac); bottomslope = FixedDiv(bottomz - los->sightzstart, frac); + if (topslope >= los->topslope && bottomslope <= los->bottomslope) return false; // view completely blocked } + // check back sector's FOFs as well for (rover = back->ffloors; rover; rover = rover->next) { @@ -291,6 +299,7 @@ static boolean P_CrossSubsector(size_t num, register los_t *los, boolean fast) bottomz = P_GetFFloorBottomZAt(rover, fracx, fracy); topslope = FixedDiv( topz - los->sightzstart, frac); bottomslope = FixedDiv(bottomz - los->sightzstart, frac); + if (topslope >= los->topslope && bottomslope <= los->bottomslope) return false; // view completely blocked } @@ -315,10 +324,10 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast) while (!(bspnum & NF_SUBSECTOR)) { - register node_t *bsp = nodes + bspnum; + register const node_t *bsp = nodes + bspnum; - INT32 side = divlineFunc(los->strace.x, los->strace.y, (divline_t *)bsp) & 1; - INT32 side2 = divlineFunc(los->t2x, los->t2y, (divline_t *) bsp); + INT32 side = divlineFunc(los->strace.x, los->strace.y, (const divline_t *)bsp) & 1; + INT32 side2 = divlineFunc(los->t2x, los->t2y, (const divline_t *)bsp); if (side == side2) { From 1a2a487a93ca8c8b9e5bacc5dc91961d95c08166 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 30 May 2026 05:42:34 +0200 Subject: [PATCH 348/589] change cmake title to "Saturn" --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3184252da..002a3e7e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ if("${SRB2_CPACK_GENERATOR}" STREQUAL "") endif() set(CPACK_GENERATOR ${SRB2_CPACK_GENERATOR}) -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart" CACHE STRING "Program name for display purposes") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2 Kart Saturn" CACHE STRING "Program name for display purposes") set(CPACK_PACKAGE_VENDOR "Kart Krew" CACHE STRING "Vendor name for display purposes") #set(CPACK_PACKAGE_DESCRIPTION_FILE ) set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") From d7803ecdcfe3dc1cc3f02883658751c62baa50c3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 30 May 2026 06:05:45 +0200 Subject: [PATCH 349/589] fix cmake build --- CMakeLists.txt | 3 +++ src/CMakeLists.txt | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 002a3e7e9..fddeeddfd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 3.5) +# needed for lto to work for some reason +cmake_policy(SET CMP0069 NEW) + if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) message(FATAL_ERROR "In-source builds will bring you a world of pain. Please make a separate directory to invoke CMake from.") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2de66a5af..dc456905a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,7 +54,7 @@ set(SRB2_CORE_SOURCES string.c tables.c v_video.c - w_wad.cpp + w_wad.c y_inter.c z_zone.cpp ) @@ -518,7 +518,7 @@ if(${SRB2_CONFIG_HWRENDER}) ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_shaders.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.cpp From c34346cb9a9557ba3c48ced1d699e5914ca1bfac Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 30 May 2026 07:29:30 +0200 Subject: [PATCH 350/589] Saturn Icon for mac --- src/sdl/macosx/Srb2mac.icns | Bin 120190 -> 10567 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/sdl/macosx/Srb2mac.icns b/src/sdl/macosx/Srb2mac.icns index 890c268f73d46e439fe9a69486e3a0c0f870a097..a2067f54d68db4e4aa9fa8563aeb3c160e7d1f8b 100644 GIT binary patch literal 10567 zcmeHN4|o(smap!aWF`p+Bw|39e?eTszfD3wMAk_#5yD|eBe!^bArR6ku^s*x0|Jf<1k^e5pWH|a?51z77_Pk_w;C3B%E;K&3>K>hzaoocL+#86NnJH>t6LthJhg~ z=X(3?eVgI?rmKGMSMOE5s(StAh2o;6B?u)?FD^=%j1c3g&dZ(NH}>9Ggizm{8Ci1x zgC>K_(eTKB;g`?QUdf#4)0j_=j4g+b@!8BLG7);q6?eTb3i`u~X3Tj4p*0U6gzX4j z0|=i*s5AwkbBhp~vKgVo<*&cXO$9vzbFwn$u0DC;Kq@uz-nPrLF9_ys(EJF(Y+CPIhkAu4#)T*q(wPsD3qzMD@-Td}{n{*(H8SJ~Ek z9u-%dYT5fQW=tKb_OmTv+q|O zAD{S-WeZ+2{?l7WcF#?kfj-Tcg*wm*WNn)>yKBkF}qh>eC|T~e{ETP_ITI(Uw8KVvfzQtDf=F){=K@t z^mNlEV|)ht(=GF_&dRknlQq)PriLrg@hAZ$;CI&G&xbDlZ1cLd)GI%Ed)=fb*%@fy zFH9Ni(F=$6mHJm_@C#S$>3AnTW>E}vSKhA@7d1`Xv}ads4T|43Yt^KGzPR(V-@lT3 zadWk^Y4F_ntvjA&MxpjAsP&Z}%(OT0OD2w}T-Wl^#IjxTCbSv;HNMvw)p%Gi75(vi z>+!VCeaed;u3Ct!O+)tnWZK(H+jgC5KJd0`uX$rsH9}NXBU?~EO(h4i z&1`fu!?1>^of;-A2wp{rnyS6mmqF135t}$7cIs6^I?s0zRr@I#tf|-czff#{rtHO< z8oX?4JL&lK@M@jv2I#;2sF%)Ua3$Bj>&keZT`UaqM%XoyPW_(x4> z$h~NIPI|(qtA~(b^_T6hLG)z~5^Vz-3Z`GROk15%oL#vx!!qw9^8Vb0w(51K8s|N= z@F-=(YUEJnz=3IaW61=Z)<6I2W2x1L9-5e*zU|Glv|LTyfMD@cMZ~P0FQNXX>tgJu zLs)}>?Ry;VWV7l-(S&p@Ngp%XB}6B?{&mcl(|{Q?qU2x!dl*5epkLTy5`_PrKCVL5 zUZGM!5Gh<8kYRz%ARqt)V4r|Vl?M|>@QEH)5HtrufU`cI;3BNx0~85z2-_IK*6WxN zcs`$t1fG;z8RAMl2a$Z;I^gXBdJVuA>U;(vs96eWc^Y7&urr8@fMZV-u=!*VLmXOsFV*V}%BW3`D zQLM3~RhGQ2g@yDv@F25mnoS?xu0#+Sx;1cWLo6 zMT-{~miu6qufahE0Vc6sogJ4hUTC`x@nb6z38QJEioq4V!RG%g*zmUo8y>qEp0A)^ z*lptZuwcXUB8961GRy~qjSee3_E)*FpWzkJ&GI}AHb7?;g?IT`UI7&G5Nv|j#t;U< z1~4P=6vgEaJSi70Sdc3z4!@*y>wrrLxB>WlonqjFn&GMjwLA^5k>44_;abBoq9{8V z1X29MLqUQ;{|$)+D1MiM{ZTwhh>$iE@O2=`mv53_m=6L0%a7!7m_AVf2i1WWcrk>E zZi%8BDJtoHptdEqO~Jgwk9nIS!F=cnY;L>a;O&YH`gENY?pmcH=!+`1Q>lVB1RI{O zr&|EQhUd4?Rv_5$wQkIZ2OGXO*z^XQzoyKFyEWKw*vfER1^vQS6UT)G8;%nxTpf^M zE*NZdSmv;|%8I=VCyQ2=<7lt}IxEYZ%gb^ypooKD6T~)#FbFn)8G$FuE^pvTxe#oE zTuF9#CAnJ%TtdJNz~|~@0~gc`S2d{RX@HH~&L9rg8kP|SY(5zTQQX5rL4ra54T%LP zUYCr$Q5;H$kTw)>bs)*7^Sdz)!+a13SZ*YT!*Eds2i1WWI5C8ZR*9k;DJtoHptdEe zO~#zVi#eMt!F=cnY*xGM;Ow#u`gENY)>^qD=!+_=Q?7zG1RIX4r&|EQhU2!-Rv_4L zwN}i92OF+8*nEdzvt+VWfE>;o{>!Vk-Rprr(*q>p^CuKWa05UOBYI%#aO99b#ip`b zMtmFnmI2>RziGgo(8C7Y89g-MPU*n`-E`F5h!ael^>^mM1qTiW?F!~*sxS36RJPDw{`Vdzex8< zPk1OjB|CL1Is4`b74rUgq8@s%-=tY{Q--_9`X8mFIpGHniqo`mi)9^eu`FplC|X#q zRjo#M6IDzy^c{TH*t?7VXrA=?DkI8P$$F?tT`SFe;rV52@`}zKEc2~x_)THS*A!Rl z3}|3^AB6g}CpN?w42wDBQLCV`MqZy|sTPb`ho{#=pVclwL6epSqXmyg5YhpIDy_%k z69}<+OoRwNidP~d1)+2bB~<_*>4tGER9UMD{iZr36s2hA%_l8tJH?*5q(uqBBh013E4aj zD0$Ku)HsVa<%O^80gYQhL zgJGv+^nVZ|GxNU1VED&^>97SRqOG)8a(85k7SmIQ4}84g@efoPnbqz6`!U1&qG1?C zM`t9VtWMZNGf~fH&tJ22UbfA`mR?g|feN{*q@a{M8#45NiyjC#BI?za_kQ7)EA4x} zQOQOqY-&VOp>Vh!{XaTNeArQfauqH7MDuPp&+A8tho-{&{WiDB@8=bY!%?Cj6vm7S z1z@9K91AtHYCrv^I^Zbj9Nr0KFP#P39AE(iB|2cm@c>cnV?lqlG63|Obqhgw74P)N z@r5@atRR3ujS>ZBb$t|a=n%C^ZHR7Bse%F+E#tvaayy`)MQ2zGeK<-y@1jMk?xV!_ z9;NRwDsf>)35pT)XMHqhwQ`((lsIV0oY!l!n!H|4rZ^lW3PRZf${_&2M!`51DiGCP z`b~AfQPMe_6N(x-3${7H0tgB)z>4DlqT0uT{%Uyu=r`*Yg77NN>5bzGZ$MZ^0D&4g z3e4*IDCE!~YL(g$t)g57uon7olsL{sOA_5jiTmq6O3&**_>H|k z_)+&KJiF}1LeFqvpdAuHBT`C{5aagZ5TPgWEkDq1N9)mcH#s=B+srTk-J!f&UBt7e zwRaQ0WrDhky19|hpa&xb0VF8yX$~RrZLHiZ`y1{Rm(YZl%@ZLfYTsVB`6E@cqZo3o z@R2DwN6NNqHu$UR`jOL88uIv2jYLARC&%aiIAvG)%ojur{?CIZc;L^~tS}oojK^n( z1kwX(91A&TrOyOO9>@h^^O;Gu4-zw8 zCX5(oOM0~)dNJ4M|1kT9!)C5~ywwJ?`=;peM}`d>d63v?CU@yW}ii$KTA@rtHMNvRdQ2`MYQF`b_ z1rwK}@3xjyg)GVobNk zQez=z>XB7Ab%%qhlJ1uCw-HOt6?Yt2CMmZW2EDK?)^b^Jo4%x^@BHl=MS_BYpNhD+ zA-KiBS_+nu;-179L?*zcr`qAxtQ2pC6Tqlm%6baoC6$$(L-V5&mv34j9;PbknMmWH zNyS)ILOxD%?;&u|pu!XioB?sb zlxYW54K*c0;Yps>U_rS@DN-7x?I2EigY78D9?TN>4dDve!LcMx_>hsuX`!}kugyZP4GSBP3xc(@uMJBNJtXhsQQ*3 zAfWd!(kM{sjW=7lZ??u;y-I*100jc!^hVHuq1Z#vDlb+dgxZq`n*#)79_#!-d4_mG z0G_a6b#Mio9IJ;Slx_j-3=}zjRR(2ANn|oGviSi*0bIOwDjwkmZdoXDD2T-yNC+mp zKCT7XdVhYjMq4jq4^zjrczg#8?*U{jAf&!JHWosVsF@IgQcT3t@6pGvCg4jb2{1$j zBT;k3m3h=4VF3iRVu+N4>g%k7lYrM7C+OORY;q>zk?SuT0>+MIod6_w;G4karGtT) zLr|+e5(sikvXPn$INIanyT%o7Ylz41>;S5Y9MyXVCWD@mhCpf)IHZXX1EL#`LX|qN z0doqRUaa1oBPjA;l9@=fxPe}!0mvFEn#91LRB80&ZB%#$GfKf2Olu1K}hyYu| zI6QLaM@l+y(Uc}7NXaS=LUB~nEDYEjWp=FXNOo#seC-Sc&VrCI6(&&-R3PG_Z7$m8 zqHQkv%|*YtFu%EVKE^@M$2h-j{Z>V^IHIL0$?9{g@LTh5Z~VVS3bc6P!yf)WcR~>V z$nTNG{QHFFp8?QcV9x_g{&|F;KVj2u_Ix=2!^BtpAHHOA>sQ?{Z1u$ef2B?XkNcya z;~VJkZxIp=YVEiBTmHcRS5);S+!y@?U$*~#{Y8Jv?`>bc|G(aU<`4P5=)wRHdl;vfCSU*P}i@{4}%e>Hw_5%dQ>H11lzvD0oZG`3a^_b0GmL zWv*qrPrP?jaAqbkuy7iFTNC6ObrE1>)5yTlj1Z)tX6LvB1f9L`uw*QRLZrbI&`E)x zSjft*^e8l0DI+7F3eP#ql4MX;6EFyNg{hQx8EOg&ik?aeO3F%>?_nQ#1!YxbB_*{O zDkT#V0p|@)U3y4F5E3_0<61V`38BKCPaj|cRN7(cZb%f6-iy}{Bls95h7j8k^QH8_t&9HJxr^YHZwc;uj6$>h5Hw1*of#5sL zfdp~T&&4v`5}`%RtRqVy=nf?V;)3B%ThwG%u5?`~y;4y{{sf#Dbt+btex=Nw^RluJ zXb@Dm$z+ZHD#fje79lqHRpWQHMoeQ>7*tht$JfXwP^jrNE}S8V&Yl~$S}ztt_hd^A zBH~eWhu1;`7<2{MkK{SZu(;xvDexj?t z)mYY3&f7t5rA#qw@(PZVmy?qPl+Z0E1~edE7;al7r(o@|HCh`GQV4tw&Z;?zN+cCJ zF98N^2GW`N;VFJ~7Q*FvHTkCUU*;lex^ zuCaA+u(!9fx7}ZnNdp4MJWm-#J_uR|A(t-~1JkKMBwErF>0&WxX)RG22r~@hA%vPX zWQ;Nu&V-O$zcrRQyEuo%WF`hUC%Zt-Bp0-^V=Ao+uw@F^GAmn=03nz~lf+R=chlNY zFl@j@gb;}B;1`My{Mzs#4IHb|z?l`Ei-?Qza!z-442pDf*yPwip;Gg~j8ke65SyKd z0n$tujYc7nE)@6xIGK47AvDrqot|(Ugj@}SCM0FpJ=TS}X*ZD98T=H&loT*@2DF57 zns*rng4DPnh)oKtV$RW27y`D!Lb)czX0RT^xEA8oMu4LxqN&I<&Wz6d!LaEC(9cAr z7CAe+&yZ3xko-X-+y z1Lp$TN@1qFV??m)t!Gw8FsYFs6!UEfBoT#SoA8J7VHotoa3B(b7~S+Fa3~VQf^6#5 zL!!`?6DWxnlsym{IEo4V&9G;0V!%#Pc5Q~)sBQwlW?VgxR#ObG#T1_>oXsHMFW>OPQt01oiulg?w=JAJ%8 z+}+(`1^|}_AQTmJ5MicIAKt!tIrU-=IL1OK76vELSPBtL-=Y^?^rDMibkU10deKEM zx)_Tt#-fX{=wdAT--<=I%xCx*zs&G`KK6?`7ZiPd<@gf5%%c5~75L&xumB_g{&;=7 z6!>pZ)F1x=``gu2$lqgVzWE9qH1rC6!N8Z7GSlAzhvA2uUqb!snsMmc;4pmlUoc-@ zr2HK?46A<$_uDn^hrfrv@D2EczXylmuSNcM!^7~_uLx}Zcf)^~&ioCt{@=p){B?Ym ze+v%3{44x7lX8EILFM`j!mdC1zIny-7x>C=LjBSBSNN-cbba&cuke2|`)^?U1z!9c zAb)CFg#VK|zPkB`_4A7L&-U~6e0>O+uX^}1*uU;L=Kjj@1Mrmm-@LxIpKoNwzrer# z*YV+0!WXZv{6ouE@PBG(_+se!%WveczeM=ral>cK?O*nOef<^ue^~Ed!Gl!Zzk3z@ zm49gb-+{x{U%?;xxA1??ztfOy{vG_)uZD*(5B?28$k*_Y_us=m{d${*AcjYOixBaR z;UUQQD;xc7fXCk&9t;usZ3448-y9w^ZUfH;zIx4?{T(<2$zS*iMi$ z@$iyc`=U)0Wu-;=c(}QF`GmzJX-RZ-OXmR6RqFc`xDQHz(e*Bx%m|P>#jvD9$bD3h z4DN>FVH9=CGDHG|q?2JthoF^v;11A;>=Z^PLP%yqOge;+|Fj3BaN9sLntBw$!X6JH z(du9zCIkw@#K=I0f<))`z~IRXr4_(nZazMVp)=tjK}ZHYj#!W`WtYOG#+?W;1+pTemawL_MaZxwLI{aE5|Gt~Hw~gk_<%YdU>K+!j9R4- zD8BB>QDsI@8AU$_2yR4WKoFXiVV#G9wk1P!grJa&7VA_9!8k*Lp~y@K3Y-V11;ZeF z>U5GIwEjqafmjNJlqxI%gS=b42k=;uLV{}{5-dUOy42m=+DdLEgYWh$Z-&Uttu5qM z+D}_+Tgxpfl>{@k4}i{AGH4@_83ANlJNaB2O%rDT6^ZF%S-RTVSn!S2($+cdiN|7f za5!C{N*q=PYdG^303yP4iP}6^thNr0_JzfQZ!K*thj{RKi3o-PYB*7bNQRJBYmvZ8 za^Ak~UlHe+UgBV)^o_i<{ ztAWnV^q@8t$=mm2Ckjj`#6eT&QqYSCr6$0LPlkX8I~v>bcntsq#qPJBmXBBUK|m;8 zvs0(l>A}Md@vT;|FlJN@kfkSrJbBAz9sKrw@Bnc=A|661@z91iMU$NRt`2~6#S%c} zn1dojr=Omui%Ni?-ElA-)l(L$mqmo>6HN^a42|vgf`KBnbwI%#UN8LJ{a7$U99T*) zOa)d)2NLz*VIq(bB;e8Da&C@R`vxAGP}An~@^A$Wy1ZHkfry1T_zXzZx)HgKl~ulY z9UTImK*Xa7c--|VA}m0)!{c-vz_3AjI{JEeyn!B0FAj#s>^}qPyHCY}!2t8^(K3k; zBXgl#gW|aiVI-JCL|QMf`IA70yJ6Utm5z>x22ViHbW6fP9YQ>qQPMmnAaUyhD;H5L*8JyF@g=p^t?b zC4eQogJ9sr)C0hh1>VBvI3287_P0njlB2we$xF9*-Al2G(WG)5Z?js{O)41kJh7^th2 zjA&pDsu2iav_^BWFat#kl7-=D26Q44JOBlPqghJedxZdrrm+(MNs`*s(mOQTLvCwn zBZIFiBVeVG!Ga^V_FcPieXxhz^9ES|-KKgXjOlA{Z2_G`GB*vRsj0EP5o~MJzE*Nu zN9!CgAlitGW9bEYj-lCcIyj;xkG4j!ot73(2d}>=AvZB*i<|Wt&GX4aYf0JATy zrlH2d0+gnPrWTshCDUB&@QbNuH^Ah!wzM=8TQM|~Xng>*i0o+ZCc@~!UUFMoA{hcU zfM{(cwlKDXHQqsPZ)pNBwBb;F`2-!3Hj9>~mb$k4F?r{3uZ;wN`U!@?te>S7QhY{5B5L7afXeq7 zm0np^li=W@fCkQzJpmXSMsV}?AVUEVJrH3OsAix55$I6J-C$*-z&6=J0`2o$ZUGN_ z<-NQ^v&r_BE+~d83hb6V7C@35x8}l46 z*F$cm0#dYbPz^5$da+s(+BoCZQ|j7Vj$&~K%Jp@@j*0`Ds(;zxQ7{1RB0x3E^;7w7e zG%(*tH2YCF76{?-84I!ibW0Xe z-5|1UjE{*SM#slML=t$XC!PX-0YIuE|3?0?}0af)yk-#AFF-T$zkr=}m6-_Lm!g-Nd$3JsLPi1iT(_v<$2L%|r z!FGv3Ffw{YxdLm06o57|Xx<2cOhpip^eEkf2NfVF@-rf1I|MOF8gBPj=LRuMnju&p z2th)Kv;Z3TG{oWgDFK^oWgLW7^N27&0%w+?56WmTYeIdvYCuf{&AtG@p?F$lM2aIl z5ke&C0MBh5uUi8l*qA<(fvOWBR>{BsaDI;jc|eSDg7g^(u?qLO7cmx)2r;w!hhd;- zEl?zq$A1<=7y=JX8yZP%AQRhofP!h;-Sv_7v5}5}+g)wI7n0kEWc2(*5XsD+C*<>Q zQX52$pZ{SZlUrKq&o^B8jZwOLS=w6KSR#%UtBoUU>~(I<#Z`Oif(9Zs87EE)F+rdS z;!F^le(Q^fMQQ1*Iq@6cFZfd+%%+O4U59;;wII~f0xoP`9f7G}@gIKMT#Y&d(V^%t zX4D(M_3Qv;F;cJZY2`v_fw*?~<>Ai=JHde{HIFU_LTXG{v;_YOjq+z0i@87#9OY6Jt=(F}uMAa)~xAb3?Y^FSihudxQ882-yTQD5w#S_d@{J zjsUiG2{;|71x)&~lw?UrED01x@h95SLU6|4Izb4;%)TR6lr4h|;wjk7xCdZd1V1Sd zBTGa%L-G=2*e-f-GPy>aZ$^lK6Ae8BsUTsAPCip6gf;;)N}(YjJad7=Kpec`-K?Ai zA=2M{CV-+jND>*M*+~1PHy=icEnKu^OLM2c+e&-;@GD@vU>LA_lWX*GxcT!35yz;F z#U($}qcsr0w#Wp|DWFRir>(X1D2Seb#tH~PQr63$1_s5i$_ADlW5AL59?W@&&(PJJ z51c}}z!t~uDkIGdu8)<@_cBr;1|cb9mpBgrFm17>Ag1S!!(u?#v7-nC+_cav7G`2& z1Ao@S#J;u5fI8roaN zufdNg0eDC)1_sR60=iK3u z1uD0 z!*C3!cL1ePL~sBB#x)!T+`+C_N5R@>qX$`#R>~+a(|95x5y=QnAxI1mb6O6dfD%R; zN-Qik^sc?V^K;x!3lZD8Ufh^Bbztt~?knvrv8{B#?%S@th=tMD+rc&!N9Jg00Wsy} zCt&WW9pIo&8><40B{4@0xA6?$7G!3C*TI3Q(+MtHrKzP2HYV-B?YcNHZL!*nTAGAZ z>Ld6%98AO_aJV=fHjomTq0WB#@Jd5RgK+$}!I(cCgCH)Py^~pjI|i5{LpBqL#9WP; zfH7+&!|*vFA{s)Gz+aVN5N^XTJS+mlVmc47D`|701vVrMkA6UYAT9c~#DWpj1L)Er zdKnnb1rrHQWI%;X_dpba08`0Lnny!Kg7A(R!7Lctq6rRfiUD9HATi;byCKwWn6fk$ zNkTD#@Bo1V3CoX`U|=6W?-Zbir~(NV2E?*U)l3j_3yAp;$^m;I1~d%6Wdm^y;1Zk$ zPzWJVp9|{rp!2koH0_{|O@=TG+sNi0_`4%;q( zlo&V$RskerYZNOmW`zDZ51At%Ur>hz+;M)I8z#cMRbaE8j|SPtVE7TO&{@c;k2XED zVD~gbZ-L zrmvYyj*N_H1uRqp7U*Uv9awG6cx`4)tli1x3x>DXfSe2oY=$H(hqi{6{%X%xz&a{@ z3~;*MN5GDg6CWEB6T!me^h86sC(rL0!Se61BV7Q^-{4Y z9oU7?YZAEjf`hwuX&i{5Q(%EhAXw~8PvY@;cF7Ua?l4tx>8mWpccB!hu_phTF1 z`f+CVdMVLI3#X|~i(kQ(8HYpYV2Rpjtd`N9k$4bX0NbF(!Mv@N`_@~nUuU8rzfw|E zTuhi7&8ui#36f9)&`Ed*Is)H<4#AJ0ED&*@gceiHi>c{uik3fg{9RYSmIK0f(fl*eFXZ4y$OC466$d{^9)`dAUs2GHyndMcuVLUP z$b&f`{D{O~;`|)>pJ(9DM*RbKUkbDE>y{s&_-B-#GD6~?$NHf=;=-l=9ph&w|1-b8 zkGAmlACmVgB;vvef5!L~+NW{zqx8R$#HyuM_{r6z~l> zez=LSa1;EM;{Qk}@WZlx6LG=v|5EXPzyQ7}#g8{GbOjK8oYXfl7fSyZtAD{0@J%6p zrg32g_^Z{wQ2Bqk`WG08{*0!-jk_=d{Pq|>)4Cw~zh3Nc_J@|DVvnqWyob2L1`{FWUe2YX2Ydzl493{x7Y2S*ZQBEI_vJ(ZWLM zf6tf;f%$LKU+DRJA+miB>_X`izh}?|!2GY#Z&`qB-vhc(`4(KpX8sRzGJ)vgDlejehn;m0er`7d_Q#v{PXo+|N38|5B+-a7v`h>f2aQs7~n$e z@1Ixz3!+c> zDd302pZ~ns|FExoNB5754?!*8G5&u5`3dm>=ReKB&!#5+gLMC~`)9OI!~My9knpqg ze~y8lCl566<2LXs$O8rbCUw}{uRKlB)@PDelc~x07O`T68-`5 zG!`J@ckw`+hyBNXfj{;BYPSDqAQJvD!hac<02uibE5!eMwEx1&kKX!tC}~0n8Su}! zAQoRMadB3rB=Bj}5Vv=5c#v<9ia2fD-`*|3`xbD^>$AmkI|PAGj->sd>FH@O5W7d< z*6p-5@F9ZWN7BR7%Ns(^-y^ES<-dCCAv-k^;24nae}YPUn^{R5S2FlM$X~H z#oMn38Tc^U){h){Wg7d8>Dc5<-Ik}!*XYthYiywV=E)_x0ynq!PYe3S$R)UpJVSMO z^_$iele{#@_fEgZaf~R7$d6lhU6?*z|DGuKAh&MNK}#g{)RkhXtHJGfu0+4Oh8C#{ zSza3w60V7;J$=vN-)Jv6lHhT44L>3^S~)0J-hP9~GPRBtfr}GRkQ&oXdDF zL^#Zv4LSwZ}^#Cd_ZJ+Eeker?F+#{jn}uyPrQ~eREzE% zQ0?^%f3D6I!dVhCcIZrW$nCkQVx8Vmw;Jz+Cjm2zT7lTgjx5rU!-$J;|53;ys=p>d z@-6*-2dfpQx854I@qM8v8gualfAsXFJPx;4YvM1zf146GwL`~bNamVxe{9?KZ0)#) z^Zd7iK8ZQ8_|zsDZAz|J4_&*-LGktOJ-M3)f-=csDitoHTbg~yIp`LyG{dP)ypmSr zL*bpO{d0}bO-X% zCzHgJb_K3XC7_VB9+QBK1?Fq(sfdo5Q`-28B_@ zqnQmk!lu(o0vIS)t_@?v<22qEWmzdJ80TxV#B99$7I|lIx=g6ZgYXKjuEYJJ`yLYZ zC6+bTZZ(P6t&60!W`(mi?CG~z2PMucDA zPjc<7Lsnh#|7fzRWo7sY*?RS?CewY}9(0rz_B|URalKsYePiO}oSeqV5WE-T(|1c= z=D&k!_C1k)_`9!x+lK66Kq>TN6?G&vEd3lwB!;PV@M6VByC?4qg zFz__6bQ*vCqAdq0LNW4*9DVI^KQ3)4OCbjt6{)7}u9Izx!V(uZ%8I#Z{;PvH4nMhyz%(X zCcXjN`|{En9bp?e>$*#PXOvNC#LY`p1)HB|X*@m_xvu)^s@k^$O31#H<8NkmPNAg* zrmr7S?@ns)FW4qzdi{*}J8JRytm)|c)6x0SBfjqoNS^(=FEFFeI7i=NH6dHyF8}2x zk3RUMlxq@G^7Q?c)o<3@%$;Y-nSOXzIb3qK!ftnZuH#E;;FwHz3l)pM46B{r)x6p5 z6kcWGX6xFPk(g*vpHnEU%QjrguONJQ;{BLfUVW0i2sN1~JT&X6SP_Ghe6XW7=lUn& zO2OcZn+wmb;ZZ6%d_5yMjaTz2L-TUZ(Wt_hz{mQIS%tfg-{@vZq^LR9F+6|N$P<4w zDMI*?@jjDLue2@tPEoFFD?A#poSW^QPv4$R)c5mCU>q4zXJfQECZhF}u8H#AXmqUm>TE$)5}3Du1v; z>0@2^4M#y|!?$^_gcB7HovxP+oRC+XUKeYuv_CW9oTItEjS@psMrGVexs6wR+nV;&=J>_|cjL{mQyeJ5Q$?3^7kE64N18G<(XV3b#eJ=vbOT)?_C8H? zct(dhAghkt5y~6LNm-?bS~ex_WM*R%2hhO;AO@ z>I#<;La~-bKYzu49d}Jr%OZmNq9x9t@2=CcmnX*U$~GMi$VWJ43(Z~9bAF|~D+W`8 z3KN}}z5h`yWyqE9)t#ZNn3emgmf8w@^1V(rv%Hh3-DYw&-~Sw)hl#%0GIIv48P`4` zy6I@NhHv_dE6kgY<$K2nmL#_5%j1~OU1#+xHeCMcWpBU}{!7opIq2J;J}OQW(NDq~3}c)zmDM-f^O)`2mMu3i z;ukJft&bV>w~`Hx7r<`wz-%q!ujfB6pd+r|Wc100^+F)0+Vo}P!fBT6Ywu*StSE@M zmwi*&u1dr|X_h1vcB4d!!Te2DXYzpqQBUu9&s@*XN)E3#s(qBLrZ*W=j~ZQib)|Ob z+ObPI+XXkA=~=0|H_oukOKFLrWik5*>dcDs zLTjF*g{Lf4Cl}`K({d(%#b3nx1HRtaltpDX)9cQ$l4w5@L~x!hHd zcqy_VD1^KbH>`9igka$&k>kDo%C?TD$Ya4PV+GZX$s!gH23%_~V*FW0s_$$v>RW!X zpV@~%TAz>>mVRA2dxLtyfk{E51h;7I(icNd=qt=GC9fAbczIXJ==8=My|aR1rYy^r zldtb!%Fh_C5yk@Hd0~}oF?Sn+z znO!w)CYh_x>_MYGG5S)ft-VpoqCz_2%ivF(-k+%<*fFx?s8fs@(mWb#M+n5XJ#71uisn8syv-!bhHf{HZECb zDWYt$+$)s(Y0+}m=*^SKY0vGNcqF$NAKu475Omi(&CzLgVOgrmOw*A52gHDblR%+; z?&*G#N_vuu#R?^VMCa`|YQrFN@)@~RKJ0~)iYzm?%B@4{20KnNOtD8OmC(B^Js+18 zw{w>w>s{ft<=kWmJHM_&kL#LWT`G_~5+}du$pvYMt=!Ejo1U{t|^pN}XAwp)9Ut`UxO4qg1X}A>wuqg3`&sew2icTM8VoLy#7U2$tmiZN*YMIDyPgZo z#6MJ(8Mo4jca@W>wlz(NZ9E!r+5NWstciQs3P!nz z+g?>u9OYwaFXL<@!!V~5WHg6ImhG8TSw=CBTp_dUSbpCub@dLuclkH{-=D?vvL)+= ziEVgxXFMpv?8@3c{aKQ#6<<&u&-mjNpDr+?vu>eW?F@Myn@lR4>};BFbc`DLL^_Tl zDoUPedvX%GV!raki5=(TMT?wFC5IE%xY{SIncl{f>`+!JH0)v^62I1wV^W9y*hHlJ z%;szyf4beBc23@yX4Y4B9D8*%^%5K2*jGmF>V9q2R_*$D{pPmN^TF{~gA-EqvdsGR zJ5BFSBsd3k)pcCD&n|Z8vES-e-m<7pC)Cr^d$70JNAd*o9cJ3Lj?LV;Ovb)NdMJss zs5-WCYq2L0`?Fg)9^6?^4AE+ixB75qiBQ$r#)%T|2U9nBdFw-4@86q=A`*SbkMwq= zP7kaUNMVAmB_c1s*!Q?p?_-_!V1KE^27Fh8%U&eQSj5B4N1S7+Pg~;Cv1eRkSDaGs zN68%%4qBQySD*Yo5=xm1P4rG=hF3hX-df!K3a1t1nr5jyGTv+s<#4v=>cV>3M07*xtz6mY9r(=y=xUqxXFqinx|N zPjX2eDCeb^c-QVZN7rPkd1WoSJ8kc+-0j{U*gTOlFD@S+77Dqvo z2B~}7y;dCE^^$aFr0byn4W>678jk0sm#a$^iByu?@7HIT&%r$XLETzu6&zfTi zrimWVug*RfId^B2foh`Pf2Ke}Hz2ZTF+Ny~4;JHt#rR+`K3I$o7UP4(_+T+USj-_nb1 z8{wGyXo_P{Qj8EOAzdK`lf>At6X!&}fB*-(xsVppMV}(Mv_<5%^8|R42t25Uf zx43gc+d|j+-l@3*5-s;V6;b?BirHoK*>{d6g{B|Os;z%gK0Y-pC|yfbzHtUuy+O#` zY18x?s^eUr=J|&&q9Wdii|Ab2FEe{LRANdEar~TZBFWFZ;vs(3%WbahQBj8F&-T7! zKcaSa@{q0j5~JM-e1p4uBFEHgQj|_C*Di^;dzIa z-Kf&!^$sWPDX?I!+*I?b;dD@SUzOJF^;*GW&agA~X^6V>HYW*|sVllS-?c9q}~J{@2W_f*M4sdL_B82Y@5@aAIS8MI!4?{=-f(Y zFS)8i`(b$k&sb5T&MZap%=Cxz52IDC}@$JZaq@N?zvcpIm6wTt>Mzb(4RhFmmHY zf^*n)iNYJBnmmqnN~7WWZzDDcIV*Y=R_QYkjb%loKPb@;O55J*oqgih@vxsENkn!% znt9(jvxG8Vy3J}=g3R@gWHXCr3h!NiIlZQrB*&Fv; z*(dEOT6Q_7S^jpkl>GBIO`W;X1dGV=*Zy}+^W)l0O@>nr;tmMqGH^O<`e>k9OHhfI zGLyb>Ioy8zQkx7(X7oLrc|>WS_Pc7E(0WR#x8DojY`W&H0h5jiuhw5bbyqMe)8rt7 zQ;nEl$fpMSq2-DaVH#Wp>%^3<=zO^5`;qWAHpq^2&&ld_j)zdxBZ;gQ!EFU=3JlC= z`2|IJ&H506wq}K9UR-G=jj!D+4R>GIp`YdyAJeygDUWJoXPG&)6En7jdrc@&!f03N zMXUE~#H>y+;tCGo`wp)PU(s?WDtlAR$|2H(*=Ds2JiTQ6a_7D+=*agCYWbOI>^F`q z9kMo>@*|{Bc0Ln~&ts{JK=Z4#xjkZ>PE%@g-=ihq=a4zg|GHfE{H>IMP1H&?%VOB& ziu#fIln&Om(u}mh4>1Sk?5*7FD>DwXJ&;k7sIMh->Zf{~e2_?;7ITgw9qoI@&afq6 zg|P(jz;dd9z`i%kC$bMes5o2}b3B~myiMKvGfP#)YTloq^Gm8%3o^{j%j}xG`atx} z<#7(lidCx+6o+L#xXn7TdpA|u@~|>rve<9P!EO4oYNLYi2Dj03chhPeq7Gl}wZ+zo zbs5|rc+?p3D0szA_mmL%v#g%0uvecv*1F1T<8LPU)M((@Q>sg6#XvMc?Ag=<&f!|= zzydat_>4JwdS90uf8E%1oY~n!ZG$y;p5NHjgp3%$uqPE)~PY}9C;zv@~PTluG9S=WfPWE?t)x1ro zy4dsf>EOtn!8gLJZ8uaeA4r(isUA^2@?g75zDX$=dt-7Y3j3n8V^Z{zq>K~hfRwOM z#>Ail%O;z%%Ed)1Q*Tut-dAEO9Ot)osCh&@vO*&2L6@z*0=v!+4_6k!eUGZ|!k@H;I8nXA*d1I69oKd?K=~Z^z*{gZ-qmrJ0d&R}6X892P zoh%(Em%X9hyH}ZrFxwz=#Z{sk<6otrv3l!HU&9uyvDT`jdq!cJJ<|Oy*&i}a3#nXs zFtSPfqnjTK1Ijo}s_%w%h{$ybE1chz#v2Lt{ij)S3S%D1M_8VwHl1GoaAUvHn}X+| zJRV+|{ztiuy)z!IaCw1wuWR-w|E~3($kq3UtUq`w#MO5B)QwIaX&WaU@RDGdP4l%K z%Xw2(9vS{fUNw%WbJb&y!^gKRdU+}tEXd7Fr36uN{ujbhhDKM}TRqDTGPLbvIIOW> zc%0c@LNLnTUS)I82i}KUP8*wugb5e+O(1heUY$6Z-D=D{@$`e&vGFT20{SlmN7k3G zsMg!esxi^C=RD)psyzXiHGad#Pqu_zXT2nToSj`U*h9LbehP=$V1^oQ;q6-O;bgbm02iN0Z@PY^SLXIlYYilt9($qld98{w z+k)NGR&836;Cz?;ywxLw$mr^REbHE^jBV3Wmo%)los8RY@Fbi5MiN!DOsn<7$6&A1 zLIvZ!f-bA+4G#z&81Z-)^MdLq#f2?CuW7bE&Gt4=ou6Zz?y&m*L?6`TfDM~DCBjs99#JISZ za~-jD@jTh-T;ZVOKvosDT&|D9P*dIvTyJy2B;l;7^}(OCR0JD*{?ExIHe z(O$R&PqxB-@|~0?zch0w6A8O5#V>Zin&$?7N}F(9ej;X{65pyq+f%!j3@PR1J`f0% z-Jn=|$}xy6J?>7Nr4y4(<4@4#?>SA z4?o|iTh=_2eD`AQ*_2i4w^g3?-@2&1NRy{O;7P^6Gg606%cNnfOiv*)E&NC(c1^x+GIPoy&2||>FQTz$ zEQ{^2P>njQZ}xB;t$SH9CP!uG*@jKeCpAAUb3@PFXf;yqHeYaRTt0r?x~~hL$t`u_FFa#3lfk1~nGx>v@t(PZ;oE- z>ApEM^eAseIPK;^X9LF`+@816F*v~v<;39-gJpNCJ(gbFn8p2`Saf#nTuzrvXtV#V zkpug9%v5Y8QlIGdP*PE-I_*2Xr^>l)M0iQM%3|)TtXoMEw`X2TtSzEOceSk?f4aIf zuTke{C)S~np<1$BvFN;_yiLG;i=v{d0s7{aPvorQ9oW?BxwbSdlNs*c;PpP#ZG(c0 zWW4~>>fK{F)g7au*Q~s+5rlf5UVfAmcA8Z>^+2ahrRJvKR(#C{wMY85Hyz&4D$CU! zILLB~@1iNF||wLJACzOZ_1e5TFTI{p#=f_4l^|emX4y>+mU^8OItp$E5=*5sU}PrYa3;ce4;Y1h(0TXE+N@+N1JXLlud zTdlt6ho;MmNOAPsr`C1Zdvc4uqM)qXQGJ`|wl~(|3h~m}QE&5WGAkRr&!$au46Q;U zXDS<3z*32)&udsKOxMzhwmoh?wEm3UDRH?I%=bE`R;uZE%CEw}$^}PMQkExfx%mvc z$|YiR!bH+GoO$a0o^y|pF=pA+5s7)@3!zY_wO?XCBo z^ro3z-gMqs;;g>Ky5&sNH1?ODFjf522{V`IY-M@vJKII4?&VJMgy`g|$FG<^Fln(j z(w(nD19x-S<%WBeDMF$;PCFfa&0yn>Ys#w>k%f1ndJ z?Cti@dYJ*E;zu*Oi2ifjmj@a-&1D}R=Uv-(+FxaDy4dqoR|b`Wl_$za%r9?8V-Au8 zTnBPON}n@Vb0&6O)F`coWnOHhd+IA7-yW#b*S5j;m{?tc$IP{IimVE7~t!2w%{#8JU@xdlyK5 z`h`?m?Z`MiFQi%=5#e-pssHm{^TeCR<~8y+&+ISoIFzgH&Z?DiV`R)ZE5~WK?(5lS zmknN4NaO|E_49x7Mo=;ZdM~VTFsE;oUM1mu`v{uyVI9`#KeesD^bU?rq?=R@9aT7W1j;8^lDig zT-%RI^Wq-Fgf8O|yo9`;t6cfy&|QWPiZ2C*PPl1$z6jNMp1sr5Ota27@Csx@s(GNC zCI6cEc4%|*Rq929tkKvpCD_UQl(<=QY~aqvgmf-erxk2>hE*cBv&7LKz-7ucxXPBp z1{*FD^0yj^MBe1qJ8`6MxoapcU+%4k-97i6Ta0eXj26{ha3c6Vw#OVllYd3LJK`Ke zRdfnde5MG4A4Y-e=81_-9WN{zlqZl;h;<)ZpY`3dd#ii+%^l$fhtE_Kg_<5E z>^GP>YRoTnBeZ<^k(%cx(1VGMU0FqK5!=FtIGmT=?VVO{?G~Zesw>FI=yhIh*Y#N0 zv4U<;^ugPX@*Kvn0q=gq{=2nxCJyd`Qd;DaPrS!i(S0Yg$(s)?jT_2E>n^?S!mJ!W zmgJ(}6s?_A$cxb(3fykAay(@p(p<@pU9LEe;^0Vs=JJW|)PUW^XZ?;8Yn&d=2#t%2 z?()uJk%$u+H?hmPi7hX4ae*=PgSpInY&=uVjHv>>R}WjLzh*~{GCr8O`)P97)qb8B zYrDW%O^{9I#{c>R^V+<~!wm?)gH~YqAokZ+Q{v+{-9cwPmj0Ng^RCOkHnPx#Y{Gn(kOJmNEHzd4it^GHl~@6SV&R!m+Etx)oKUN3pSL1Cr1>r zyp(U*U-p-|*uRR@>)i&Zv`^pU>j}Q5j(BIy7ZMAEg1t1KT1V*@aCAN9@cNUn4Pw}wQ%p4d{);_`RuQtQ+X0(5 zH!?NWIe6bJmiN8jchPC0+jO!NpFF;P73nO$1AF79dqRk?ScAe&c{%*45Ke0+!rBxu z7CCV;lsPijW1^UFwsC4B|8bE?0Ztuinep`rDf_Bt8O%>t1y3bzl}DU*aMvv~ie1a( z0=Y>X4QJ1E2~LbD3>St)a(_n z$;MUMKF{`4U$5hpn@|hNKCn$j@!Yzoq8%xT&t@rWc3RXQd*sK>(7olY`Wm*AZe5vP zjE3>Yf?m%VA24296nBMrvcAwD&39}N-4V=vjNzpJ(3D>14Ej;{I&#ka4J@a7+z({B znVgHYPVySh*MHt^Y!uH8%b%`y@6B*{v7%+qYE$o(`D`RljER zZ^_G3E^x2y*^`Jy?SrJW$`5=PQ+n4_88jw162R@bcK4E5MEm{x@Km*Fo6FtCgb{O} z`!BXlEIphOy?Ixk==h@#68n^QpAFAtdddQOHgC5GxqOgkV=Q``kY1Xu70a<6)K9{n4+1DjvodKC`gSG(Be>FH&$J>JzE(4K!#+%c^9 zs^z|BnF^wMkKuQ%*HUQ{;X4x zr>x>0k7iz8-j{`o89j?~r%d%O-yO7CpvXlLTb}%}yj@lN@%!5sCp=0HV(lK*IGA-y z1^4IjFPVMSPtiU8f7rXnCBfM+0mE(Ew(V)#wrxz?)3$Bfwr$(CZSS{LdkXunD<|+K zRYB#-okzRl046YHH{JY}aI^8yq9J+rU`c2-9ykOgG-& zTk^^>+1Y7mv|r&yTvWnh$8bFhtTQ;{sFoa{_)U);ZIHz3hh}S#j4T*!fCY4RH&k*K zDIz=8jZe$P^npq{kZ4crjkymPYny3ozftsq3?Z4RXk7thyy@t4Dhp2D@(F19LGGKR za^h}}<%~oA5L@)SP}q%f7-gHuF!>g*T+$(GnT7ca}`661MkG9?0^ z1qpXi8hV%RN$bofMZ3BYLCs@hv8?wzQsdvOEFNivqVlDlxvHF+@WQJ4aR-wd7^Ilk zr+G_LYzs<#hLoB8U8Xdz=(Hwm61UtFmH)}2ZiW56boy%7y`xjjRyMi_(6q{?=SiIr zJnDGVv?NTKl?|41Y|+W%WgSHftV0*{b~=?>piwe+BzpoAqt1%R4fx8DIvU$Y0{&Tl z7vz$_VGDFvs*#hmzd$Xv<0;%y*|k_KJEITBl;c`>viT$&89i~jy!+ouR^6@|%Au_p zncnaLhRN#>?U_YTQ;WEBQTApN-A{tr(HhOIimH77rE=8{Rh*4iyS|IGyeFW21dC#1 zG@O7LO839D8xEQ4Um8nr=De+u)}Bk;O|0O?bJ&U!bF=4cuJ0^uu%dWwOf&jEVxu=g zJ`x`BMRG;R6}`Ik1)57~epqK;LQLvd5CFp8W~cb5dDc)RrxtFqqIYj_AA zqGh27i>wUtCKKkAaZK)hlh8-%lp}9dbVWeT;sNv%R0VTUX+R7o%I-)T96*HG&`(31 zq7IIy#x>7aftRNsvMBZNC*RVxu*@I z=_>25$7OC6DNF+Q-P93oGbymctOTLY&ne{ibayaWy|viJl`hDPe62^Mh$14i>SdXZ zp{54Q5X98nxd5hF(!^UX2r+txy|-#c19wf5dnzviu}nytN?vF{kARvRx&aZw^W_@b z7mhGN9FkP@sXjD#Jhs3INvgxSaqhUWV?Goccs}+3^EU5iN+%!7^@9RhR?%CN`Xtxb zeM+?4gik%-MBJeH)ZA#gfon@yjjZ=uasZYOq~GxssxS_iso_Prg0dpjMJgP57A-p| zqiUe!Ic4)}+EO_Zyf!Q}fI;}K@+}+9WxaZlp66WKkfnz0 z1^VYa9UzsZJPNt2y5tOPt35#L;nHrmx(`P}pN$hyRa~n5NQFADhjKBJ)_VDc#Y%X0 zf}TTH-CunKRZkGL**=X|rasSwRo38@<$NO4HtEzPsYB44j*q=i-=_)-xJKX;kRD+trvdlh2MJNw_f0x1j0q)# zkz3%Ft|5%MT+Sv;MaH01d6pT*Ro1U}a}g|04cgB=>n+VKEvVWnpMnmO0JUXyESbx0 z+!?)lvRdE}tDLI~jJjmTHnP%}FgT4P#o>SQ4s9+SUHBD|yDAnG01gZ!=Pd$sW5CBF zC7ut}^0Qnqs+W0}PeC$T^!}jM9NrK^@q>G9Bq(foBdTT6loI)WLK_bC$|yp>wQXX%J19o>G$X zYxbGt6PorJa0hzTOs9uLCxvdhJB6b!dO@exQv}_%`+!ZzucAUE6oRWIyi(~(dm=#d zgF_!Di3gblpE_4CmtAtHOmr4Pbb!|Y+EZ5R2beHXo&s2b$Bia4fwpW}zKT>*rCG>El5$9MKey`<8wgZ|r96-Hm8FyVFM_2u$z8ScALc#f001TiK{E9c zbz>G%QeFSPsQlfMY9ugWoQ|ggQjirTFT zKpE(V(9Z+Y0}BF&U|yQH zwHldXbfSs2|(!aEjtvf2v25_JxJg&sv zo0`|0Vp+8+Mpep~7YLzYi^b_O5&{?EULzyrQAW;}BqWPauomjbo|Vp%c+Jerg02PG z5J^Kse0?dT57hvp?CNhtlNoV0W|&R1gLA;P;ZxJlbSqo(bd)(P6c+EG;`gg6ztV%T zHpyTKfICIV5^(l~y+#a#hbSy=GZfu=YayA5qR4zsL&I-*dlKi`U^f@2DZvXH``|{@ zYFu^fjX#u-;pnw)vQ?W=&KW0C|M+!M$K6(xwIIHkryL_;HlJ%=>hp#N)L+>VX84>R ztNsPwq2$N}2<%f~xDfM{o5@Y195JD+Z{R*x^K>y^zEq|9Q+Wt`<_sPbB+?I>JQdVp zW!7r2KwVrm4By2YuHF+l!yq@k&KROM9ENu?gDl^0eTjcs=%UV#dGuPPL%(vW{EN8k z6TS_QpQf_j=K=c;mi1Xc*&{f`DB3}49d^a|yyGZ^azP(sarZg7eSG@HOXM3^V19Lt z%NbZcc>UM+170b1`}kw@`cLi$Jiq7m(dip^(04DjcJC3Aw*<4k|4&y8rK5%fzB0tx zApXd60$2pa+CDrJ_;I%iT^unZvOF2_>5wW8O09T7ogSJrql_?^M2AH31pe8)l%knK za77mIG?U1ElYuDbF`bUZuIPmE6KG<6V?$~881@rm%0V^Nf`dRY+F#mr+6o3c*7}4j zOacN9y<_{VNLu7K_Yhhn3ow{;>+gaP|E(bM4#xgZRQ)CGm5Qe@U?Qryi-#hSjaHZB zc^o}Oc)d_2A=7qBDrdBnzHM3+9rqR_AnuphuMPOa!lN72^$o>uhz&61Ejx${a8LdlJqQ zUcqA9zmtAqWNi{>j4VWeQ*2pf5gIzaCWGe~ z_DoMf+66jQFgP@OHl$YT88sRNeccsTFEIajj>Sw}=f|sw)m%uhzn}#}Q=AQI%txyw zR%RQ-GC6eTPdT~}GCTed6Q$pO?U;x)_4@h4)G=qDMRe!bj37rIFXS1dsG{jM0Q1)7 zG9s}i>4OgtMz1uGJR0qWeVm4)F!TfaP3A_=iUrbo`+sTq5ifBV(b~o*Wt;89!)f5&m zN)1n8DJTl~R!a!3Kf<3ghtlcRj1Mc}x_l&xVZs53hfc3em#R1KE^`0wi$F#^;l;44 zNz~BBHpy_b)kU4P?Q6FjLR;qQ(ld?%T8*&@IE0baKXv4j?5VZ^j7+!lDYf>Axz!jo1}+1 z-=0CBdj)Dshnih^uTtfeWCJ2SHs>*9chX5;b1Q)U=cNdGBD$O(lTr5l1HLkLNJZ96 zDzTi5l{tVheo>fk*VxI1Fl)>E)&dRAxbyck=8)vi;W8V}Z|%pK8Lh(y{z$16Ai7+s zcZ!i>jcjQyNE6e0H=j5v1~OykJP_4o2Y^ngjNP2<=_3Q&LYPw)ofYEf@`2O*iM6MD z(WZe^cQG<1ypMgTdp~s5SK)Vc0*4~hYxN6zdPe2ozJqOg0A+5lh{bQNiZUr9L8LhK zudkP0P@skThc^Y~pBYqW;1o$Ot+Q=kRi8R&_RB?*FGRNq=>w7u?4?d!Rua6(ALeVy zo{*T>Ks<%85xjebtGtrCF%MX}ff*UiI6$f$FeJvnbJu6G{|Y+G=G{+nVuelX)EY=_ z_y8`(a!+I~6WqycivNbb*9l^D6(fOf!+BwfsUH`E#RFTlhdYml#K4 zY|)J5;O@0?0dC7xnpU*?>fZVJy~Inb+e2ohe~BL7^F_E=WVg&U#_CBIsje2zgqMsa zyyYb3DWHDqs0%~RrdkDyh~YH3Jq5QXQoH_paVJj#7}X-Mmbov)gDY7D8tLnC_Ss8} z`E>lHt=k?!xEAKvsYKM9fm=m)MfHv9!QXU&9Q0da?L#!)+|A&oXtE!lB*1Ru?M&h^ zBfgrcc+{mzLLNxDskJA4vRC=_A1>EG%btfW<;&dDaYddIz-&S@rq4Ts&y9amhtPgpj0I^tLO zSG-9m!5Xlb@CDYvMFX*^zQhJ={~F{?e-MiVt44WB7eRU^;{94KRRsvC8r*V&DT%uF z{#>L2a8TZSIs;Qrmf-p4gp$2hYaG@q36lh4-264P2Ed|C!n(3NpK%Rx?_Au!#0k+s zAsR282YGyWaKaoy);zRJXk)nurwsBiC@D?^*N84%r^v|~M_Jeuzkh=i)V@RyafGu& zp?{H;4f!j1$^}KtZulc=+RE>rzSXMUQv@#>u-Z`DwmZFB;|SlsU7Mo##)>W#FdL{O zaL-fLl8`{MI5M{|)u3;;Fi0bpHLMKS)u>XgtwwkS`vGuFX=3^mPFZ+5mV^v@U*}1{ z3p(of^6%lC5*+H>H*n;EEKZzbG`^G=U53%$oD3-jn1zcEW#pqG#|{=6$Z@gQeE7o9 z^atK+uUY&Q8|YdJHjt%O|LijgHfIaOUw{c!A}uHaxO^qTthf7Z35)hA z=%|lq$w-oW+ae8d`Wqmf2Lh!oq<)#IbhN!uGw5{GAXB~9XysT7Jssed3I>ZOlNJ`V z3ZQexD2=@hTk<|5>DBk{fY4tP7#qM(L759D;#^-gbO$&zLg$R2W9cG0`s%?pV}9li z9^3Uw1tK7K>Ncs@X9Gzk;qY$D>2asJozTK3jt;_*lii^S#(9BZTn#c#Hg!6d>EE&g#EG7cMN~6MsL>B)5%fH>?1?;Ui zc{9E8d*dDs9F^UauaqMi>f5rqU`<_SM4W_Ah)=YG(_R45hx$j%@)_DhO}OUh(a^VK zkn_xC_3d3R;?FBWi*M1@=z}?u)({PT5d}2MwNcAD0bX}d6%8>F>H9Lip%aNlLJ?b} z<KDOMJ7wU$0(VL0^{D84-{JUz^g%`C-{_XE>ywS z@&a3;%T(W017$OHV}A>f!C>2}!Tu)*8A@IfPl%)W(mTvdef==_lWzEOrhrfoq$hYd%37Kp z57xaL@zGYZ1UODBZgfuCM1LUV@w!)|M0gqBh7r5ICE1WJq;S7xnL5WSTjPayOrJi3 zDnNr^+I!ZdCI7zKs-#v-J9YN@$~p0QTs1JDg9dH?FPl979#*YP<;59hPk-K1v8_U0Q9pSXfoLe%RjIy_s48e2N>VM4JVe&GQe8f=w%$@W*b(XX z$ZXN$R1-d;fA^`|P*TvGv)MM-49rrb7ZioQob@<9V6|q1+YGfB!h)vCLYs%;fVJhy}LPjBD#{{@4PmzJ-|- z7a%o~di#y9{jnMcLNnkuk;3Tr^PakC=ghTvk*LTvmNewLMtS^3ifAKd9t{d{cSm>= zU(q6pp8!u^mSOmp2O8pDLd4a-ojSy98}2_C5e9N$AMd`(hC$4cuvz2E5(*jepz%TM z0ohUInTp>aQ)eO)KPQi`!`uu?5w4eXHE1zzLDY85q`w+}$2hIsVv$az4PxdG8#Q4% zy{gO%#h`U&Ub}&d!agX!)ib=P+y`P8U`806ht-$S3H6sw%QE{ z>XBq7 zE&4*5Kc6oE?xT>MF4d=WfHY>+Pxznl7Q=?ji&htKn%YF0{CjCU8ufzYQxy%AQUNVd zRuwB4@vW~=({+&f0{8o+t!`<7ZFHz{H_1qBM=?dT(^%;l!DoJ2_zuz=iA2cxOe1@4 znF77Geqj92(Gd3*dr!R9>Vgy^d-||wf1XpHH%1Y6-C*O>d<>_ym}0uovt#ijYWF$O zK#`gceYI-oaY=q8PA;M`srPA|TYb}V8$qPMh^C&N5QO-w+S~YGyoMauIKIrZT z`@z1iPb}|ql-Vg)TzC)d zO>zO)i@ZI1bYQza527>h$joVSfh=Wy_HVF91RsxYiCBv(&c0~S~WWg&p<>aO5wdWpTl(%(PK9&&D5e2gZYX3TOZCU-`H@o6HDAa z1OHJGlv{%&%h5s>xxOJRPFFoRCR(jV+tTns&z+*zHwVgvKq(HV8YjH^XQe2BAcq>! zD-?~1AgT%$cw7NuSHCg&)L^no+a8NOo6WD=kCp~z^`47Nwtftf!weg?@>MuDvbf}8 zl1SCDXfsTZnYAly&x?!n`i$7Ns_n8oUIAAbrSs`UB1p)A>o&@t0xZhYZK|w>_%eZhyehV+^4XpctSHA|}BcZ$4*aj&tYUfZO zr)anFccF0n2fPBs<&j=*`v$M}PwzUknTRQR1^rF$V~ilu(sEgQ1^#-uFORrn4mDM) zpj*3+wElAsc1)Iz)BHFbcUBn6;vyfRI}Bf2VFbB^Jz_nd4sv@iA4s);lD|77kMp70 zgN99N8cGTCEk9BTPwq$xR@5TIX@U~nOwAK^R0P0jgn6#2T}xb^;z_Y46pVY$(W&5=R6Z*SN^@-o+{%^5r2f89uIDC_adI(38{LB}S0gD?tle@T5Ciwl6XH zyb>X*9C&klRY91f7fPb7h+s26&ANwr8(8bPXbLc@l4D7a3Fy)nGL1m#$2x)1pY?_a zpH>A<;Zq{28>D`%7{@u9h#E$lHoJbOy%|>^DwSBg8vi26m>pF1)Ua`wo)nQ_iU+#h z>2Wt?WAkfv=RE6;Iy~HmDPFDVSn@}=3KT8jknl$npMj$xTj6F?4}WA`;?k2j@ct~8 zOsj!<{i4rM6wtRmhnvEtqSSdfCM8gn8piZQuITg`5us`KuXAHhE6A&y97{jJwe6cn z%e1BJim{1I4FjJKaASu8K4l!XDh3c0B85Uv1LE za^7^d*p@{yZ^G+Q*jo=yd~fh4XBWr}FAF*21wjb~ zUV3n#v(G{Tiyofy4*k@S*nX~rPWThQqx!Kb3;A_VnV9z{N$>u2{SS}wRRcku0Lm{h z@uC~pj2iPXyNWEnzk^-tI7L7Z+*hC*_2(N5{9h09P*{FuS`Y0%z8p1kLgvx@*cxn6x+v`}fh-xJyk@uGu`6V+!UdMXc=M0z_RbnY>>2m4YbQ-*eot`LEriLZhzl(i%xNOPD&#uKTGP)dHvre?WANWJmI}u-I+T@=64q z0A!6)N_V3?+jM<8K^OjbT45w3l#_I4rVO=uDfkm8>iSJ@hU+%b^@lYcp&dcpzmJBz z7HI(IEtLZgiAwb!kpcPeE5nfx=-VOCYU$H%jAK+&mr`_|&V9KSv{9;2P<3td!b>I^ zdiS)9HNpQGls&OIMIq~oyoB}8WGJ(lg|}MG!CPONn>fZF5I;Ojeh8+T<;Rv%k|)|` zx0ZEh2X17$g`R$biC8&^c68^x?%&3XdMOw2UZ@vQfyK{K%48h#+JqeIEH=ePH}ArOxF?=c7nru$3K-x*rpeA~a3CGHGCqQ;iy zPpplidgRU%;JcAS3ZJm1lF?mQ5XbgpaJEF-KW%Leqq<>QWf!Yg{>#|-DXR{(NBf=N z2D@4fFb5>VdhG$3oOc{hvQ)BOa0!K!TnA#Z`OM-Zey}7ZIHLT5K8pkWGVPO=Pymp< zHJpzkegNcN1w!g!pTZ5Nu0)H3)l6KfS7gZU@95VpU#NNtR&ieEQH^N@^@g6MCMaZ! zGgqiV+9a#a8Am?;&WZNF!xQQti(*_^1^2IYw*9g8P?(3cO@E_9R2gC%^44U8&UHKO zHet)5HDg}mLu;hph7gE|*;30C#}{5+oLAs@aKVWtDM}g-STkM84rRU<=LKyzSkPHp zw}VeTHVP|O!*YKfqx(ebd7#g|UEzQXqc`E!2aGFW20hn{a9R$8lCkvXhX82Bn*kap-ci(eSfl$Ui7_YW0t^H;a~EeR|!tk7k5miTJ1p&6jh zzo?TaC{1rDF&p!?#_ngR#+~S(HrTLe`P`4;uiX)y2%*;Nr7`SqUq9OO@D{{&#s%f_fQ;{A)MxUeVD0$E za|b|~HqN@A8_l?kv`BCj)&3TEqLEh;G1E0z!iR7zfUmioMZp5Is6~CIt9@&rh{7O3 z>sX<5yL)F!PxxIM^L#lCad?Gq1sZ=CBBzMCa9i?ie2w3vYr`Ulfkw9=7+ljN81l~a z_sgjwLNsMN62WjEPamtKGop~yhVsd*OV6}N@+ML!Mb`2wLtsTU!{ZzNKfdFT!&#`}(-$R|oSq_?#DLKwYs;{ds0Oe} zrhZJTUFwVipEd=B*<6R^NpG6Hv=$JHz!t4Lk(rl8&wQl$ds+j{j3)FMgl&6m>BWK>>)M*rhijssthZ8<_a&W>3oUU$?gpvKuD6J9&2+D0 z9}b9t)E8OuE;Wu1P^CC4$uKPNjsZdAM?5KqaH@7T+6v2ckiw~hua{TQ;gm>ct+vre z$JD2Q?jeN(aP!46ajBd3)>hMsDByw=VfE)BSX4^}vJgu=v_h;xidow1`GPI;(UkRI z#)tgpEV+)<70jugnS|CgBD6RuJGPb4&YnhrZCK@TXZF7#6x9lclfh!AgB;v#odS&2 znz_FOfuHg=b9Iv!nd{nX#($`xrW%udk|&22^ZUV}O}ki~@_Sv-{XDQp>XiRJMG=VP ziS>1Qc1Ra=>7TsPA)=1RJFnH?YKUI6ErdmFJG-e8#HYR9<#$c77j-Jw%9^VHq_ug$ zr6Xz4>TzHDd~3wPEzplbaT))UldOTQ`1=Fr6D4kle!tcA5LfjhMp`2I8fab}jA)}f zX$m2R=%Rx$^m4bV-`+<=neJ3pmpFet9cT z&KXPfs0&Sree@%3NL`+OCBzsyYzsLl`y}0W@%r*bCdqeoZcIv*U)K8xwUF*}T}}++ zBPm^O!FY&5O1ziX)8|Q{+Vr3AU)DA$FXfD3!$M{QVloGxrlv%0`u`}!0d zdoeRfCUwqBp)Kq6?SId)T=-CedgF{r~TAP@y2ehnIl=~w?Fl9)XZgA zAPiGxp+OWuneL99{9{bKw36zO62edw$l1vnMVin;I&SCZp+@F#ePKmGGVIxAUxN20 zA&`us!v^Q@&4O!r-^KNO>)?%Kxmo++ia5F=dzV+sBuFX(~u&b48f>K=BJRJDAEXC zx>uCesZXCmn3OymEfDRQg_%RjsZ~@@wUpW8G#(~6C_iSYxop7%6SylMf*R=qS*hpn zw`x9msrknY6Cq%a(NG{eAavSo^w^r1=RLrRmXUlFL-q@)#(^e-%+dv^Ux*LiivBn1^YOlrtL@v&?t&3iJI@y`B;&Y?+ z54bCJ_>s0C;u0Cc?#%yXs05W9&R72f8U_6-^sWE6376SPz>Khsh=A_fNbL$DX$6FdJ4aw8{J+NZzJ3-#Y(R~%i<71CjJQk8dKpho_1+M#9}h5KJ=62 zT)|?%e{BLJ^XevrchJS6`6EN2Svwy)?&~S*;cDA&#VNb2W~jgX#?Pe7v$JSI^iqI+ zf=oL*?wYEJyGkEs;m_gpFYK;UQ;>Q@sQErL&!w+DxE3@Ndy!I`>D_Qg0WIcuUS|wR z5lV2y&*AQqoPt202&dCP2T&E z{p-t$1`2mc66oBZ3}w;6zMzKvt>mv=Amt!b#|=4|$jay)+@bAx^EvtvD;tny_X-d) z^&^ic>fgN;^Ss|)pD}(Tu%93`>&C9)1M?)0+aBftmM26#zneX(BSv)lLs{=~ZE%Pe{}ukY@Z+E}Xoz2|PF3q}#WBO46=@q7o-OKx!BOA5t>i#9!$B;DZ7d)pxkPxJW2}T&R)e zK4u&N^7O`kXFQhhM7ByD`qB1|CfN{|NE{tbX>uY`R;`2#4DSL#h?QEvVXUv8&5lhB zlLP<&AkU}F11K2GnEfj7-F(D$7H?c2aQr22lYCk~P|rzmc+(H6s72drJw{l^i(Akm z<#iB!o{y8kFV60bwPl`BpR~yu6(l_$&Y(9KHINf3OFU&|M*zUGZ_O@lfa^P~Wj7AC z@tD+;p&BXmBoYLqbZcxXgpGx+U11^uZqolw5or}Kxr~heHM9>~ZfAF9lbO-;n$nrui4I1aQmZjRBPL-i)YLZKe~cYe9LVT_zGGC z!#L6)E5@!&;nG(`&R^SzXTfwNdGlM{?qA z_s7k}spQcmX%5N%9y%by`M2!SiOaHjU`jJgAgnA!GMv~Zow~VzG0whj9rSKn*x)i(-%5o@dJuJ zST@5xQ3hYEmVE)8nVr!hP!{(9?lb{SEauDl1(8Td*99#nYh2X7yT5D^(j+A%Vr7+y zvgE_G`fXzRNU*pqN0@6}Y_0pKJ++Pv4{%TP{-NJm{vx)EC~$B^j2^CAFLB8#@La z$J#%oLUrE`03>giods%r19VU+=<&VQwSNU}`+W(-kcz~IKw1;QH#fv`FA9Tva zIfD_wh+hT73Pf>Lph8x68w{PfMupsZ0h>`B+>7sls}xsA-dS@o9WC6o=FUClW;z*D zhoJ5nUJ*Ku;-@_Bq)mW z7_v{mE!UTu8YROWns3v>5_eyuI4Fc4!EMja!FEum3XS36&qov7xWUUV-s}fup7M}j zHWmBfswSI$3yZvi4EeD;VcyAD=)eW4$uGt0zNvgh z@%>n3O10q&ovc)^kmjf60p3BM$n7uje;cUlS=?Kb%~@7M=48ME3Ml>*-qKEoY0I-4 zf+a-OBo`lZdp`^5Ytr`ai1rV3!(5t0z{ziVp?`P=!kj~9-fj-XeFGhj6hAOnM4ZUJ z50WS&`BIgCx*lM!O>H*bzsDWjmc4*5_dcm0IJx|Q#b$R>NO0Bz9p3O*X=)vq9|qP$ zk0Rvhwm9@vI3tMy?sWj)|AHI#g2=gPk~1I*a`WE@il>`%@{@pBw!B28;;1Nz{ElaE z=p-56w+ymfgYzjB6)-q>%#;{0rO&`N7?8(D=K=Wd;yGhm5u_WCtCN+`wa=IJ=)SkZ zOqmul5shn;Pjw9IV8-@|B`#*%D+1Wad9eEx#1Y9*U2lD94UiD6fEv$v&zmxI$i*@oJ{g9e9SkK}I z*K>0M7+?SS)y${r5^H6-Ch+&pc(A{Df7RAo8c;?KX)rZ+dqMsc7rlr*?yJABPs1exSnTM zW3IPQ9qg}P;YQDT9TFOn!N4vL2+!s^UcROmH}>?J0SQZASiXHIB&65?0lZ&be` zGcy60`OlyH_bu6@CilW|1Q;D5f3}a{k4$UDd}P^wU!(`Dh2ErE=M}k>8u9k()*UEl zMJeIsJ_qRvZt@Jq2a!K~XJxF_)w!Vve131|;v)q9rR@!l!(L!|QaxLz#h$1IF-pUj zzP=Y23o{w|bDv;CrA&GYEMgyxzUf_%DE5Gm>=+`{1YZ@p--Lk(=6|gt2=Am!v#wgB zEF9lO2cT^})S}D!LxY%|lnQ+2mA?ZQL;_n|)ofBmJYNX!(b^rn;;5tFIcScZ;STzW zEC=^z-utP<*1poOUoGLsF=^C9zq|64gOx9;Gv8C;O0!=z!ypLx`tgR-0T-ekV*gCMG9{ zVp}{Hm%FbQV`)uBF|lqV30$vr>8t-~y`^ zXue(;SkdPx+(m$}^!|lYXf^-6wd{h;g*;twQ*-DKaWr#pIpG_ZbctNUwg=k*@9*vF z^oXfH0eO?}H1a;+h~@PwBqAGPy^pGxlud5QH1B-?n2oA8Ok zyb~P|SBku3dfrv-`@wOOz+D@)oK;)v{40%tTNPK4CJNZ?d?HVz6hf0kUZiz&Zz=CB zNjaE;i@r>CHwjFFE#L9{67dA9HA`T?!NsIlFvB%LGl_MWzf^O4>g@?sYYqCh=8@ul|g3?hnze#}w#+(b7OcA3%1;N;&Eq6<%yn{O3*r8n02 zcx=MAJ=O`Tn%OFVE`Nam)1=`-_|49|G}=|RUJE-<;7yOP{BEP`12{FZc=E>1-T~sn zYw{-QNuYEua!YLC@Q2(vwBg-fGowKm0E3^q2#ial&o0B?t``|_c+6vMd=)ZJgiU=Q zd*7rck*`sYFP53nAYqZca_o|frDayyrGItbQ%r@Mwx<_a0< z52%;iS&Q}DZ1f|5GuPpn={4r&H5zMEX>u#;K{dh_P8Et^>MISL$TfgZA zjZCXGb3G@fq=U79$Lg9t-ZO=OOw%;a0^hqk=FT^M#B)9xM|a?h@h}>s+X?0}LV0i^ z07ulbQ6?!$S#Z@kR6q1d6`!+LL1QAe^#u&}A191wA~R>7W%W3^8kCW&NspPsQ;G@? z!a%nolWdO=Rsqx`Hwox@{mnJj&~S5`TTS?KTQwj$VzMX$b^32DPw9%h!|qlQmPf4p zf5yf}LKTs^O+iww937?s4wpZAQ(I8&!!5F|)u2(AN+BD?eOR zC8H|LSOtw-hUpk3S(EjdtDQx*%M zN^5msj>R1qIm1GvYY0+$4%B$O)jRwQBQ+tzS7CjHw*yTqqcV#Th-n^k4G75xBUk`v zm*n4nY7-99(0sqpfcU3kMVth&F}kp)@@ZkTyHKXa8bk@ZmFN(gn6QUO+HUPp%ZZf7 z$i?}W+PhrOWFy4Ehz|k-Hmo?p?1wd1L#@3}*WyxzN)B$QscM70OK>7X19U$h`y+Aw z1tsXqxbVSS4*QyJnRNOVYW>q=tuHkhw0~;dWK$CdtLnaq$N!HXJl#Rrx(PfflzIw7 zIZuxsxK4i}ZqFFfpe#oO1YmXC`Gg*Ej2}CvKOz@S8o}6INM?Ku;>*AfI+z>s9)QFu z8o$D{W}OiCphUo5>8_Vad8S4{=!kQr4Ch!=BZL+W=+m!uyb~*p!4|0s4$e&Z?ZaW}o3y4hfMG-T#y#PRwS zD522g!Kzx;Jqm=j_M5sqEt>O~yE*K|-7mR&<-FgbEA^dSNH4cD+hE1E1$TAQC)u!1 z{896U=}fy|`UMk2Lw?#a<(Q!;lt*;e9*o);)O!bi?3tZNZpRfMYW{+Gnh{x%Nk^uR z6%zS`az1deN-Au{MuXIU7*X*t&@Y8xyz;7%A$ez|0W$3p!;IFrT9CGjQC%wzbT(*S zGi3g7B3$>3ksel)_2`k^gA?WGhGs4|IAQ$;h7_P@qEOUJJ%`YyY9g za>xW~Y0H`wLjQ+fqEmfS4dg*43wLBssUovReU3`|Od$FkN33z7z;O2W zqYP?~e<^f;?VrC}Nb!8QUWw9#CA1b$XIg$>$Quo}cG0xEabsStR zcSV9WqPVb!w`j&Y zFL#c@#=07Uj6|!iI~#9^ou{ce0e+F>ECrM??#IRkfB#mm;Y|}_x0M9290eTHn72Tb zKTI&m8>}}iEX*>AP-CX`ZPaGozF#r6tl0_^X!HFEK;2Ie|6>O@yDI=Y&*m2DvD>hz z-t~reV{cs-F3Y^kGRzD7EUiUdRG7qm=Ke-eTT+cjz554y$P$}q2`heEQE18n?X)jH zO)sqNi~NF~+ItF7_K3#cOJHqjtSGnWgM!jk`+gcCa9f%cU=|rkV3XeMkR*l#n(60% z+Pm{_DD*dg<1*O_DPtESvTrxCYa}8|gA8tyeWyEiveYC)hS0SPHzHZ1v4j*wwy|XF zTgDz^%~+D%+v{aJ*Z}SS746{J?NdJNwQk5mx0pyiP+kINEzY!EJ=*9xncVxc%h4XE^f> ziDJRMd2toV+G>iX#Mi$Zo^G4P*bj9(+cTo;cz*O&zgLAys5rmIepJ>)r}JZp2zZR9 zuktp02K^*stQ!BzQ!kOpO((HLq4ru)Wj@7eC5 zo-eDXCqc|k3_V%oU8yGABQ|jBG*Y(4VjfTQ+&@m|xO#0|J>RxwxH8OJ0nN6Zp?T}Z zgm&dG)~$FZDoq?_N-7v_DuUckhhlfSCr zmHAAt`STpnp4N;P#$(Bfy&VVLt4)|%I>ua$wcBdAPttjo?@Rc9#OIQ@rG74bKBhL_ zGIZ4{CzpPVHdhYj(GvVaXU&p#p0G4-dEBb%qY!beG3gD8U2nJsr=M zJX8)Q#{(7zjCOU)heK)wT5vf`@mAXMXu;=q!>WzN^4P1G1-p^`>p_Lk3y>|GB!dk~ zFXl`0^-u}Au!r;y%!BjiiN^k7>VcinZpNfkhnrL^ku}RtnZz$Glu7q{!YenMHq8mX zXzxrep*wDMHsVk5_66Udo}1xwVu73@pGDmWR;*>;lrvMD;{(KNHhOR_WntUN21NOt zEpJ|tPt$so>xZyA{`88!B!(nc-8-M14R!VZ6S03MynO%IwElJdzK?w;;NKit85)zbz zK?w;;NKit85)zb}LIM*Kn2^AP1STXfA%O`AOh{lt0uvILkidilCL}N+fe8sr zNMJ$&6B3w^z=Q-QBrqX?2?Hf3w-sgz7;oq3F7ZEAS3lqbclJW$T zM-_ei$uxhe)>O;bQJH&}rDXTX?TzHHxl!Q^8Rp*Jq5te6CFO9lJf(fj=3A@r_a52L z_P1!~bMonbOhtXHL%Y8!pg|crch0LV3!#+P6yJ(qQt*xZuCW(SXDQp(e1MA=p1Dk< z?$c@I`>AdkRq-Fav@KRWXIFfV;8F95wFSqdMsSWjR7`AG?0tB=rDBf}>lPH=XVtGa zeRJ(mMJTs%aHd7Xu|s++xq3Whab?3cVawqx(R6jvsI{?C?^&Rt-~E1fly+a&k2L88qIcFkHRA`tZ>C(mVeq&vjA z^|uh5-C=Oc`NP$G>P{I^>C?W9DY= zS?~KOMH!RF>s>>n(*2o6v7qGT>&1AN1r}P^zU&@vZ!RHtk9O}e3HFBnrrRr{w_ZgN zkpeBwag8i5BBd)!UT&TCDQ@_V?H*!5CRkFRi~3~f8TQN#nl%nQ`4F(=Q59l|c5Hf$ zH%%`nl|8OXlOxBJf0IhnZrzL9&&;=PK7#3lYDbkwj=(iomFOQOhCCcpD3>s&E1oD^ zzM`j+wy@uYV4B{TX&A_-(tPw9j5%k2T&8lXX_BFP zSdCq-iGPdR|4xHCmh56M2VV|3l!M&&W8{k(w&(0AqT)%XT@XHD*@Y)2V=KLdLG9>Y z-O>u5_*kc7?Av+zcWr{@(hfsjV)h0n9MxXc-|mspG_m9QeCZPBMZz8d+x`eHiz976 zuMWh1ivGg6?O~KDLXlJQ;#2s7n1Az5$Z1f<(|Ci|Sjk1JEoV2)zb|$&5u$AX+gh&*X8T$PZ zf2ZMw$%o;&82YWN!wNoQdqi3M*E+VI3Nt@((Hh^UKU*zlouabCo9CiVHSUwsoNbkS zo0O591r*456lS-S8yiV_W9bEvy3ezq{oohs{L&@wYx78p;vq(hF@>(M&9(QUeR|aj z=eeX4bX?`092J!deRa}?v<-Yj@f(H?Nq*125NQPIqqkRHl^Je^bhPwo+e)YhHQZ2x zrjsUJ?}~~-nXRJG64^d8MjG&=s$KXM*~hDH?KD4`;XQ7`=;#X_0seJVIpKJXSdU*_ z8FBe{EPb|32$37bAlOw09_p=Rcd=lh_HgTw}peT?|^JJ0qHZv?5QWF`~# z)~^%Q)Oax+j|F}2KykE3Zo&)=EaLM?tzZ2hrT$Ca4l$*5wel{ZEyzg}eir@jNSQyv zU3L{0Myi||Yl`$yWz&-6YNx^>iG==ji&w1%!+Jl2bGy_r&xRLmUOWr;y|O4wF&O1# zapOr~e%mt?NVj|oPQz?u?^vJ6i6vyNl-eP@G%ZDuE?OsNr6EuJ;U;*;8q`m tK0v4#!dI$CK=;6D-nTquu6a(v;@U9-`56>JB}1VAcHW+m05;mUzX4oZEExa* From 62be792a0dbe9b24278d097fe8f652d307d80f37 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 31 May 2026 13:28:05 +0200 Subject: [PATCH 351/589] cleanup K_KartDrift a bit --- src/k_kart.c | 93 ++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 50 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index ad29d1cb5..4274d991d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5953,6 +5953,8 @@ INT32 K_GetKartDriftSparkValue(player_t *player) static void K_KartDrift(player_t *player, boolean onground) { + const ticcmd_t *cmd = &player->cmd; + fixed_t minspeed = (10 * player->mo->scale); INT32 dsone = K_GetKartDriftSparkValue(player); INT32 dstwo = dsone*2; @@ -5974,55 +5976,50 @@ static void K_KartDrift(player_t *player, boolean onground) { player->kartstuff[k_driftcharge] = 0; } - else if (player->kartstuff[k_driftcharge] >= dsone && player->kartstuff[k_driftcharge] < dstwo) + else if (player->kartstuff[k_driftcharge] >= dsone && + player->kartstuff[k_driftcharge] < dstwo) { if (player->kartstuff[k_driftboost] < 20) player->kartstuff[k_driftboost] = 20; + S_StartSound(player->mo, sfx_s23c); + player->kartstuff[k_driftcharge] = 0; } else if (player->kartstuff[k_driftcharge] < dsthree) { if (player->kartstuff[k_driftboost] < 50) player->kartstuff[k_driftboost] = 50; + S_StartSound(player->mo, sfx_s23c); + player->kartstuff[k_driftcharge] = 0; } else if (player->kartstuff[k_driftcharge] >= dsthree) { if (player->kartstuff[k_driftboost] < 125) player->kartstuff[k_driftboost] = 125; + S_StartSound(player->mo, sfx_s23c); + player->kartstuff[k_driftcharge] = 0; } } // Drifting: left or right? - if ((player->cmd.driftturn > 0) && player->speed > minspeed && player->kartstuff[k_jmp] == 1 - && (player->kartstuff[k_drift] == 0 || player->kartstuff[k_driftend] == 1)) // && player->kartstuff[k_drift] != 1) + if ((cmd->driftturn != 0) && player->speed > minspeed && player->kartstuff[k_jmp] == 1 + && (player->kartstuff[k_drift] == 0 || player->kartstuff[k_driftend] == 1)) { - // Starting left drift - player->kartstuff[k_drift] = 1; + // Starting left or right drift + player->kartstuff[k_drift] = intsign(cmd->driftturn); player->kartstuff[k_driftend] = 0; } - else if ((player->cmd.driftturn < 0) && player->speed > minspeed && player->kartstuff[k_jmp] == 1 - && (player->kartstuff[k_drift] == 0 || player->kartstuff[k_driftend] == 1)) // && player->kartstuff[k_drift] != -1) - { - // Starting right drift - player->kartstuff[k_drift] = -1; - player->kartstuff[k_driftend] = 0; - } - else if (player->kartstuff[k_jmp] == 0) // || player->kartstuff[k_turndir] == 0) + else if (player->kartstuff[k_jmp] == 0) { // drift is not being performed so if we're just finishing set driftend and decrement counters - if (player->kartstuff[k_drift] > 0) + if (player->kartstuff[k_drift] != 0) { - player->kartstuff[k_drift]--; - player->kartstuff[k_driftend] = 1; - } - else if (player->kartstuff[k_drift] < 0) - { - player->kartstuff[k_drift]++; + player->kartstuff[k_drift] -= intsign(player->kartstuff[k_drift]); player->kartstuff[k_driftend] = 1; } else @@ -6043,10 +6040,10 @@ static void K_KartDrift(player_t *player, boolean onground) if (player->kartstuff[k_drift] > 5) player->kartstuff[k_drift] = 5; - if (player->cmd.driftturn > 0) // Inward - driftadditive += abs(player->cmd.driftturn)/100; - if (player->cmd.driftturn < 0) // Outward - driftadditive -= abs(player->cmd.driftturn)/75; + if (cmd->driftturn > 0) // Inward + driftadditive += abs(cmd->driftturn)/100; + else if (cmd->driftturn < 0) // Outward + driftadditive -= abs(cmd->driftturn)/75; } else if (player->kartstuff[k_drift] <= -1) // Drifting to the right { @@ -6054,26 +6051,31 @@ static void K_KartDrift(player_t *player, boolean onground) if (player->kartstuff[k_drift] < -5) player->kartstuff[k_drift] = -5; - if (player->cmd.driftturn < 0) // Inward - driftadditive += abs(player->cmd.driftturn)/100; - if (player->cmd.driftturn > 0) // Outward - driftadditive -= abs(player->cmd.driftturn)/75; + if (cmd->driftturn < 0) // Inward + driftadditive += abs(cmd->driftturn)/100; + else if (cmd->driftturn > 0) // Outward + driftadditive -= abs(cmd->driftturn)/75; } // Disable drift-sparks until you're going fast enough - if (player->kartstuff[k_getsparks] == 0 || (player->kartstuff[k_offroad] && !player->kartstuff[k_invincibilitytimer] && !player->kartstuff[k_hyudorotimer] && !player->kartstuff[k_sneakertimer])) + if (player->kartstuff[k_getsparks] == 0 || + (player->kartstuff[k_offroad] && !player->kartstuff[k_invincibilitytimer] && !player->kartstuff[k_hyudorotimer] && !player->kartstuff[k_sneakertimer])) driftadditive = 0; + if (player->speed > minspeed*2) player->kartstuff[k_getsparks] = 1; - const boolean driftblue = (player->kartstuff[k_driftcharge] < dsone && player->kartstuff[k_driftcharge]+driftadditive >= dsone); - const boolean driftred = (player->kartstuff[k_driftcharge] < dstwo && player->kartstuff[k_driftcharge]+driftadditive >= dstwo); - const boolean driftrainbow = (player->kartstuff[k_driftcharge] < dsthree && player->kartstuff[k_driftcharge]+driftadditive >= dsthree); + if (player->kartstuff[k_driftcharge] < dsthree && player->kartstuff[k_driftcharge]+driftadditive >= dsthree) // rainbow drift + player->driftlevel = 3; + else if (player->kartstuff[k_driftcharge] < dstwo && player->kartstuff[k_driftcharge]+driftadditive >= dstwo) // red drift + player->driftlevel = 2; + else if (player->kartstuff[k_driftcharge] < dsone && player->kartstuff[k_driftcharge]+driftadditive >= dsone) // blue drift + player->driftlevel = 1; + else + player->driftlevel = 0; // Sound whenever you get a different tier of sparks - if (driftblue - || driftred - || driftrainbow) + if (player->driftlevel) { //S_StartSound(player->mo, sfx_s3ka2); if (P_IsLocalPlayer(player)) // UGHGHGH... @@ -6081,13 +6083,6 @@ static void K_KartDrift(player_t *player, boolean onground) S_StartSoundAtVolume(player->mo, sfx_s3ka2, 192); // Ugh... } - if (driftrainbow) - player->driftlevel = 3; - else if (driftred) - player->driftlevel = 2; - else if (driftblue) - player->driftlevel = 1; - player->driftsparkGrowTimer = DRIFTSPARKGROWTICS; } } @@ -6119,14 +6114,11 @@ static void K_KartDrift(player_t *player, boolean onground) } if ((!player->kartstuff[k_sneakertimer]) - || (!player->cmd.driftturn) + || (!cmd->driftturn) || (!player->kartstuff[k_aizdriftstrat]) - || (player->cmd.driftturn > 0) != (player->kartstuff[k_aizdriftstrat] > 0)) + || (cmd->driftturn > 0) != (player->kartstuff[k_aizdriftstrat] > 0)) { - if (!player->kartstuff[k_drift]) - player->kartstuff[k_aizdriftstrat] = 0; - else - player->kartstuff[k_aizdriftstrat] = ((player->kartstuff[k_drift] > 0) ? 1 : -1); + player->kartstuff[k_aizdriftstrat] = intsign(player->kartstuff[k_drift]); } else if (player->kartstuff[k_aizdriftstrat] && !player->kartstuff[k_drift]) { @@ -6137,12 +6129,13 @@ static void K_KartDrift(player_t *player, boolean onground) } if (player->kartstuff[k_drift] - && ((player->cmd.buttons & BT_BRAKE) - || !(player->cmd.buttons & BT_ACCELERATE)) + && ((cmd->buttons & BT_BRAKE) + || !(cmd->buttons & BT_ACCELERATE)) && P_IsObjectOnGround(player->mo)) { if (!player->kartstuff[k_brakedrift]) K_SpawnBrakeDriftSparks(player); + player->kartstuff[k_brakedrift] = 1; } else From d5083ac66c6bf818610a1e53f1251e7861d08519 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 31 May 2026 13:29:34 +0200 Subject: [PATCH 352/589] cleanup and split K_MoveKartPlayer item stuff split into K_PlayerItemThink --- src/k_kart.c | 1116 ++++++++++++++++++++++++++------------------------ 1 file changed, 588 insertions(+), 528 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 4274d991d..79b18aeae 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5734,17 +5734,19 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) else { player->kartstuff[k_eggmanexplode]--; + if (player->kartstuff[k_eggmanexplode] <= 0) { - mobj_t *eggsexplode; //player->powers[pw_flashing] = 0; - eggsexplode = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_SPBEXPLOSION); - if (player->kartstuff[k_eggmanblame] >= 0 - && player->kartstuff[k_eggmanblame] < MAXPLAYERS - && playeringame[player->kartstuff[k_eggmanblame]] - && !players[player->kartstuff[k_eggmanblame]].spectator - && players[player->kartstuff[k_eggmanblame]].mo) - P_SetTarget(&eggsexplode->target, players[player->kartstuff[k_eggmanblame]].mo); + mobj_t *eggsplode = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_SPBEXPLOSION); + + const INT32 blametarg = player->kartstuff[k_eggmanblame]; + + if ((blametarg >= 0 && blametarg < MAXPLAYERS) + && playeringame[blametarg] + && !players[blametarg].spectator + && players[blametarg].mo) + P_SetTarget(&eggsplode->target, players[blametarg].mo); } } } @@ -6287,6 +6289,7 @@ void K_StripItems(player_t *player) { K_DropRocketSneaker(player); K_DropKitchenSink(player); + player->kartstuff[k_itemtype] = KITEM_NONE; player->kartstuff[k_itemamount] = 0; player->kartstuff[k_itemheld] = 0; @@ -6296,6 +6299,7 @@ void K_StripItems(player_t *player) player->kartstuff[k_itemroulette] = 0; player->kartstuff[k_roulettetype] = 0; } + player->kartstuff[k_eggmanheld] = 0; player->kartstuff[k_hyudorotimer] = 0; @@ -6326,18 +6330,582 @@ void K_StripOther(player_t *player) } } +static void K_PlayerItemThink(player_t *player, boolean onground, boolean oldattackdown) +{ + if (!player || !player->mo) + return; + + if (player->mo->health <= 0) + return; + + if (player->spectator) + return; + + if (player->exiting || mapreset) + return; + + if (player->kartstuff[k_spinouttimer] != 0 || + player->kartstuff[k_squishedtimer] != 0 || + player->kartstuff[k_respawn] != 0) + return; + + const ticcmd_t *cmd = &player->cmd; + + const boolean ATTACK_IS_DOWN = ((cmd->buttons & BT_ATTACK) && !oldattackdown); + const boolean HOLDING_ITEM = (player->kartstuff[k_itemheld] || player->kartstuff[k_eggmanheld]); + const boolean NO_HYUDORO = (player->kartstuff[k_stolentimer] == 0 && player->kartstuff[k_stealingtimer] == 0); + + // First, the really specific, finicky items that function without the item being directly in your item slot. + // Karma item dropping + if (ATTACK_IS_DOWN && player->kartstuff[k_comebackmode] && !player->kartstuff[k_comebacktimer]) + { + mobj_t *newitem; + + if (player->kartstuff[k_comebackmode] == 1) + { + newitem = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_RANDOMITEM); + newitem->threshold = 69; // selected "randomly". + } + else + { + newitem = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_EGGMANITEM); + + const INT32 blametarg = player->kartstuff[k_eggmanblame]; + + if ((blametarg >= 0 && blametarg < MAXPLAYERS) + && playeringame[blametarg] + && !players[blametarg].spectator + && players[blametarg].mo) + P_SetTarget(&newitem->target, players[blametarg].mo); + + player->kartstuff[k_eggmanblame] = -1; + } + + newitem->flags2 = (player->mo->flags2 & MF2_OBJECTFLIP); + newitem->fuse = 15*TICRATE; // selected randomly. + + player->kartstuff[k_comebackmode] = 0; + player->kartstuff[k_comebacktimer] = comebacktime; + S_StartSound(player->mo, sfx_s254); + } + // Eggman Monitor exploding + else if (player->kartstuff[k_eggmanexplode]) + { + if (ATTACK_IS_DOWN && player->kartstuff[k_eggmanexplode] <= 3*TICRATE && player->kartstuff[k_eggmanexplode] > 1) + player->kartstuff[k_eggmanexplode] = 1; + } + // Eggman Monitor throwing + else if (ATTACK_IS_DOWN && player->kartstuff[k_eggmanheld]) + { + K_ThrowKartItem(player, false, MT_EGGMANITEM, -1, 0); + K_PlayAttackTaunt(player->mo); + player->kartstuff[k_eggmanheld] = 0; + K_UpdateHnextList(player, true); + } + // Rocket Sneaker + else if (ATTACK_IS_DOWN && !HOLDING_ITEM && onground && NO_HYUDORO + && player->kartstuff[k_rocketsneakertimer] > 1) + { + K_DoSneaker(player, 2); + K_PlayBoostTaunt(player->mo); + + player->kartstuff[k_rocketsneakertimer] -= 2*TICRATE; + + if (player->kartstuff[k_rocketsneakertimer] < 1) + player->kartstuff[k_rocketsneakertimer] = 1; + } + // Grow Canceling + else if (player->kartstuff[k_growshrinktimer] > 0) + { + if (player->kartstuff[k_growcancel] >= 0) + { + if (cmd->buttons & BT_ATTACK) + { + player->kartstuff[k_growcancel]++; + + if (player->kartstuff[k_growcancel] > 26) + K_RemoveGrowShrink(player); + } + else + player->kartstuff[k_growcancel] = 0; + } + else + { + if ((cmd->buttons & BT_ATTACK) || (player->pflags & PF_ATTACKDOWN)) + player->kartstuff[k_growcancel] = -1; + else + player->kartstuff[k_growcancel] = 0; + } + } + else if (player->kartstuff[k_itemamount] <= 0) + { + player->kartstuff[k_itemamount] = player->kartstuff[k_itemheld] = 0; + } + else + { + switch (player->kartstuff[k_itemtype]) + { + case KITEM_SNEAKER: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && onground && NO_HYUDORO) + { + K_DoSneaker(player, 1); + K_PlayBoostTaunt(player->mo); + player->kartstuff[k_itemamount]--; + } + break; + case KITEM_ROCKETSNEAKER: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && onground && NO_HYUDORO + && player->kartstuff[k_rocketsneakertimer] == 0) + { + INT32 moloop; + mobj_t *mo = NULL; + mobj_t *prev = player->mo; + + K_PlayBoostTaunt(player->mo); + //player->kartstuff[k_itemheld] = 1; + S_StartSound(player->mo, sfx_s3k3a); + + //K_DoSneaker(player, 2); + + player->kartstuff[k_rocketsneakertimer] = (itemtime*3); + player->kartstuff[k_itemamount]--; + K_UpdateHnextList(player, true); + + for (moloop = 0; moloop < 2; moloop++) + { + mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_ROCKETSNEAKER); + K_MatchGenericExtraFlags(mo, player->mo); + mo->flags |= MF_NOCLIPTHING; + mo->angle = player->mo->angle; + mo->threshold = 10; + mo->movecount = moloop%2; + mo->movedir = mo->lastlook = moloop+1; + P_SetTarget(&mo->target, player->mo); + P_SetTarget(&mo->hprev, prev); + P_SetTarget(&prev->hnext, mo); + prev = mo; + } + } + break; + case KITEM_INVINCIBILITY: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) // Doesn't hold your item slot hostage normally, so you're free to waste it if you have multiple + { + if (!player->kartstuff[k_invincibilitytimer]) + { + mobj_t *overlay = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_INVULNFLASH); + P_SetTarget(&overlay->target, player->mo); + overlay->destscale = player->mo->scale; + P_SetScale(overlay, player->mo->scale); + } + + player->kartstuff[k_invincibilitytimer] = itemtime+(2*TICRATE); // 10 seconds + + if (cv_supermusic.value == 1 && P_IsLocalPlayer(player)) + S_ChangeMusicSpecial("kinvnc"); + + P_RestoreMusic(player); + K_PlayPowerGloatSound(player->mo); + player->kartstuff[k_itemamount]--; + } + break; + case KITEM_BANANA: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) + { + INT32 moloop; + mobj_t *mo; + mobj_t *prev = player->mo; + + //K_PlayAttackTaunt(player->mo); + player->kartstuff[k_itemheld] = 1; + S_StartSound(player->mo, sfx_s254); + + for (moloop = 0; moloop < player->kartstuff[k_itemamount]; moloop++) + { + mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_BANANA_SHIELD); + + if (!mo) + { + player->kartstuff[k_itemamount] = moloop; + break; + } + + mo->flags |= MF_NOCLIPTHING; + mo->threshold = 10; + mo->movecount = player->kartstuff[k_itemamount]; + mo->movedir = moloop+1; + P_SetTarget(&mo->target, player->mo); + P_SetTarget(&mo->hprev, prev); + P_SetTarget(&prev->hnext, mo); + prev = mo; + } + } + else if (ATTACK_IS_DOWN && player->kartstuff[k_itemheld]) // Banana x3 thrown + { + K_ThrowKartItem(player, false, MT_BANANA, -1, 0); + K_PlayAttackTaunt(player->mo); + player->kartstuff[k_itemamount]--; + K_UpdateHnextList(player, false); + } + break; + case KITEM_EGGMAN: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) + { + mobj_t *mo; + player->kartstuff[k_itemamount]--; + player->kartstuff[k_eggmanheld] = 1; + S_StartSound(player->mo, sfx_s254); + mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_EGGMANITEM_SHIELD); + + if (mo) + { + mo->flags |= MF_NOCLIPTHING; + mo->threshold = 10; + mo->movecount = 1; + mo->movedir = 1; + P_SetTarget(&mo->target, player->mo); + P_SetTarget(&player->mo->hnext, mo); + } + } + break; + case KITEM_ORBINAUT: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) + { + angle_t newangle; + INT32 moloop; + mobj_t *mo = NULL; + mobj_t *prev = player->mo; + + //K_PlayAttackTaunt(player->mo); + player->kartstuff[k_itemheld] = 1; + S_StartSound(player->mo, sfx_s3k3a); + + for (moloop = 0; moloop < player->kartstuff[k_itemamount]; moloop++) + { + newangle = (player->mo->angle + ANGLE_157h) + FixedAngle(((360 / player->kartstuff[k_itemamount]) * moloop) << FRACBITS) + ANGLE_90; + mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_ORBINAUT_SHIELD); + + if (!mo) + { + player->kartstuff[k_itemamount] = moloop; + break; + } + + mo->flags |= MF_NOCLIPTHING; + mo->angle = newangle; + mo->threshold = 10; + mo->movecount = player->kartstuff[k_itemamount]; + mo->movedir = mo->lastlook = moloop+1; + mo->color = player->skincolor; + P_SetTarget(&mo->target, player->mo); + P_SetTarget(&mo->hprev, prev); + P_SetTarget(&prev->hnext, mo); + prev = mo; + } + } + else if (ATTACK_IS_DOWN && player->kartstuff[k_itemheld]) // Orbinaut x3 thrown + { + K_ThrowKartItem(player, true, MT_ORBINAUT, 1, 0); + K_PlayAttackTaunt(player->mo); + player->kartstuff[k_itemamount]--; + K_UpdateHnextList(player, false); + } + break; + case KITEM_JAWZ: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) + { + angle_t newangle; + INT32 moloop; + mobj_t *mo = NULL; + mobj_t *prev = player->mo; + + //K_PlayAttackTaunt(player->mo); + player->kartstuff[k_itemheld] = 1; + S_StartSound(player->mo, sfx_s3k3a); + + for (moloop = 0; moloop < player->kartstuff[k_itemamount]; moloop++) + { + newangle = (player->mo->angle + ANGLE_157h) + FixedAngle(((360 / player->kartstuff[k_itemamount]) * moloop) << FRACBITS) + ANGLE_90; + mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_JAWZ_SHIELD); + + if (!mo) + { + player->kartstuff[k_itemamount] = moloop; + break; + } + + mo->flags |= MF_NOCLIPTHING; + mo->angle = newangle; + mo->threshold = 10; + mo->movecount = player->kartstuff[k_itemamount]; + mo->movedir = mo->lastlook = moloop+1; + P_SetTarget(&mo->target, player->mo); + P_SetTarget(&mo->hprev, prev); + P_SetTarget(&prev->hnext, mo); + prev = mo; + } + } + else if (ATTACK_IS_DOWN && HOLDING_ITEM && player->kartstuff[k_itemheld]) // Jawz thrown + { + if (player->kartstuff[k_throwdir] == 1 || player->kartstuff[k_throwdir] == 0) + K_ThrowKartItem(player, true, MT_JAWZ, 1, 0); + else if (player->kartstuff[k_throwdir] == -1) // Throwing backward gives you a dud that doesn't home in + K_ThrowKartItem(player, true, MT_JAWZ_DUD, -1, 0); + + K_PlayAttackTaunt(player->mo); + player->kartstuff[k_itemamount]--; + K_UpdateHnextList(player, false); + } + break; + case KITEM_MINE: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) + { + mobj_t *mo; + + player->kartstuff[k_itemheld] = 1; + S_StartSound(player->mo, sfx_s254); + mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_SSMINE_SHIELD); + + if (mo) + { + mo->flags |= MF_NOCLIPTHING; + mo->threshold = 10; + mo->movecount = 1; + mo->movedir = 1; + P_SetTarget(&mo->target, player->mo); + P_SetTarget(&player->mo->hnext, mo); + } + } + else if (ATTACK_IS_DOWN && player->kartstuff[k_itemheld]) + { + K_ThrowKartItem(player, false, MT_SSMINE, 1, 1); + K_PlayAttackTaunt(player->mo); + player->kartstuff[k_itemamount]--; + player->kartstuff[k_itemheld] = 0; + K_UpdateHnextList(player, true); + } + break; + case KITEM_BALLHOG: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) + { + player->kartstuff[k_itemamount]--; + K_ThrowKartItem(player, true, MT_BALLHOG, 1, 0); + K_PlayAttackTaunt(player->mo); + } + break; + case KITEM_SPB: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) + { + player->kartstuff[k_itemamount]--; + K_ThrowKartItem(player, true, MT_SPB, 1, 0); + K_PlayAttackTaunt(player->mo); + } + break; + case KITEM_GROW: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO + && player->kartstuff[k_growshrinktimer] <= 0) // Grow holds the item box hostage + { + if (player->kartstuff[k_growshrinktimer] < 0) // If you're shrunk, then "grow" will just make you normal again. + K_RemoveGrowShrink(player); + else + { + K_PlayPowerGloatSound(player->mo); + player->mo->scalespeed = mapobjectscale/TICRATE; + player->mo->destscale = (3*mapobjectscale)/2; + + if (cv_kartdebugshrink.value && !modeattacking && !player->bot) + player->mo->destscale = (6*player->mo->destscale)/8; + + player->kartstuff[k_growshrinktimer] = itemtime+(4*TICRATE); // 12 seconds + + if (cv_growmusic.value == 1 && P_IsLocalPlayer(player)) + S_ChangeMusicSpecial("kgrow"); + + P_RestoreMusic(player); + S_StartSound(player->mo, sfx_kc5a); + } + + player->kartstuff[k_itemamount]--; + } + break; + case KITEM_SHRINK: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) + { + K_DoShrink(player); + player->kartstuff[k_itemamount]--; + K_PlayPowerGloatSound(player->mo); + } + break; + case KITEM_THUNDERSHIELD: + if (player->kartstuff[k_curshield] != 1) + { + mobj_t *shield = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_THUNDERSHIELD); + P_SetScale(shield, (shield->destscale = (5*shield->destscale)>>2)); + P_SetTarget(&shield->target, player->mo); + S_StartSound(shield, sfx_s3k41); + player->kartstuff[k_curshield] = 1; + } + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) + { + K_DoThunderShield(player); + player->kartstuff[k_itemamount]--; + K_PlayAttackTaunt(player->mo); + } + break; + case KITEM_HYUDORO: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) + { + player->kartstuff[k_itemamount]--; + K_DoHyudoroSteal(player); // yes. yes they do. + } + break; + case KITEM_POGOSPRING: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && onground && NO_HYUDORO + && !player->kartstuff[k_pogospring]) + { + K_PlayBoostTaunt(player->mo); + K_DoPogoSpring(player->mo, 32<kartstuff[k_pogospring] = 1; + player->kartstuff[k_itemamount]--; + } + break; + case KITEM_KITCHENSINK: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) + { + mobj_t *mo; + + player->kartstuff[k_itemheld] = 1; + S_StartSound(player->mo, sfx_s254); + mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_SINK_SHIELD); + + if (mo) + { + mo->flags |= MF_NOCLIPTHING; + mo->threshold = 10; + mo->movecount = 1; + mo->movedir = 1; + P_SetTarget(&mo->target, player->mo); + P_SetTarget(&player->mo->hnext, mo); + } + } + else if (ATTACK_IS_DOWN && HOLDING_ITEM && player->kartstuff[k_itemheld]) // Sink thrown + { + K_ThrowKartItem(player, false, MT_SINK, 1, 2); + K_PlayAttackTaunt(player->mo); + player->kartstuff[k_itemamount]--; + player->kartstuff[k_itemheld] = 0; + K_UpdateHnextList(player, true); + } + break; + case KITEM_SAD: + if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO + && !player->kartstuff[k_sadtimer]) + { + player->kartstuff[k_sadtimer] = stealtime; + player->kartstuff[k_itemamount]--; + } + break; + default: + break; + } + } + + // No more! + if (!player->kartstuff[k_itemamount]) + { + player->kartstuff[k_itemheld] = 0; + player->kartstuff[k_itemtype] = KITEM_NONE; + } + + if (player->kartstuff[k_itemtype] != KITEM_THUNDERSHIELD) + player->kartstuff[k_curshield] = 0; + + if (player->kartstuff[k_growshrinktimer] <= 0) + player->kartstuff[k_growcancel] = -1; + + if (player->kartstuff[k_itemtype] == KITEM_SPB + || player->kartstuff[k_itemtype] == KITEM_SHRINK + || player->kartstuff[k_growshrinktimer] < 0) + indirectitemcooldown = 20*TICRATE; + + if (player->kartstuff[k_hyudorotimer] > 0) + { + if (splitscreen) + { + if (!cv_reducevfx.value && leveltime & 1) + player->mo->flags2 |= MF2_DONTDRAW; + else + player->mo->flags2 &= ~MF2_DONTDRAW; + + if (player->kartstuff[k_hyudorotimer] >= (1*TICRATE/2) && player->kartstuff[k_hyudorotimer] <= hyudorotime-(1*TICRATE/2)) + { + if (player == &players[displayplayers[1]]) + player->mo->eflags |= MFE_DRAWONLYFORP2; + else if (player == &players[displayplayers[2]] && splitscreen > 1) + player->mo->eflags |= MFE_DRAWONLYFORP3; + else if (player == &players[displayplayers[3]] && splitscreen > 2) + player->mo->eflags |= MFE_DRAWONLYFORP4; + else if (player == &players[displayplayers[0]]) + player->mo->eflags |= MFE_DRAWONLYFORP1; + else + player->mo->flags2 |= MF2_DONTDRAW; + } + else + player->mo->eflags &= ~(MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); + } + else + { + if (P_IsDisplayPlayer(player) || + (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2))) + { + if (!cv_reducevfx.value && leveltime & 1) + player->mo->flags2 |= MF2_DONTDRAW; + else + player->mo->flags2 &= ~MF2_DONTDRAW; + } + else + player->mo->flags2 |= MF2_DONTDRAW; + } + + player->powers[pw_flashing] = player->kartstuff[k_hyudorotimer]; // We'll do this for now, let's people know about the invisible people through subtle hints + } + else if (player->kartstuff[k_hyudorotimer] == 0) + { + player->mo->flags2 &= ~MF2_DONTDRAW; + player->mo->eflags &= ~(MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); + } + + if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) // dead in match? you da bomb + { + K_DropItems(player); //K_StripItems(player); + K_StripOther(player); + player->mo->flags2 |= MF2_SHADOW; + player->powers[pw_flashing] = player->kartstuff[k_comebacktimer]; + } + else if (G_RaceGametype() || player->kartstuff[k_bumper] > 0) + { + player->mo->flags2 &= ~MF2_SHADOW; + } +} + // // K_MoveKartPlayer // void K_MoveKartPlayer(player_t *player, boolean onground) { ticcmd_t *cmd = &player->cmd; - boolean ATTACK_IS_DOWN = ((cmd->buttons & BT_ATTACK) && !(player->pflags & PF_ATTACKDOWN)); - boolean HOLDING_ITEM = (player->kartstuff[k_itemheld] || player->kartstuff[k_eggmanheld]); - boolean NO_HYUDORO = (player->kartstuff[k_stolentimer] == 0 && player->kartstuff[k_stealingtimer] == 0); + + const boolean oldattackdown = (player->pflags & PF_ATTACKDOWN); // fun + + if ((player->pflags & PF_ATTACKDOWN) && !(cmd->buttons & BT_ATTACK)) + player->pflags &= ~PF_ATTACKDOWN; + else if (cmd->buttons & BT_ATTACK) + player->pflags |= PF_ATTACKDOWN; K_KartUpdatePosition(player); + // Play overtake sounds, but only if + // - your place changed + // - not exiting if (!player->exiting) { if (player->kartstuff[k_oldposition] < player->kartstuff[k_position]) // But first, if you lost a place, @@ -6355,521 +6923,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (player->kartstuff[k_positiondelay]) player->kartstuff[k_positiondelay]--; - if ((player->pflags & PF_ATTACKDOWN) && !(cmd->buttons & BT_ATTACK)) - player->pflags &= ~PF_ATTACKDOWN; - else if (cmd->buttons & BT_ATTACK) - player->pflags |= PF_ATTACKDOWN; - - if (player && player->mo && player->mo->health > 0 && !player->spectator && !(player->exiting || mapreset) - && player->kartstuff[k_spinouttimer] == 0 && player->kartstuff[k_squishedtimer] == 0 && player->kartstuff[k_respawn] == 0) - { - // First, the really specific, finicky items that function without the item being directly in your item slot. - // Karma item dropping - if (ATTACK_IS_DOWN && player->kartstuff[k_comebackmode] && !player->kartstuff[k_comebacktimer]) - { - mobj_t *newitem; - - if (player->kartstuff[k_comebackmode] == 1) - { - newitem = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_RANDOMITEM); - newitem->threshold = 69; // selected "randomly". - } - else - { - newitem = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_EGGMANITEM); - if (player->kartstuff[k_eggmanblame] >= 0 - && player->kartstuff[k_eggmanblame] < MAXPLAYERS - && playeringame[player->kartstuff[k_eggmanblame]] - && !players[player->kartstuff[k_eggmanblame]].spectator - && players[player->kartstuff[k_eggmanblame]].mo) - P_SetTarget(&newitem->target, players[player->kartstuff[k_eggmanblame]].mo); - player->kartstuff[k_eggmanblame] = -1; - } - - newitem->flags2 = (player->mo->flags2 & MF2_OBJECTFLIP); - newitem->fuse = 15*TICRATE; // selected randomly. - - player->kartstuff[k_comebackmode] = 0; - player->kartstuff[k_comebacktimer] = comebacktime; - S_StartSound(player->mo, sfx_s254); - } - // Eggman Monitor exploding - else if (player->kartstuff[k_eggmanexplode]) - { - if (ATTACK_IS_DOWN && player->kartstuff[k_eggmanexplode] <= 3*TICRATE && player->kartstuff[k_eggmanexplode] > 1) - player->kartstuff[k_eggmanexplode] = 1; - } - // Eggman Monitor throwing - else if (ATTACK_IS_DOWN && player->kartstuff[k_eggmanheld]) - { - K_ThrowKartItem(player, false, MT_EGGMANITEM, -1, 0); - K_PlayAttackTaunt(player->mo); - player->kartstuff[k_eggmanheld] = 0; - K_UpdateHnextList(player, true); - } - // Rocket Sneaker - else if (ATTACK_IS_DOWN && !HOLDING_ITEM && onground && NO_HYUDORO - && player->kartstuff[k_rocketsneakertimer] > 1) - { - K_DoSneaker(player, 2); - K_PlayBoostTaunt(player->mo); - player->kartstuff[k_rocketsneakertimer] -= 2*TICRATE; - if (player->kartstuff[k_rocketsneakertimer] < 1) - player->kartstuff[k_rocketsneakertimer] = 1; - } - // Grow Canceling - else if (player->kartstuff[k_growshrinktimer] > 0) - { - if (player->kartstuff[k_growcancel] >= 0) - { - if (cmd->buttons & BT_ATTACK) - { - player->kartstuff[k_growcancel]++; - if (player->kartstuff[k_growcancel] > 26) - K_RemoveGrowShrink(player); - } - else - player->kartstuff[k_growcancel] = 0; - } - else - { - if ((cmd->buttons & BT_ATTACK) || (player->pflags & PF_ATTACKDOWN)) - player->kartstuff[k_growcancel] = -1; - else - player->kartstuff[k_growcancel] = 0; - } - } - else if (player->kartstuff[k_itemamount] <= 0) - { - player->kartstuff[k_itemamount] = player->kartstuff[k_itemheld] = 0; - } - else - { - switch (player->kartstuff[k_itemtype]) - { - case KITEM_SNEAKER: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && onground && NO_HYUDORO) - { - K_DoSneaker(player, 1); - K_PlayBoostTaunt(player->mo); - player->kartstuff[k_itemamount]--; - } - break; - case KITEM_ROCKETSNEAKER: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && onground && NO_HYUDORO - && player->kartstuff[k_rocketsneakertimer] == 0) - { - INT32 moloop; - mobj_t *mo = NULL; - mobj_t *prev = player->mo; - - K_PlayBoostTaunt(player->mo); - //player->kartstuff[k_itemheld] = 1; - S_StartSound(player->mo, sfx_s3k3a); - - //K_DoSneaker(player, 2); - - player->kartstuff[k_rocketsneakertimer] = (itemtime*3); - player->kartstuff[k_itemamount]--; - K_UpdateHnextList(player, true); - - for (moloop = 0; moloop < 2; moloop++) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_ROCKETSNEAKER); - K_MatchGenericExtraFlags(mo, player->mo); - mo->flags |= MF_NOCLIPTHING; - mo->angle = player->mo->angle; - mo->threshold = 10; - mo->movecount = moloop%2; - mo->movedir = mo->lastlook = moloop+1; - P_SetTarget(&mo->target, player->mo); - P_SetTarget(&mo->hprev, prev); - P_SetTarget(&prev->hnext, mo); - prev = mo; - } - } - break; - case KITEM_INVINCIBILITY: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) // Doesn't hold your item slot hostage normally, so you're free to waste it if you have multiple - { - if (!player->kartstuff[k_invincibilitytimer]) - { - mobj_t *overlay = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_INVULNFLASH); - P_SetTarget(&overlay->target, player->mo); - overlay->destscale = player->mo->scale; - P_SetScale(overlay, player->mo->scale); - } - player->kartstuff[k_invincibilitytimer] = itemtime+(2*TICRATE); // 10 seconds - - if (cv_supermusic.value == 1 && P_IsLocalPlayer(player)) - S_ChangeMusicSpecial("kinvnc"); - - P_RestoreMusic(player); - K_PlayPowerGloatSound(player->mo); - player->kartstuff[k_itemamount]--; - } - break; - case KITEM_BANANA: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) - { - INT32 moloop; - mobj_t *mo; - mobj_t *prev = player->mo; - - //K_PlayAttackTaunt(player->mo); - player->kartstuff[k_itemheld] = 1; - S_StartSound(player->mo, sfx_s254); - - for (moloop = 0; moloop < player->kartstuff[k_itemamount]; moloop++) - { - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_BANANA_SHIELD); - if (!mo) - { - player->kartstuff[k_itemamount] = moloop; - break; - } - mo->flags |= MF_NOCLIPTHING; - mo->threshold = 10; - mo->movecount = player->kartstuff[k_itemamount]; - mo->movedir = moloop+1; - P_SetTarget(&mo->target, player->mo); - P_SetTarget(&mo->hprev, prev); - P_SetTarget(&prev->hnext, mo); - prev = mo; - } - } - else if (ATTACK_IS_DOWN && player->kartstuff[k_itemheld]) // Banana x3 thrown - { - K_ThrowKartItem(player, false, MT_BANANA, -1, 0); - K_PlayAttackTaunt(player->mo); - player->kartstuff[k_itemamount]--; - K_UpdateHnextList(player, false); - } - break; - case KITEM_EGGMAN: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) - { - mobj_t *mo; - player->kartstuff[k_itemamount]--; - player->kartstuff[k_eggmanheld] = 1; - S_StartSound(player->mo, sfx_s254); - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_EGGMANITEM_SHIELD); - if (mo) - { - mo->flags |= MF_NOCLIPTHING; - mo->threshold = 10; - mo->movecount = 1; - mo->movedir = 1; - P_SetTarget(&mo->target, player->mo); - P_SetTarget(&player->mo->hnext, mo); - } - } - break; - case KITEM_ORBINAUT: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) - { - angle_t newangle; - INT32 moloop; - mobj_t *mo = NULL; - mobj_t *prev = player->mo; - - //K_PlayAttackTaunt(player->mo); - player->kartstuff[k_itemheld] = 1; - S_StartSound(player->mo, sfx_s3k3a); - - for (moloop = 0; moloop < player->kartstuff[k_itemamount]; moloop++) - { - newangle = (player->mo->angle + ANGLE_157h) + FixedAngle(((360 / player->kartstuff[k_itemamount]) * moloop) << FRACBITS) + ANGLE_90; - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_ORBINAUT_SHIELD); - if (!mo) - { - player->kartstuff[k_itemamount] = moloop; - break; - } - mo->flags |= MF_NOCLIPTHING; - mo->angle = newangle; - mo->threshold = 10; - mo->movecount = player->kartstuff[k_itemamount]; - mo->movedir = mo->lastlook = moloop+1; - mo->color = player->skincolor; - P_SetTarget(&mo->target, player->mo); - P_SetTarget(&mo->hprev, prev); - P_SetTarget(&prev->hnext, mo); - prev = mo; - } - } - else if (ATTACK_IS_DOWN && player->kartstuff[k_itemheld]) // Orbinaut x3 thrown - { - K_ThrowKartItem(player, true, MT_ORBINAUT, 1, 0); - K_PlayAttackTaunt(player->mo); - player->kartstuff[k_itemamount]--; - K_UpdateHnextList(player, false); - } - break; - case KITEM_JAWZ: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) - { - angle_t newangle; - INT32 moloop; - mobj_t *mo = NULL; - mobj_t *prev = player->mo; - - //K_PlayAttackTaunt(player->mo); - player->kartstuff[k_itemheld] = 1; - S_StartSound(player->mo, sfx_s3k3a); - - for (moloop = 0; moloop < player->kartstuff[k_itemamount]; moloop++) - { - newangle = (player->mo->angle + ANGLE_157h) + FixedAngle(((360 / player->kartstuff[k_itemamount]) * moloop) << FRACBITS) + ANGLE_90; - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_JAWZ_SHIELD); - if (!mo) - { - player->kartstuff[k_itemamount] = moloop; - break; - } - mo->flags |= MF_NOCLIPTHING; - mo->angle = newangle; - mo->threshold = 10; - mo->movecount = player->kartstuff[k_itemamount]; - mo->movedir = mo->lastlook = moloop+1; - P_SetTarget(&mo->target, player->mo); - P_SetTarget(&mo->hprev, prev); - P_SetTarget(&prev->hnext, mo); - prev = mo; - } - } - else if (ATTACK_IS_DOWN && HOLDING_ITEM && player->kartstuff[k_itemheld]) // Jawz thrown - { - if (player->kartstuff[k_throwdir] == 1 || player->kartstuff[k_throwdir] == 0) - K_ThrowKartItem(player, true, MT_JAWZ, 1, 0); - else if (player->kartstuff[k_throwdir] == -1) // Throwing backward gives you a dud that doesn't home in - K_ThrowKartItem(player, true, MT_JAWZ_DUD, -1, 0); - K_PlayAttackTaunt(player->mo); - player->kartstuff[k_itemamount]--; - K_UpdateHnextList(player, false); - } - break; - case KITEM_MINE: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) - { - mobj_t *mo; - player->kartstuff[k_itemheld] = 1; - S_StartSound(player->mo, sfx_s254); - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_SSMINE_SHIELD); - if (mo) - { - mo->flags |= MF_NOCLIPTHING; - mo->threshold = 10; - mo->movecount = 1; - mo->movedir = 1; - P_SetTarget(&mo->target, player->mo); - P_SetTarget(&player->mo->hnext, mo); - } - } - else if (ATTACK_IS_DOWN && player->kartstuff[k_itemheld]) - { - K_ThrowKartItem(player, false, MT_SSMINE, 1, 1); - K_PlayAttackTaunt(player->mo); - player->kartstuff[k_itemamount]--; - player->kartstuff[k_itemheld] = 0; - K_UpdateHnextList(player, true); - } - break; - case KITEM_BALLHOG: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) - { - player->kartstuff[k_itemamount]--; - K_ThrowKartItem(player, true, MT_BALLHOG, 1, 0); - K_PlayAttackTaunt(player->mo); - } - break; - case KITEM_SPB: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) - { - player->kartstuff[k_itemamount]--; - K_ThrowKartItem(player, true, MT_SPB, 1, 0); - K_PlayAttackTaunt(player->mo); - } - break; - case KITEM_GROW: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO - && player->kartstuff[k_growshrinktimer] <= 0) // Grow holds the item box hostage - { - if (player->kartstuff[k_growshrinktimer] < 0) // If you're shrunk, then "grow" will just make you normal again. - K_RemoveGrowShrink(player); - else - { - K_PlayPowerGloatSound(player->mo); - player->mo->scalespeed = mapobjectscale/TICRATE; - player->mo->destscale = (3*mapobjectscale)/2; - if (cv_kartdebugshrink.value && !modeattacking && !player->bot) - player->mo->destscale = (6*player->mo->destscale)/8; - player->kartstuff[k_growshrinktimer] = itemtime+(4*TICRATE); // 12 seconds - if (cv_growmusic.value == 1 && P_IsLocalPlayer(player)) - S_ChangeMusicSpecial("kgrow"); - P_RestoreMusic(player); - S_StartSound(player->mo, sfx_kc5a); - } - player->kartstuff[k_itemamount]--; - } - break; - case KITEM_SHRINK: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) - { - K_DoShrink(player); - player->kartstuff[k_itemamount]--; - K_PlayPowerGloatSound(player->mo); - } - break; - case KITEM_THUNDERSHIELD: - if (player->kartstuff[k_curshield] != 1) - { - mobj_t *shield = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_THUNDERSHIELD); - P_SetScale(shield, (shield->destscale = (5*shield->destscale)>>2)); - P_SetTarget(&shield->target, player->mo); - S_StartSound(shield, sfx_s3k41); - player->kartstuff[k_curshield] = 1; - } - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) - { - K_DoThunderShield(player); - player->kartstuff[k_itemamount]--; - K_PlayAttackTaunt(player->mo); - } - break; - case KITEM_HYUDORO: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) - { - player->kartstuff[k_itemamount]--; - K_DoHyudoroSteal(player); // yes. yes they do. - } - break; - case KITEM_POGOSPRING: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && onground && NO_HYUDORO - && !player->kartstuff[k_pogospring]) - { - K_PlayBoostTaunt(player->mo); - K_DoPogoSpring(player->mo, 32<kartstuff[k_pogospring] = 1; - player->kartstuff[k_itemamount]--; - } - break; - case KITEM_KITCHENSINK: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) - { - mobj_t *mo; - player->kartstuff[k_itemheld] = 1; - S_StartSound(player->mo, sfx_s254); - mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_SINK_SHIELD); - if (mo) - { - mo->flags |= MF_NOCLIPTHING; - mo->threshold = 10; - mo->movecount = 1; - mo->movedir = 1; - P_SetTarget(&mo->target, player->mo); - P_SetTarget(&player->mo->hnext, mo); - } - } - else if (ATTACK_IS_DOWN && HOLDING_ITEM && player->kartstuff[k_itemheld]) // Sink thrown - { - K_ThrowKartItem(player, false, MT_SINK, 1, 2); - K_PlayAttackTaunt(player->mo); - player->kartstuff[k_itemamount]--; - player->kartstuff[k_itemheld] = 0; - K_UpdateHnextList(player, true); - } - break; - case KITEM_SAD: - if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO - && !player->kartstuff[k_sadtimer]) - { - player->kartstuff[k_sadtimer] = stealtime; - player->kartstuff[k_itemamount]--; - } - break; - default: - break; - } - } - - // No more! - if (!player->kartstuff[k_itemamount]) - { - player->kartstuff[k_itemheld] = 0; - player->kartstuff[k_itemtype] = KITEM_NONE; - } - - if (player->kartstuff[k_itemtype] != KITEM_THUNDERSHIELD) - player->kartstuff[k_curshield] = 0; - - if (player->kartstuff[k_growshrinktimer] <= 0) - player->kartstuff[k_growcancel] = -1; - - if (player->kartstuff[k_itemtype] == KITEM_SPB - || player->kartstuff[k_itemtype] == KITEM_SHRINK - || player->kartstuff[k_growshrinktimer] < 0) - indirectitemcooldown = 20*TICRATE; - - if (player->kartstuff[k_hyudorotimer] > 0) - { - if (splitscreen) - { - if (!cv_reducevfx.value && leveltime & 1) - player->mo->flags2 |= MF2_DONTDRAW; - else - player->mo->flags2 &= ~MF2_DONTDRAW; - - if (player->kartstuff[k_hyudorotimer] >= (1*TICRATE/2) && player->kartstuff[k_hyudorotimer] <= hyudorotime-(1*TICRATE/2)) - { - if (player == &players[displayplayers[1]]) - player->mo->eflags |= MFE_DRAWONLYFORP2; - else if (player == &players[displayplayers[2]] && splitscreen > 1) - player->mo->eflags |= MFE_DRAWONLYFORP3; - else if (player == &players[displayplayers[3]] && splitscreen > 2) - player->mo->eflags |= MFE_DRAWONLYFORP4; - else if (player == &players[displayplayers[0]]) - player->mo->eflags |= MFE_DRAWONLYFORP1; - else - player->mo->flags2 |= MF2_DONTDRAW; - } - else - player->mo->eflags &= ~(MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); - } - else - { - if (P_IsDisplayPlayer(player) - || (!P_IsDisplayPlayer(player) && (player->kartstuff[k_hyudorotimer] < (1*TICRATE/2) || player->kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)))) - { - if (!cv_reducevfx.value && leveltime & 1) - player->mo->flags2 |= MF2_DONTDRAW; - else - player->mo->flags2 &= ~MF2_DONTDRAW; - } - else - player->mo->flags2 |= MF2_DONTDRAW; - } - - player->powers[pw_flashing] = player->kartstuff[k_hyudorotimer]; // We'll do this for now, let's people know about the invisible people through subtle hints - } - else if (player->kartstuff[k_hyudorotimer] == 0) - { - player->mo->flags2 &= ~MF2_DONTDRAW; - player->mo->eflags &= ~(MFE_DRAWONLYFORP1|MFE_DRAWONLYFORP2|MFE_DRAWONLYFORP3|MFE_DRAWONLYFORP4); - } - - if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) // dead in match? you da bomb - { - K_DropItems(player); //K_StripItems(player); - K_StripOther(player); - player->mo->flags2 |= MF2_SHADOW; - player->powers[pw_flashing] = player->kartstuff[k_comebacktimer]; - } - else if (G_RaceGametype() || player->kartstuff[k_bumper] > 0) - { - player->mo->flags2 &= ~MF2_SHADOW; - } - } + K_PlayerItemThink(player, onground, oldattackdown); // JugadorXEI: Do *not* calculate friction when a player is pogo'd // because they'll be in the air and friction will not reset! @@ -6918,12 +6972,14 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_KartDrift(player, onground); - if (player->sliproll && ((!player->kartstuff[k_aizdriftstrat]) || (!P_IsObjectOnGround(player->mo)) || (player->kartstuff[k_drift]))) + //// funneh Saturn sprite stuff + + if ((player->sliproll > 0) && + (!player->kartstuff[k_aizdriftstrat] || player->kartstuff[k_drift] || !P_IsObjectOnGround(player->mo))) { player->sliproll -= (4*ANG1); } - // funneh Saturn sprite stuff if (cv_gravstretch.value) K_StretchPlayerGravity(player); else if (cv_saltyhop.value && cv_saltysquish.value) @@ -6931,6 +6987,8 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_RollMobjBySlopes(player->mo, player->mo->standingslope); + //// + // Quick Turning // You can't turn your kart when you're not moving. // So now it's time to burn some rubber! @@ -6982,6 +7040,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) { player->mo->scalespeed = mapobjectscale/12; player->mo->destscale = mapobjectscale + (FixedMul(mapobjectscale, player->kartstuff[k_boostcharge]*131)); + if (cv_kartdebugshrink.value && !modeattacking && !player->bot) player->mo->destscale = (6*player->mo->destscale)/8; } @@ -7012,6 +7071,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) else { K_SpawnDashDustRelease(player); // already handled for perfect boosts by K_DoSneaker + if ((!player->kartstuff[k_floorboost] || player->kartstuff[k_floorboost] == 3) && P_IsLocalPlayer(player)) { if (player->kartstuff[k_boostcharge] <= 40) From 8ae6f71578231165b7cf4cf688be5eeb2874a0aa Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 1 Jun 2026 11:13:07 +0200 Subject: [PATCH 353/589] bunch of smaller optimizations and cleanups mostly avoiding needless work as per usual --- src/k_kart.c | 64 ++++++++++++++------ src/p_enemy.c | 12 ++-- src/p_floor.c | 17 ++++-- src/p_inter.c | 2 +- src/p_local.h | 1 - src/p_slopes.c | 2 + src/p_spec.c | 154 ++++++++++++++++++++++++++++++------------------- src/p_user.c | 37 +++++++----- 8 files changed, 186 insertions(+), 103 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 79b18aeae..ac1a3a8fd 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1897,6 +1897,7 @@ void K_RespawnChecker(player_t *player) void K_KartMoveAnimation(player_t *player) { ticcmd_t *cmd = &player->cmd; + // Standing frames - S_KART_STND1 S_KART_STND1_L S_KART_STND1_R if (player->speed == 0) { @@ -2102,16 +2103,22 @@ static void K_HandleDelayedHitByEm(player_t *player) void K_MomentumToFacing(player_t *player) { - angle_t dangle = player->mo->angle - R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); - - if (dangle > ANGLE_180) - dangle = InvAngle(dangle); - // If you aren't on the ground or are moving in too different of a direction don't do this if (player->mo->eflags & MFE_JUSTHITFLOOR) ; // Just hit floor ALWAYS redirects - else if (!P_IsObjectOnGround(player->mo) || dangle > ANGLE_90) - return; + else + { + if (!P_IsObjectOnGround(player->mo)) + return; + + angle_t dangle = player->mo->angle - R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); + + if (dangle > ANGLE_180) + dangle = InvAngle(dangle); + + if (dangle > ANGLE_90) + return; + } P_Thrust(player->mo, player->mo->angle, player->speed - FixedMul(player->speed, player->mo->friction)); player->mo->momx = FixedMul(player->mo->momx - player->cmomx, player->mo->friction) + player->cmomx; @@ -2492,6 +2499,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto if (!player->kartstuff[k_bumper]) { player->kartstuff[k_comebacktimer] = comebacktime; + if (player->kartstuff[k_comebackmode] == 2) { mobj_t *poof = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_EXPLODE); @@ -2507,9 +2515,12 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto if (player->kartstuff[k_spinouttype] <= 0) // type 0 is spinout, type 1 is wipeout, type 2 is spb { + const fixed_t spd = K_GetKartSpeed(player, true)/4; + // At spinout, player speed is increased to 1/4 their regular speed, moving them forward - if (player->speed < K_GetKartSpeed(player, true)/4) - P_InstaThrust(player->mo, player->mo->angle, FixedMul(K_GetKartSpeed(player, true)/4, player->mo->scale)); + if (player->speed < spd) + P_InstaThrust(player->mo, player->mo->angle, FixedMul(spd, player->mo->scale)); + S_StartSound(player->mo, sfx_slip); } @@ -2520,10 +2531,12 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto P_SetPlayerMobjState(player->mo, S_KART_SPIN); player->kartstuff[k_instashield] = 15; + if (cv_kartdebughuddrop.value && !modeattacking) K_DropItems(player); else K_DropHnextList(player); + return; } @@ -3943,6 +3956,7 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map // this is the small graphic effect that plops in you when you throw an item: throwmo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height/2, MT_FIREDITEM); P_SetTarget(&throwmo->target, player->mo); + // Ditto: if (player->mo->eflags & MFE_VERTICALFLIP) { @@ -3986,6 +4000,7 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map // floorz and ceilingz aren't properly set to account for FOFs and Polyobjects on spawn // This should set it for FOFs P_SetOrigin(mo, mo->x, mo->y, mo->z); // however, THIS can fuck up your day. just absolutely ruin you. + if (P_MobjWasRemoved(mo)) return NULL; @@ -4296,8 +4311,10 @@ static void K_DoShrink(player_t *user) { players[i].mo->scalespeed = mapobjectscale/TICRATE; players[i].mo->destscale = (6*mapobjectscale)/8; + if (cv_kartdebugshrink.value && !modeattacking && !players[i].bot) players[i].mo->destscale = (6*players[i].mo->destscale)/8; + S_StartSound(players[i].mo, sfx_kc59); } } @@ -4546,6 +4563,7 @@ void K_DropHnextList(player_t *player) // we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic... P_SetTarget(&player->mo->hnext, NULL); player->kartstuff[k_bananadrag] = 0; + if (player->kartstuff[k_eggmanheld]) player->kartstuff[k_eggmanheld] = 0; else if (player->kartstuff[k_itemheld] @@ -4629,6 +4647,7 @@ void K_DropRocketSneaker(player_t *player) leftshoe = false; } + P_SetTarget(&player->mo->hnext, NULL); player->kartstuff[k_rocketsneakertimer] = 0; } @@ -4843,6 +4862,7 @@ static void K_MoveHeldObjects(player_t *player) player->kartstuff[k_itemamount] = player->kartstuff[k_itemheld] = 0; player->kartstuff[k_itemtype] = KITEM_NONE; } + return; } @@ -4859,6 +4879,7 @@ static void K_MoveHeldObjects(player_t *player) player->kartstuff[k_itemamount] = player->kartstuff[k_itemheld] = 0; player->kartstuff[k_itemtype] = KITEM_NONE; } + return; } @@ -4874,7 +4895,6 @@ static void K_MoveHeldObjects(player_t *player) while (!P_MobjWasRemoved(cur)) { - const fixed_t radius = FixedHypot(player->mo->radius, player->mo->radius) + FixedHypot(cur->radius, cur->radius); // mobj's distance from its Target, or Radius. fixed_t z; if (!cur->health) @@ -4883,6 +4903,8 @@ static void K_MoveHeldObjects(player_t *player) continue; } + const fixed_t radius = FixedHypot(player->mo->radius, player->mo->radius) + FixedHypot(cur->radius, cur->radius); // mobj's distance from its Target, or Radius. + cur->color = player->skincolor; cur->angle -= ANGLE_90; @@ -4954,7 +4976,6 @@ static void K_MoveHeldObjects(player_t *player) while (!P_MobjWasRemoved(cur)) { - const fixed_t radius = FixedHypot(targ->radius, targ->radius) + FixedHypot(cur->radius, cur->radius); angle_t ang; fixed_t targx, targy, targz; fixed_t speed, dist; @@ -4967,6 +4988,8 @@ static void K_MoveHeldObjects(player_t *player) continue; } + const fixed_t radius = FixedHypot(targ->radius, targ->radius) + FixedHypot(cur->radius, cur->radius); + if (cur->extravalue1 < radius) cur->extravalue1 += FixedMul(P_AproxDistance(cur->extravalue1, radius), FRACUNIT/12); if (cur->extravalue1 > radius) @@ -5045,11 +5068,10 @@ static void K_MoveHeldObjects(player_t *player) while (!P_MobjWasRemoved(cur)) { - const fixed_t radius = FixedHypot(player->mo->radius, player->mo->radius) + FixedHypot(cur->radius, cur->radius); - boolean vibrate = ((leveltime & 1) && !cur->tracer); angle_t angoffset; fixed_t targx, targy, targz; - + const boolean vibrate = ((leveltime & 1) && !cur->tracer); + cur->flags &= ~MF_NOCLIPTHING; if (player->kartstuff[k_rocketsneakertimer] <= TICRATE && (leveltime & 1)) @@ -5069,6 +5091,8 @@ static void K_MoveHeldObjects(player_t *player) continue; } + const fixed_t radius = FixedHypot(player->mo->radius, player->mo->radius) + FixedHypot(cur->radius, cur->radius); + if (cur->extravalue1 < radius) cur->extravalue1 += FixedMul(P_AproxDistance(cur->extravalue1, radius), FRACUNIT/12); if (cur->extravalue1 > radius) @@ -5105,7 +5129,6 @@ static void K_MoveHeldObjects(player_t *player) targz = (player->mo->z + (player->mo->height/2)) + sine; if (player->mo->eflags & MFE_VERTICALFLIP) targz += (player->mo->height/2 - 32*player->mo->scale)*6; - } if (!P_MobjWasRemoved(cur->tracer)) @@ -5182,9 +5205,11 @@ player_t *K_FindJawzTarget(mobj_t *actor, player_t *source) // Don't go for people who are behind you if (thisang > ANGLE_67h) continue; + // Don't pay attention to people who aren't above your position if (player->kartstuff[k_position] >= source->kartstuff[k_position]) continue; + if ((best == -1) || (player->kartstuff[k_position] > best)) { wtarg = player; @@ -5506,6 +5531,8 @@ FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, bool */ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) { + const boolean onground = P_IsObjectOnGround(player->mo); + K_UpdateOffroad(player); K_UpdateEngineSounds(player, cmd); // Thanks, VAda! @@ -5622,7 +5649,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->kartstuff[k_spinouttimer]) { - if ((P_IsObjectOnGround(player->mo) || ((player->kartstuff[k_spinouttype]+1)/2 == 1)) // spinouttype 1 and 2 - explosion and spb + if ((onground || ((player->kartstuff[k_spinouttype]+1)/2 == 1)) // spinouttype 1 and 2 - explosion and spb && (player->kartstuff[k_sneakertimer] == 0)) { player->kartstuff[k_spinouttimer]--; @@ -5721,7 +5748,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (G_BattleGametype() && player->kartstuff[k_bumper] > 0) player->kartstuff[k_wanted]++; - if (P_IsObjectOnGround(player->mo)) + if (onground) player->kartstuff[k_waterskip] = 0; if (player->kartstuff[k_instashield]) @@ -5765,7 +5792,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->kartstuff[k_comebacktimer]) player->kartstuff[k_comebackmode] = 0; - if (P_IsObjectOnGround(player->mo) && player->kartstuff[k_pogospring]) + if (onground && player->kartstuff[k_pogospring]) { if (P_MobjFlip(player->mo)*player->mo->momz <= 0) player->kartstuff[k_pogospring] = 0; @@ -7362,6 +7389,7 @@ void K_CheckSpectateStatus(void) { UINT8 oldrespawnlist[MAXPLAYERS]; memcpy(oldrespawnlist, respawnlist, numjoiners); + for (i = 0; i < numjoiners; i++) { UINT8 pos = 0; diff --git a/src/p_enemy.c b/src/p_enemy.c index 15410747a..1502f5ff3 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -328,7 +328,7 @@ void P_NewChaseDir(mobj_t *actor) else d[1] = DI_NODIR; - if (twodlevel || actor->flags2 & MF2_TWOD) + if (UNLIKELY(twodlevel || actor->flags2 & MF2_TWOD)) d[2] = DI_NODIR; if (deltay < -FixedMul(10*FRACUNIT, actor->scale)) d[2] = DI_SOUTH; @@ -872,7 +872,7 @@ void A_PointyThink(void *thing) TVector v; TVector *res; angle_t fa; - fixed_t radius = FixedMul(actor->info->radius*actor->info->reactiontime, actor->scale); + fixed_t radius; boolean firsttime = true; INT32 sign; @@ -930,6 +930,8 @@ void A_PointyThink(void *thing) if (!actor->tracer) // For some reason we do not have spike balls... return; + radius = FixedMul(actor->info->radius*actor->info->reactiontime, actor->scale); + // Position spike balls relative to the value of 'lastlook'. ball = actor->tracer; @@ -2759,9 +2761,11 @@ void A_Invincibility(void *thing) if (P_IsLocalPlayer(player) && !player->powers[pw_super]) { S_StopMusic(); - if (mariomode) + + if (UNLIKELY(mariomode)) G_GhostAddColor((INT32) (player - players), GHC_INVINCIBLE); - S_ChangeMusicInternal((mariomode) ? "minvnc" : "invinc", false); + + S_ChangeMusicInternal((UNLIKELY(mariomode)) ? "minvnc" : "invinc", false); } } diff --git a/src/p_floor.c b/src/p_floor.c index ef42b02a3..3c4128777 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1107,14 +1107,13 @@ void T_SpikeSector(levelspecthink_t *spikes) if (affectsec == spikes->sector) // Applied to an actual sector { - fixed_t affectfloor = P_GetSpecialBottomZ(thing, affectsec, affectsec); - fixed_t affectceil = P_GetSpecialTopZ(thing, affectsec, affectsec); - if (affectsec->flags & SF_FLIPSPECIAL_FLOOR) { if (!(thing->eflags & MFE_VERTICALFLIP) && thing->momz > 0) continue; + fixed_t affectfloor = P_GetSpecialBottomZ(thing, affectsec, affectsec); + if (thing->z == affectfloor) dothepain = true; } @@ -1124,19 +1123,21 @@ void T_SpikeSector(levelspecthink_t *spikes) if ((thing->eflags & MFE_VERTICALFLIP) && thing->momz < 0) continue; + fixed_t affectceil = P_GetSpecialTopZ(thing, affectsec, affectsec); + if (thing->z + thing->height == affectceil) dothepain = true; } } else { - fixed_t affectfloor = P_GetSpecialBottomZ(thing, affectsec, spikes->sector); - fixed_t affectceil = P_GetSpecialTopZ(thing, affectsec, spikes->sector); if (affectsec->flags & SF_FLIPSPECIAL_FLOOR) { if (!(thing->eflags & MFE_VERTICALFLIP) && thing->momz > 0) continue; + fixed_t affectceil = P_GetSpecialTopZ(thing, affectsec, spikes->sector); + if (thing->z == affectceil) dothepain = true; } @@ -1146,6 +1147,8 @@ void T_SpikeSector(levelspecthink_t *spikes) if ((thing->eflags & MFE_VERTICALFLIP) && thing->momz < 0) continue; + fixed_t affectfloor = P_GetSpecialBottomZ(thing, affectsec, spikes->sector); + if (thing->z + thing->height == affectfloor) dothepain = true; } @@ -1652,6 +1655,7 @@ wegotit: static mobj_t *SearchMarioNode(msecnode_t *node) { mobj_t *thing = NULL; + for (; node; node = node->m_thinglist_next) { // Things which should NEVER be ejected from a MarioBlock, by type. @@ -2079,11 +2083,12 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) continue; topheight = P_GetSpecialTopZ(players[j].mo, sec, targetsec); - bottomheight = P_GetSpecialBottomZ(players[j].mo, sec, targetsec); if (players[j].mo->z > topheight) continue; + bottomheight = P_GetSpecialBottomZ(players[j].mo, sec, targetsec); + if (players[j].mo->z + players[j].mo->height < bottomheight) continue; diff --git a/src/p_inter.c b/src/p_inter.c index c2d111efd..0a35cab3c 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1624,7 +1624,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) // Drop stuff. // This determines the kind of object spawned // during the death frame of a thing. - if (!mariomode // Don't show birds, etc. in Mario Mode Tails 12-23-2001 + if (LIKELY(!mariomode) // Don't show birds, etc. in Mario Mode Tails 12-23-2001 && target->flags & MF_ENEMY) { if (cv_soniccd.value) diff --git a/src/p_local.h b/src/p_local.h index b71e99ebd..383469bcc 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -99,7 +99,6 @@ typedef struct camera_s // Hold up/down to pan the camera vertically SINT8 dpad_y_held; - // Camera demobjerization // Info for drawing: position. fixed_t x, y, z; diff --git a/src/p_slopes.c b/src/p_slopes.c index ac3a56c17..6334b2e45 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -664,8 +664,10 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag for (i = 0; i < 3; i++) { mt = ret->vertices[i]; + if (!mt) // If a vertex wasn't found, it's game over. There's nothing you can do to recover (except maybe try and kill the slope instead - TODO?) I_Error("P_NewVertexSlope: Slope vertex %s (for linedef tag %d) not found!", sizeu1(i), tag1); + if (mt->extrainfo) mt->z = mt->options; else diff --git a/src/p_spec.c b/src/p_spec.c index 605a34861..265ff4afb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1234,7 +1234,6 @@ static void P_AddExecutorDelay(line_t *line, mobj_t *mobj, sector_t *sector) boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller) { sector_t *ctlsector; - fixed_t dist = P_AproxDistance(triggerline->dx, triggerline->dy)>>FRACBITS; size_t i, linecnt, sectori; INT16 specialtype = triggerline->special; //fromlapexec = false; @@ -1272,6 +1271,8 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller rings = actor->health-1; } + const fixed_t dist = P_AproxDistance(triggerline->dx, triggerline->dy)>>FRACBITS; + if (triggerline->flags & ML_NOCLIMB) { if (rings > dist) @@ -1293,7 +1294,6 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller msecnode_t *node; mobj_t *mo; INT32 numpush = 0; - INT32 numneeded = dist; if (!caller) return false; // we need a calling sector to find pushables in, silly! @@ -1308,6 +1308,8 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller node = node->m_thinglist_next; } + const fixed_t numneeded = P_AproxDistance(triggerline->dx, triggerline->dy)>>FRACBITS; + if (triggerline->flags & ML_NOCLIMB) // Need at least or more { if (numpush < numneeded) @@ -3385,14 +3387,16 @@ DoneSection2: { const fixed_t hscale = mapobjectscale + (mapobjectscale - player->mo->scale); const fixed_t minspeed = 24*hscale; - angle_t pushangle = FixedHypot(player->mo->momx, player->mo->momy) ? R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy) : player->mo->angle; - // if we have no speed for SOME REASON, use the player's angle, otherwise we'd be forcefully thrusted to what I can only assume is angle 0 if (player->mo->eflags & MFE_SPRUNG) break; if (player->speed < minspeed) // Push forward to prevent getting stuck + { + // if we have no speed for SOME REASON, use the player's angle, otherwise we'd be forcefully thrusted to what I can only assume is angle 0 + const angle_t pushangle = FixedHypot(player->mo->momx, player->mo->momy) ? R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy) : player->mo->angle; P_InstaThrust(player->mo, pushangle, minspeed); + } player->kartstuff[k_pogospring] = 1; K_DoPogoSpring(player->mo, 0, 1); @@ -3408,16 +3412,22 @@ DoneSection2: const fixed_t hscale = mapobjectscale + (mapobjectscale - player->mo->scale); const fixed_t minspeed = 24*hscale; const fixed_t maxspeed = 28*hscale; - angle_t pushangle = FixedHypot(player->mo->momx, player->mo->momy) ? R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy) : player->mo->angle; - // if we have no speed for SOME REASON, use the player's angle, otherwise we'd be forcefully thrusted to what I can only assume is angle 0 if (player->mo->eflags & MFE_SPRUNG) break; if (player->speed > maxspeed) // Prevent overshooting jumps + { + // if we have no speed for SOME REASON, use the player's angle, otherwise we'd be forcefully thrusted to what I can only assume is angle 0 + const angle_t pushangle = FixedHypot(player->mo->momx, player->mo->momy) ? R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy) : player->mo->angle; P_InstaThrust(player->mo, pushangle, maxspeed); + } else if (player->speed < minspeed) // Push forward to prevent getting stuck + { + // if we have no speed for SOME REASON, use the player's angle, otherwise we'd be forcefully thrusted to what I can only assume is angle 0 + const angle_t pushangle = FixedHypot(player->mo->momx, player->mo->momy) ? R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy) : player->mo->angle; P_InstaThrust(player->mo, pushangle, minspeed); + } player->kartstuff[k_pogospring] = 2; K_DoPogoSpring(player->mo, 0, 1); @@ -3645,7 +3655,7 @@ DoneSection2: thinker_t *th; mobj_t *waypoint = NULL; mobj_t *mo2; - angle_t an; + if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) break; @@ -3693,10 +3703,13 @@ DoneSection2: CONS_Debug(DBG_GAMELOGIC, "Waypoint %d found in sequence %d - speed = %d\n", waypoint->health, sequence, speed); } - an = R_PointToAngle2(player->mo->x, player->mo->y, waypoint->x, waypoint->y) - player->mo->angle; + if (!(lines[lineindex].flags & ML_EFFECT4)) + { + const angle_t an = R_PointToAngle2(player->mo->x, player->mo->y, waypoint->x, waypoint->y) - player->mo->angle; - if (an > ANGLE_90 && an < ANGLE_270 && !(lines[lineindex].flags & ML_EFFECT4)) - break; // behind back + if (an > ANGLE_90 && an < ANGLE_270) + break; // behind back + } P_SetTarget(&player->mo->tracer, waypoint); player->speed = speed; @@ -3718,7 +3731,6 @@ DoneSection2: thinker_t *th; mobj_t *waypoint = NULL; mobj_t *mo2; - angle_t an; if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) break; @@ -3766,10 +3778,13 @@ DoneSection2: CONS_Debug(DBG_GAMELOGIC, "Waypoint %d found in sequence %d - speed = %d\n", waypoint->health, sequence, speed); } - an = R_PointToAngle2(player->mo->x, player->mo->y, waypoint->x, waypoint->y) - player->mo->angle; + if (!(lines[lineindex].flags & ML_EFFECT4)) + { + const angle_t an = R_PointToAngle2(player->mo->x, player->mo->y, waypoint->x, waypoint->y) - player->mo->angle; - if (an > ANGLE_90 && an < ANGLE_270 && !(lines[lineindex].flags & ML_EFFECT4)) - break; // behind back + if (an > ANGLE_90 && an < ANGLE_270) + break; // behind back + } P_SetTarget(&player->mo->tracer, waypoint); player->speed = speed; @@ -3783,10 +3798,13 @@ DoneSection2: case 10: // Finish Line // SRB2kart - 150117 - if (G_RaceGametype() && (player->starpostnum >= (numstarposts - (numstarposts/2)) || player->exiting)) + if (!G_RaceGametype()) + break; + + if (player->starpostnum >= (numstarposts - (numstarposts/2)) || player->exiting) player->kartstuff[k_starpostwp] = player->kartstuff[k_waypoint] = 0; // - if (G_RaceGametype() && !player->exiting) + if (!player->exiting) { if (player->starpostnum >= (numstarposts - (numstarposts/2))) // srb2kart: must have touched *enough* starposts (was originally "(player->starpostnum == numstarposts)") { @@ -5164,11 +5182,18 @@ void T_LaserFlash(laserthink_t *flash) if (thing->health <= 0) continue; + // thing is neither shootable nor an egg guard shield + if (!(thing->flags & MF_SHOOTABLE) && (thing->type != MT_EGGSHIELD)) + continue; + top = P_GetSpecialTopZ(thing, sourcesec, sector); + + if (thing->z >= top) + continue; + bottom = P_GetSpecialBottomZ(thing, sourcesec, sector); - if (thing->z >= top - || thing->z + thing->height <= bottom) + if (thing->z + thing->height <= bottom) continue; if (thing->flags & MF_SHOOTABLE) @@ -5262,7 +5287,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) continue; // Process Section 1 - switch(GETSECSPECIAL(sector->special, 1)) + switch (GETSECSPECIAL(sector->special, 1)) { case 5: // Spikes P_AddSpikeThinker(sector, (INT32)(sector-sectors)); @@ -5274,7 +5299,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) } // Process Section 2 - switch(GETSECSPECIAL(sector->special, 2)) + switch (GETSECSPECIAL(sector->special, 2)) { case 10: // Time for special stage sstimer = (sector->floorheight>>FRACBITS) * TICRATE + 6; // Time to finish @@ -5287,7 +5312,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) } // Process Section 4 - switch(GETSECSPECIAL(sector->special, 4)) + switch (GETSECSPECIAL(sector->special, 4)) { case 10: // Circuit finish line if (G_RaceGametype()) @@ -5323,11 +5348,13 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) // Allocate each list, and then zero the count so we can use it to track // the end of the list as we add the thinkers for (i = 0; i < numsectors; i++) - if(secthinkers[i].count > 0) + { + if (secthinkers[i].count > 0) { secthinkers[i].thinkers = Z_Malloc(secthinkers[i].count * sizeof(thinker_t *), PU_STATIC, NULL); secthinkers[i].count = 0; } + } // Finally, populate the lists. for (th = thinkercap.next; th != &thinkercap; th = th->next) @@ -6426,15 +6453,19 @@ void T_Scroll(scroll_t *s) if (thing->flags2 & MF2_PUSHED) // Already pushed this tic by an exclusive pusher. continue; - height = P_GetSpecialBottomZ(thing, sec, psec); - if (!(thing->flags & MF_NOCLIP)) // Thing must be clipped - if (!(thing->flags & MF_NOGRAVITY || thing->z+thing->height != height)) // Thing must a) be non-floating and have z+height == height { - // Move objects only if on floor - // non-floating, and clipped. - P_DoScrollMove(thing, dx, dy, s->exclusive); + height = P_GetSpecialBottomZ(thing, sec, psec); + + if (!(thing->flags & MF_NOGRAVITY || thing->z+thing->height != height)) // Thing must a) be non-floating and have z+height == height + { + // Move objects only if on floor + // non-floating, and clipped. + P_DoScrollMove(thing, dx, dy, s->exclusive); + } + } + } // end of for loop through touching_thinglist } // end of loop through sectors } @@ -6448,14 +6479,16 @@ void T_Scroll(scroll_t *s) if (thing->flags2 & MF2_PUSHED) continue; - height = P_GetSpecialBottomZ(thing, sec, sec); - - if (!(thing->flags & MF_NOCLIP) && - (!(thing->flags & MF_NOGRAVITY || thing->z > height))) + if (!(thing->flags & MF_NOCLIP)) // Thing must be clipped { - // Move objects only if on floor or underwater, - // non-floating, and clipped. - P_DoScrollMove(thing, dx, dy, s->exclusive); + height = P_GetSpecialBottomZ(thing, sec, sec); + + if (!(thing->flags & MF_NOGRAVITY || thing->z > height)) + { + // Move objects only if on floor or underwater, + // non-floating, and clipped. + P_DoScrollMove(thing, dx, dy, s->exclusive); + } } } } @@ -6501,14 +6534,16 @@ void T_Scroll(scroll_t *s) if (thing->flags2 & MF2_PUSHED) continue; - height = P_GetSpecialTopZ(thing, sec, psec); - if (!(thing->flags & MF_NOCLIP)) // Thing must be clipped - if (!(thing->flags & MF_NOGRAVITY || thing->z != height))// Thing must a) be non-floating and have z == height { - // Move objects only if on floor or underwater, - // non-floating, and clipped. - P_DoScrollMove(thing, dx, dy, s->exclusive); + height = P_GetSpecialTopZ(thing, sec, psec); + + if (!(thing->flags & MF_NOGRAVITY || thing->z != height))// Thing must a) be non-floating and have z == height + { + // Move objects only if on floor or underwater, + // non-floating, and clipped. + P_DoScrollMove(thing, dx, dy, s->exclusive); + } } } // end of for loop through touching_thinglist } // end of loop through sectors @@ -6523,14 +6558,16 @@ void T_Scroll(scroll_t *s) if (thing->flags2 & MF2_PUSHED) continue; - height = P_GetSpecialTopZ(thing, sec, sec); - - if (!(thing->flags & MF_NOCLIP) && - (!(thing->flags & MF_NOGRAVITY || thing->z+thing->height < height))) + if (!(thing->flags & MF_NOCLIP)) // Thing must be clipped { - // Move objects only if on floor or underwater, - // non-floating, and clipped. - P_DoScrollMove(thing, dx, dy, s->exclusive); + height = P_GetSpecialTopZ(thing, sec, sec); + + if (!(thing->flags & MF_NOGRAVITY || thing->z+thing->height < height)) + { + // Move objects only if on floor or underwater, + // non-floating, and clipped. + P_DoScrollMove(thing, dx, dy, s->exclusive); + } } } } @@ -6993,6 +7030,7 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t * p->magnitude = P_AproxDistance(p->x_mag,p->y_mag)<<(FRACBITS-PUSH_FACTOR); else p->magnitude = P_AproxDistance(p->x_mag,p->y_mag); + if (source) // point source exist? { // where force goes to zero @@ -7043,15 +7081,14 @@ static inline boolean PIT_PushThing(mobj_t *thing) // don't fade wrt Z if health & 2 (mapthing has multi flag) if (tmpusher->source->health & 2) - dist = P_AproxDistance(thing->x - sx,thing->y - sy); + dist = P_AproxDistance(thing->x - sx, thing->y - sy); else { // Make sure the Z is in range if (thing->z < sz - tmpusher->radius || thing->z > sz + tmpusher->radius) return false; - dist = P_AproxDistance(P_AproxDistance(thing->x - sx, thing->y - sy), - thing->z - sz); + dist = P_AproxDistance(P_AproxDistance(thing->x - sx, thing->y - sy), thing->z - sz); } speed = (tmpusher->magnitude - ((dist>>FRACBITS)>>1))<<(FRACBITS - PUSH_FACTOR - 1); @@ -7214,7 +7251,6 @@ void T_Pusher(pusher_t *p) if (p->type == p_push) { - // Seek out all pushable things within the force radius of this // point pusher. Crosses sectors, so use blockmap. @@ -7461,16 +7497,17 @@ static void P_SpawnPushers(void) mobj_t *thing; for (i = 0; i < numlines; i++, l++) + { switch (l->special) { case 541: // wind for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) Add_Pusher(p_wind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); - break; + break; case 544: // current for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) Add_Pusher(p_current, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); - break; + break; case 547: // push/pull for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) { @@ -7482,20 +7519,21 @@ static void P_SpawnPushers(void) case 545: // current up for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) Add_Pusher(p_upcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); - break; + break; case 546: // current down for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) Add_Pusher(p_downcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); - break; + break; case 542: // wind up for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) Add_Pusher(p_upwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); - break; + break; case 543: // wind down for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) Add_Pusher(p_downwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); - break; + break; } + } } void P_StartQuake(tic_t time, fixed_t intensity, fixed_t radius) diff --git a/src/p_user.c b/src/p_user.c index 9df7d2735..f435b60da 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1122,22 +1122,26 @@ void P_SpawnShieldOrb(player_t *player) P_SetTarget(&ov->target, shieldobj); P_SetMobjState(ov, shieldobj->info->seestate); } + if (shieldobj->info->meleestate) { ov = P_SpawnMobj(shieldobj->x, shieldobj->y, shieldobj->z, MT_OVERLAY); P_SetTarget(&ov->target, shieldobj); P_SetMobjState(ov, shieldobj->info->meleestate); } + if (shieldobj->info->missilestate) { ov = P_SpawnMobj(shieldobj->x, shieldobj->y, shieldobj->z, MT_OVERLAY); P_SetTarget(&ov->target, shieldobj); P_SetMobjState(ov, shieldobj->info->missilestate); } + if (player->powers[pw_shield] & SH_FORCE) { //Copy and pasted from P_ShieldLook in p_mobj.c shieldobj->movecount = (player->powers[pw_shield] & 0xFF); + if (shieldobj->movecount < 1) { if (shieldobj->info->painstate) @@ -1569,10 +1573,12 @@ static void P_CheckBouncySectors(player_t *player) newmom = -8*FRACUNIT; } - if (newmom > P_GetPlayerHeight(player)/2) - newmom = P_GetPlayerHeight(player)/2; - else if (newmom < -P_GetPlayerHeight(player)/2) - newmom = -P_GetPlayerHeight(player)/2; + const fixed_t halfpheight = P_GetPlayerHeight(player)/2; + + if (newmom > halfpheight) + newmom = halfpheight; + else if (newmom < -halfpheight) + newmom = -halfpheight; momentum.z = newmom*2; @@ -1835,6 +1841,9 @@ void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range) if (!((mo2->flags & MF_SHOOTABLE && mo2->flags & MF_ENEMY) || mo2->type == MT_EGGGUARD || mo2->player)) continue; + if (mo2->health <= 0) + continue; + dist = P_AproxDistance(P_AproxDistance(player->mo->x-mo2->x, player->mo->y-mo2->y), player->mo->z-mo2->z); if (range < dist) @@ -1843,15 +1852,12 @@ void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range) if (!P_CheckSight(player->mo, mo2)) continue; // if your psychic powers can't "see" it don't bother - if (mo2->health > 0) - { - an = R_PointToAngle2(player->mo->x, player->mo->y, mo2->x, mo2->y); + an = R_PointToAngle2(player->mo->x, player->mo->y, mo2->x, mo2->y); - P_Thrust(mo2, an, thrust); + P_Thrust(mo2, an, thrust); - if (mo2->type == MT_GOLDBUZZ || mo2->type == MT_REDBUZZ) - mo2->tics += 8; - } + if (mo2->type == MT_GOLDBUZZ || mo2->type == MT_REDBUZZ) + mo2->tics += 8; } //P_SpawnThokMobj(player); @@ -2736,16 +2742,16 @@ boolean P_LookForEnemies(player_t *player) || ((mo->z+mo->height < player->mo->z+player->mo->height-FixedMul(MAXSTEPMOVE, mapobjectscale)) && (player->mo->eflags & MFE_VERTICALFLIP))) // Reverse gravity check - Flame. continue; // Don't home upwards! - if (P_AproxDistance(P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y), - player->mo->z-mo->z) > FixedMul(RING_DIST, player->mo->scale)) + const fixed_t modist = P_AproxDistance(P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y), player->mo->z-mo->z); + + if (modist > FixedMul(RING_DIST, player->mo->scale)) continue; // out of range if (UNLIKELY((twodlevel || player->mo->flags2 & MF2_TWOD) && abs(player->mo->y-mo->y) > player->mo->radius)) continue; // not in your 2d plane - if (closestmo && P_AproxDistance(P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y), - player->mo->z-mo->z) > P_AproxDistance(P_AproxDistance(player->mo->x-closestmo->x, + if (closestmo && modist > P_AproxDistance(P_AproxDistance(player->mo->x-closestmo->x, player->mo->y-closestmo->y), player->mo->z-closestmo->z)) continue; @@ -4580,6 +4586,7 @@ void P_PlayerThink(player_t *player) { short int i; mo->flags |= MF_NOCLIPHEIGHT; + for (i = 0; i < 32; i++) { // Debug drawing From 4140f93e41eb2da2a777e5e741b79042a8366445 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 4 Jun 2026 09:00:50 +0200 Subject: [PATCH 354/589] update pingdisplay only once per second this will make sense later...... --- src/d_clisrv.c | 12 ++++++++++-- src/d_clisrv.h | 2 ++ src/hu_stuff.c | 20 ++++++++++++++++++++ src/hu_stuff.h | 1 + src/screen.c | 2 +- src/v_video.c | 10 ++++++++++ 6 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index fb163acfa..23c0551b5 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -125,6 +125,7 @@ static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the UINT16 pingmeasurecount = 1; UINT32 realpingtable[MAXPLAYERS] = {}; //the base table of ping where an average will be sent to everyone. UINT32 playerpingtable[MAXPLAYERS] = {}; //table of player latency values. +UINT32 localplayerping = 0; #define GENTLEMANSMOOTHING (TICRATE) static tic_t reference_lag = 0; @@ -4447,6 +4448,7 @@ void SV_ResetServer(void) pingmeasurecount = 1; memset(realpingtable, 0, sizeof(realpingtable)); memset(playerpingtable, 0, sizeof(playerpingtable)); + localplayerping = 0; ClearAdminPlayers(); @@ -6983,10 +6985,12 @@ static void UpdatePingTable(void) INT32 i; + const boolean playing = Playing(); + if (server) { - //if (Playing() && !(gametime % 8)) // Value chosen based on _my vibes man_ << dont do this for v8 atleast, this is placeboeing ppl to hell and back - if (Playing() && !(gametime % 35)) // update once per second. + //if (playing && !(gametime % 8)) // Value chosen based on _my vibes man_ << dont do this for v8 atleast, this is placeboeing ppl to hell and back + if (playing && !(gametime % 35)) // update once per second. PingUpdate(); fastest = 0; @@ -7045,6 +7049,10 @@ static void UpdatePingTable(void) else lowest_lag = simulated_lag = 0; } + + // this is really dumb but oh well + if (playing && !(gametime % 35)) + localplayerping = playerpingtable[consoleplayer]; } #ifdef HOLEPUNCH diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 8392f13a1..29a33e351 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -650,6 +650,8 @@ extern UINT8 playernode[MAXPLAYERS]; extern boolean player_muted[MAXPLAYERS]; +extern UINT32 localplayerping; + INT32 D_NumPlayers(void); void D_ResetTiccmds(void); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 145ce240f..65bcf4e94 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2478,6 +2478,26 @@ void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) } } +void HU_drawLocalPlayerPing(INT32 x, INT32 y, INT32 flags) +{ + UINT32 lag = localplayerping; + const boolean gentleman = (cv_mindelay.value && (lag < (tic_t)simulated_lag)); + + if (gentleman) + { + lag = simulated_lag; + } + + if (cv_pingstyle.value == 0) // kart + { + HU_drawKartPing(x, y, lag, flags, gentleman); + } + else if (cv_pingstyle.value == 1) // old style ping + { + HU_drawOldPing(x, y, lag, flags, gentleman); + } +} + // // HU_DrawSpectatorTicker // diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 16b4bf0fc..30dfddc0c 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -104,6 +104,7 @@ void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_clearChatChars(void); void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags); // Lat': Ping drawer for scoreboard. +void HU_drawLocalPlayerPing(INT32 x, INT32 y, INT32 flags); void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 hilicol); void HU_DrawEmeralds(INT32 x, INT32 y, INT32 pemeralds); const char *HU_SkinColorToConsoleColor(skincolors_t color); diff --git a/src/screen.c b/src/screen.c index a874ed530..67b7e0bf3 100644 --- a/src/screen.c +++ b/src/screen.c @@ -530,6 +530,6 @@ void SCR_DisplayLocalPing(void) if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level { INT32 dispy = (cv_ticrate.value == 1) ? 165 : ((cv_ticrate.value == 2 || cv_ticrate.value == 4) ? 172 : ((cv_ticrate.value == 3) ? 163 : 181)); // absolute buttpain - HU_drawPlayerPing(308, dispy, consoleplayer, pingflags); // consoleplayer's ping is everyone's ping in a splitnetgame :P + HU_drawLocalPlayerPing(308, dispy, pingflags); // consoleplayer's ping is everyone's ping in a splitnetgame :P } } diff --git a/src/v_video.c b/src/v_video.c index 585478c3a..0f4540216 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2203,6 +2203,7 @@ void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) { if (!*ch) break; + if (*ch & 0x80) //color parsing -x 2.16.09 { // manually set flags override color codes @@ -2213,6 +2214,7 @@ void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) } continue; } + if (*ch == '\n') { cx = x; @@ -2247,6 +2249,7 @@ void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) if (cx > scrwidth) break; + if (cx+left + w < 0) //left boundary check { cx += w; @@ -2304,6 +2307,7 @@ void V_DrawKartString(INT32 x, INT32 y, INT32 option, const char *string) { if (!*ch) break; + if (*ch & 0x80) //color parsing -x 2.16.09 { // manually set flags override color codes @@ -2314,6 +2318,7 @@ void V_DrawKartString(INT32 x, INT32 y, INT32 option, const char *string) } continue; } + if (*ch == '\n') { cx = x; @@ -2348,6 +2353,7 @@ void V_DrawKartString(INT32 x, INT32 y, INT32 option, const char *string) if (cx > scrwidth) break; + if (cx+left + w < 0) //left boundary check { cx += w; @@ -2422,6 +2428,7 @@ void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string) { if (!*ch) break; + if (*ch & 0x80) //color parsing -x 2.16.09 { // manually set flags override color codes @@ -2432,6 +2439,7 @@ void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string) } continue; } + if (*ch == '\n') { cx = x; @@ -2540,6 +2548,7 @@ void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string) { if (!*ch) break; + if (*ch & 0x80) //color parsing -x 2.16.09 { // manually set flags override color codes @@ -2550,6 +2559,7 @@ void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string) } continue; } + if (*ch == '\n') { cx = x; From bd30ab8fb7ad355883f8d606071683f79b426546 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 4 Jun 2026 08:35:36 +0200 Subject: [PATCH 355/589] delet JoyType_t palyer[sic]...... --- src/g_game.c | 24 +++++++++++++----------- src/i_joy.h | 20 +------------------- src/k_hud.c | 2 +- src/m_menu.c | 10 +++++++--- src/p_user.c | 4 ++-- src/sdl/i_system.cpp | 12 ++++-------- src/sdl/i_video.c | 2 +- 7 files changed, 29 insertions(+), 45 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 6554a22be..f6941a911 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -66,8 +66,6 @@ boolean botingame = false; UINT8 botskin = 0; UINT8 botcolor = 0; -JoyType_t Joystick[MAXSPLITSCREENPLAYERS] = {}; - // SRB2kart char gamedatafilename[64] = "kartdata.dat"; char timeattackfolder[64] = "kart"; @@ -755,7 +753,7 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player) if (retaxis > (+JOYAXISRANGE)) retaxis = +JOYAXISRANGE; - if (!Joystick[pnum].bGamepadStyle && axissel < AXISDEAD) + if (!DigitalGamepadStyle(pnum) && axissel < AXISDEAD) { const INT32 jdeadzone = ((JOYAXISRANGE-1) * deadzone) >> FRACBITS; @@ -803,8 +801,8 @@ static void G_HandleLocalDriftturn(ticcmd_t *cmd, UINT8 ssplayer) const UINT8 forplayer = (ssplayer-1); - const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle; - const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle; + const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !DigitalGamepadStyle(forplayer); + const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && DigitalGamepadStyle(forplayer); turnright = InputDown(gc_turnright, ssplayer); turnleft = InputDown(gc_turnleft, ssplayer); @@ -992,10 +990,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) player_t *player = P_GetLocalPlayerForNum(forplayer); camera_t *thiscam = &camera[forplayer]; - const boolean freecam = camera[forplayer].freecam; - - const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle; - const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle; + const boolean freecam = thiscam->freecam; lang = localangle[forplayer]; laim = localaiming[forplayer]; @@ -1027,6 +1022,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) return; } + const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !DigitalGamepadStyle(forplayer); + const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && DigitalGamepadStyle(forplayer); + usejoystick = (analogjoystickmove || gamepadjoystickmove); turnright = InputDown(gc_turnright, ssplayer); turnleft = InputDown(gc_turnleft, ssplayer); @@ -4089,6 +4087,7 @@ char *G_BuildMapTitle(INT32 mapnum) const char *actnum = NULL; len += strlen(mapheaderinfo[mapnum-1]->lvlttl); + if (strlen(mapheaderinfo[mapnum-1]->zonttl) > 0) { zonetext = M_GetText(mapheaderinfo[mapnum-1]->zonttl); @@ -4099,6 +4098,7 @@ char *G_BuildMapTitle(INT32 mapnum) zonetext = M_GetText("Zone"); len += strlen(zonetext) + 1; // ' ' + zonetext } + if (strlen(mapheaderinfo[mapnum-1]->actnum) > 0) { actnum = M_GetText(mapheaderinfo[mapnum-1]->actnum); @@ -4112,8 +4112,10 @@ char *G_BuildMapTitle(INT32 mapnum) sprintf(title, "%s", mapheaderinfo[mapnum-1]->lvlttl); - if (zonetext) sprintf(title + strlen(title), " %s", zonetext); - if (actnum) sprintf(title + strlen(title), " %s", actnum); + if (zonetext) + sprintf(title + strlen(title), " %s", zonetext); + if (actnum) + sprintf(title + strlen(title), " %s", actnum); } return title; diff --git a/src/i_joy.h b/src/i_joy.h index d1282e945..62562e55c 100644 --- a/src/i_joy.h +++ b/src/i_joy.h @@ -36,25 +36,7 @@ extern "C" { "JOYBUTTONS is greater than INT64 bits can hold" #endif -/** \brief The struct JoyType_s - - share some joystick information (maybe 2 for splitscreen), to the game input code, - actually, we need to know if it is a gamepad or analog controls -*/ - -struct JoyType_s -{ - /*! this joystick is a gamepad, read: digital axes - if FALSE, interpret the joystick event data as JOYAXISRANGE (see above) */ - INT32 bGamepadStyle; - -}; -typedef struct JoyType_s JoyType_t; -/** \brief Joystick info - for palyer[sic] 1-4's joystick/gamepad -*/ - -extern JoyType_t Joystick[MAXSPLITSCREENPLAYERS]; +#define DigitalGamepadStyle(i) (cv_joyscale[i].value == 0) #ifdef __cplusplus } // extern "C" diff --git a/src/k_hud.c b/src/k_hud.c index 07d065219..a5f184f7b 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4282,7 +4282,7 @@ static void K_drawInput(void) // kart does not have anything we can get analogue joystick y axis values from // during normal gameplay, so replicate shit here - const boolean analogjoystickmove = (!demo.playback && P_IsLocalPlayer(stplyr) && cv_usejoystick[stplyrnum].value && !Joystick[stplyrnum].bGamepadStyle); + const boolean analogjoystickmove = (!demo.playback && P_IsLocalPlayer(stplyr) && cv_usejoystick[stplyrnum].value && !DigitalGamepadStyle(stplyrnum)); axis = analogjoystickmove ? JoyAxis(AXISAIM, stplyrnum+1) : 0; if (axis != 0) diff --git a/src/m_menu.c b/src/m_menu.c index a6790ff78..499e5b9c4 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1025,11 +1025,12 @@ boolean M_Responder(event_t *ev) const INT32 jxdeadzone = ((JOYAXISRANGE-1) * max(cv_xdeadzone[0].value, FRACUNIT/2)) >> FRACBITS; const INT32 jydeadzone = ((JOYAXISRANGE-1) * max(cv_ydeadzone[0].value, FRACUNIT/2)) >> FRACBITS; INT32 accelaxis = abs(cv_moveaxis[0].value); + if (ev->data1 == 0) { if (ev->data3 != INT32_MAX) { - if (Joystick[0].bGamepadStyle || abs(ev->data3) > jydeadzone) + if (DigitalGamepadStyle(0) || abs(ev->data3) > jydeadzone) { if (joywaity < thistime && (pjoyy == 0 || (ev->data3 < 0) != (pjoyy < 0))) // no previous direction OR change direction @@ -1045,7 +1046,7 @@ boolean M_Responder(event_t *ev) if (ev->data2 != INT32_MAX && joywaitx < thistime) { - if (Joystick[0].bGamepadStyle || abs(ev->data2) > jxdeadzone) + if (DigitalGamepadStyle(0) || abs(ev->data2) > jxdeadzone) { if (joywaitx < thistime && (pjoyx == 0 || (ev->data2 < 0) != (pjoyx < 0))) // no previous direction OR change direction @@ -1064,19 +1065,22 @@ boolean M_Responder(event_t *ev) // The following borrows heavily from Joy1Axis. const boolean xmode = (accelaxis%2); INT32 retaxis = 0; + if (!xmode) accelaxis--; accelaxis /= 2; + if (ev->data1 == accelaxis) { const INT32 jacceldeadzone = xmode ? jxdeadzone : jydeadzone; retaxis = xmode ? ev->data2 : ev->data3; + if (retaxis != INT32_MAX) { if (cv_moveaxis[0].value < 0) retaxis = -retaxis; - if (Joystick[0].bGamepadStyle || retaxis > jacceldeadzone) + if (DigitalGamepadStyle(0) || retaxis > jacceldeadzone) { if (joywaitaccel < thistime && retaxis > pjoyaccel) // only on upwards event { diff --git a/src/p_user.c b/src/p_user.c index f435b60da..26e358cc8 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3155,8 +3155,8 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) cmd->angleturn = (INT16)(lang >> TICCMD_REDUCE); cmd->aiming = G_ClipAimingPitch(&laim); - const boolean analogjoystickmove = cv_usejoystick[num].value && !Joystick[num].bGamepadStyle; - const boolean gamepadjoystickmove = cv_usejoystick[num].value && Joystick[num].bGamepadStyle; + const boolean analogjoystickmove = cv_usejoystick[num].value && !DigitalGamepadStyle(num); + const boolean gamepadjoystickmove = cv_usejoystick[num].value && DigitalGamepadStyle(num); usejoystick = (analogjoystickmove || gamepadjoystickmove); diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 7e1a93835..437c04243 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -743,26 +743,22 @@ INT32 numcontrollers = 0; // void I_JoyScale(void) { - Joystick[0].bGamepadStyle = cv_joyscale[0].value == 0; - JoyInfo[0].scale = Joystick[0].bGamepadStyle ? 1 : cv_joyscale[0].value; + JoyInfo[0].scale = DigitalGamepadStyle(0) ? 1 : cv_joyscale[0].value; } void I_JoyScale2(void) { - Joystick[1].bGamepadStyle = cv_joyscale[1].value == 0; - JoyInfo[1].scale = Joystick[1].bGamepadStyle ? 1 : cv_joyscale[1].value; + JoyInfo[1].scale = DigitalGamepadStyle(1) ? 1 : cv_joyscale[1].value; } void I_JoyScale3(void) { - Joystick[2].bGamepadStyle = cv_joyscale[2].value == 0; - JoyInfo[2].scale = Joystick[2].bGamepadStyle ? 1 : cv_joyscale[2].value; + JoyInfo[2].scale = DigitalGamepadStyle(2) ? 1 : cv_joyscale[2].value; } void I_JoyScale4(void) { - Joystick[3].bGamepadStyle = cv_joyscale[3].value == 0; - JoyInfo[3].scale = Joystick[3].bGamepadStyle ? 1 : cv_joyscale[3].value; + JoyInfo[3].scale = DigitalGamepadStyle(3) ? 1 : cv_joyscale[3].value; } // Cheat to get the device index for a joystick handle diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index a30da7f0a..c736330ad 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -454,7 +454,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) return 0; } - if (Joystick[pid].bGamepadStyle) + if (DigitalGamepadStyle(pid)) { // gamepad control type, on or off, live or die if (raxis < -(JOYAXISRANGE/2)) From f7a32b5f85005e5b76980eebf5e6daffb8ced871 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 4 Jun 2026 08:35:59 +0200 Subject: [PATCH 356/589] init "savegamename" global that was missed --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index e24c66fea..c9df6e441 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -154,7 +154,7 @@ boolean music_disabled = false; INT32 debugload = 0; #endif -char savegamename[256]; +char savegamename[256] = {}; char srb2home[256] = "."; char srb2path[256] = "."; From 746a8cec8b54e3c05e9d7882f0e305a49bc30131 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Mar 2026 16:58:05 +0100 Subject: [PATCH 357/589] hw_main: make HWR_SkyWallList_Add realloc check a little safer stuff like that should always be checked per equals/greater than just equals in practice this shouldnt have caused any issues but its just better practice to check for greater --- src/hardware/hw_main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index d451ccc29..86f906f18 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1167,7 +1167,6 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, static FOutVector* skyWallVertexArray = NULL; static int skyWallVertexArraySize = 0; -static int skyWallVertexArrayAllocSize = 65536;// what a mouthful static boolean gl_collect_skywalls = false; @@ -1178,13 +1177,14 @@ static void HWR_SkyWallList_Clear(void) static void HWR_SkyWallList_Add(FOutVector *wallVerts) { + static int skyWallVertexArrayAllocSize = 65536; // what a mouthful + if (!skyWallVertexArray) { // array has not been allocated yet. allocate it now skyWallVertexArray = static_cast(Z_Malloc(sizeof(FOutVector) * 4 * skyWallVertexArrayAllocSize, PU_STATIC, NULL)); } - - if (skyWallVertexArraySize == skyWallVertexArrayAllocSize) + else if (skyWallVertexArraySize >= skyWallVertexArrayAllocSize) { // allocated array got full, allocate more space skyWallVertexArrayAllocSize *= 2; @@ -1231,6 +1231,7 @@ static void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) HWR_SetCurrentTexture(NULL); HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_NoTexture|PF_Skydecal, 255, NULL); } + // PF_Invisible so it's not drawn into the colour buffer // PF_NoTexture for no texture // PF_Occlude is set in HWR_ProjectWall to draw into the depth buffer @@ -1854,6 +1855,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom HWR_DrawSkyWall(wallVerts, &Surf); } + if (gl_frontsector->floorpic == skyflatnum) { wallVerts[3].y = FixedToFloat(worldbottom); @@ -2119,6 +2121,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom break; } + if (r2) continue; From 956bc3f7dfebafd8ab61983e891db972b72afa46 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 12:31:54 +0200 Subject: [PATCH 358/589] hw renderer cleanups from lugstuff branch mostly just code dedupe with ceepeepee lambdas had checked in the past those didnt cause any real noticeable perf changes --- src/hardware/hw_cache.c | 13 +- src/hardware/hw_main.cpp | 390 +++++++++---------------------- src/hardware/r_opengl/r_opengl.c | 3 +- 3 files changed, 119 insertions(+), 287 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index f7cfceecb..d7c25bf3d 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -446,7 +446,7 @@ typedef struct } GLMapTextureSet_t; // idk i suck at naming things static size_t gl_numtextures = 0; // Texture count -static GLMapTextureSet_t *gl_textures; // For all textures +static GLMapTextureSet_t *gl_textures = NULL; // For all textures static void HWR_FreeTextureData(patch_t *patch) { @@ -570,7 +570,8 @@ void HWR_ClearAllTextures(void) /*static void HWR_FreeColormapCache(void) { HWR_FreePatchCache(false); -}*/ +} +*/ void HWR_InitMapTextures(void) { @@ -622,10 +623,12 @@ static void HWR_PrecacheLevelFlats(void) { // lookup for flats that may´ve been already loaded flatcheck flatpresent; - flatcheck_init(&flatpresent); size_t i, j; INT32 k; + flatcheck_init(&flatpresent); + flatcheck_reserve(&flatpresent, numlevelflats); + // special case for encore #ifdef GLENCORE if (encoremap) @@ -989,7 +992,6 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum) flat[steppy] = glMipmap->colormap->source[flat[steppy]]; } -#endif if (haschromakey) { @@ -1001,6 +1003,7 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum) glMipmap->flags &= ~TF_CHROMAKEYED; } } +#endif } // Download a Doom 'flat' to the hardware cache and make it ready for use @@ -1127,7 +1130,9 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap) HWR_UpdatePatchMipmap(patch, glMipmap); } else + { HWR_LoadPatchMipmap(patch, glMipmap); + } return; } diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 86f906f18..c200d6682 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1403,11 +1403,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // Sky Ceilings wallVerts[3].y = wallVerts[2].y = FLOATMAX; - auto draw_sky_walls = [&](int vert1, int vert2, fixed_t world, fixed_t worldslope) + auto draw_sky_walls = [] + (int vert1, int vert2, fixed_t world, fixed_t worldslope, auto& wwallVerts, auto& sSurf) FUNCINLINE { - wallVerts[vert1].y = FixedToFloat(world); - wallVerts[vert2].y = FixedToFloat(worldslope); - HWR_DrawSkyWall(wallVerts, &Surf); + wwallVerts[vert1].y = FixedToFloat(world); + wwallVerts[vert2].y = FixedToFloat(worldslope); + HWR_DrawSkyWall(wwallVerts, &sSurf); }; if (gl_frontsector->ceilingpic == skyflatnum) @@ -1420,7 +1421,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom && (worldhigh != worldtop || worldhighslope != worldtopslope)) // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race { - draw_sky_walls(0, 1, worldhigh, worldhighslope); + draw_sky_walls(0, 1, worldhigh, worldhighslope, wallVerts, Surf); } // hack to allow height changes in outdoor areas @@ -1431,13 +1432,13 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { // Only the frontsector is sky, just draw a skywall from the front ceiling - draw_sky_walls(0, 1, worldtop, worldtopslope); + draw_sky_walls(0, 1, worldtop, worldtopslope, wallVerts, Surf); } } else if (gl_backsector->ceilingpic == skyflatnum) { // Only the backsector is sky, just draw a skywall from the front ceiling - draw_sky_walls(0, 1, worldtop, worldtopslope); + draw_sky_walls(0, 1, worldtop, worldtopslope, wallVerts, Surf); } // Sky Floors @@ -1455,19 +1456,19 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race && !(gl_sidedef->bottomtexture)) { - draw_sky_walls(3, 2, worldlow, worldlowslope); + draw_sky_walls(3, 2, worldlow, worldlowslope, wallVerts, Surf); } } else { // Only the backsector has sky, just draw a skywall from the back floor - draw_sky_walls(3, 2, worldbottom, worldbottomslope); + draw_sky_walls(3, 2, worldbottom, worldbottomslope, wallVerts, Surf); } } else if ((gl_backsector->floorpic == skyflatnum) && !(gl_sidedef->bottomtexture)) { // Only the backsector has sky, just draw a skywall from the back floor if there's no bottomtexture - draw_sky_walls(3, 2, worldlow, worldlowslope); + draw_sky_walls(3, 2, worldlow, worldlowslope, wallVerts, Surf); } } @@ -1870,28 +1871,38 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom //Hurdler: 3d-floors test if (!gl_drawing_stencil && gl_backsector && gl_frontsector->tag != gl_backsector->tag && (gl_backsector->ffloors || gl_frontsector->ffloors)) { - ffloor_t *rover; fixed_t highcut = 0, lowcut = 0; fixed_t lowcutslope = 0, highcutslope = 0; - // Used for height comparisons and etc across FOFs and slopes - fixed_t high1, highslope1, low1, lowslope1; - fixed_t high2, highslope2, low2, lowslope2; - - INT32 texnum; - lowcut = std::max(worldbottom, worldlow); highcut = std::min(worldtop, worldhigh); lowcutslope = std::max(worldbottomslope, worldlowslope); highcutslope = std::min(worldtopslope, worldhighslope); - if (gl_backsector->ffloors) + auto process_ffloors = [&](boolean backsec) FUNCINLINE { - for (rover = gl_backsector->ffloors; rover; rover = rover->next) + ffloor_t *rover; + INT32 texnum; + + // Used for height comparisons and etc across FOFs and slopes + fixed_t high1, highslope1, low1, lowslope1; + fixed_t high2, highslope2, low2, lowslope2; + + // i suck at naming stuff lul + sector_t* main_sector = backsec ? gl_backsector : gl_frontsector; + sector_t* other_sector = backsec ? gl_frontsector : gl_backsector; + + for (rover = main_sector->ffloors; rover; rover = rover->next) { const ffloortype_e roverflags = rover->flags; - if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES) || (roverflags & FF_INVERTSIDES)) + if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES)) + continue; + + if (backsec && (roverflags & FF_INVERTSIDES)) + continue; + + if (!backsec && !(roverflags & FF_ALLSIDES)) continue; SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) @@ -1901,7 +1912,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom continue; ffloor_t * r2; - for (r2 = gl_frontsector->ffloors; r2; r2 = r2->next) + for (r2 = other_sector->ffloors; r2; r2 = r2->next) { if (r2->master == rover->master) // Skip if same control line. break; @@ -1939,14 +1950,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (r2) continue; - side_t *side = R_GetFFloorSide(gl_curline->linedef, rover, gl_backsector); + const side_t *side = R_GetFFloorSide(gl_curline->linedef, rover, main_sector); boolean do_texture_skew; boolean dont_peg_bottom; if (rover->master->flags & ML_TFERLINE) { - line_t *newline = R_GetFFloorLine(gl_curline->linedef, rover, gl_backsector); + const line_t *newline = R_GetFFloorLine(gl_curline->linedef, rover, main_sector); do_texture_skew = newline->flags & ML_DONTPEGTOP; dont_peg_bottom = newline->flags & ML_DONTPEGBOTTOM; } @@ -1969,6 +1980,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom h = highcut; hS = highcutslope; } + if (l <= lowcut && lS <= lowcutslope) { l = lowcut; @@ -2043,8 +2055,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = HWR_CalcWallLight(lightnum, gl_curline, colormap); - if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, 0, false, &Surf, roverflags, rover, blendmode); + if (other_sector->numlights) + HWR_SplitWall(other_sector, wallVerts, 0, false, &Surf, roverflags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } @@ -2058,8 +2070,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } - if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, texnum, noencore, &Surf, roverflags, rover, blendmode); + if (other_sector->numlights) + HWR_SplitWall(other_sector, wallVerts, texnum, noencore, &Surf, roverflags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -2069,192 +2081,16 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } } + }; + + if (gl_backsector->ffloors) + { + process_ffloors(true); } if (gl_frontsector->ffloors) // Putting this seperate should allow 2 FOF sectors to be connected without too many errors? I think? { - for (rover = gl_frontsector->ffloors; rover; rover = rover->next) - { - const ffloortype_e roverflags = rover->flags; - - if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES) || !(roverflags & FF_ALLSIDES)) - continue; - - SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) - SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) - - if ((high1 < lowcut || highslope1 < lowcutslope) || (low1 > highcut || lowslope1 > highcutslope)) - continue; - - ffloor_t * r2; - for (r2 = gl_backsector->ffloors; r2; r2 = r2->next) - { - if (r2->master == rover->master) // Skip if same control line. - break; - - const ffloortype_e r2flags = r2->flags; - - if (!(r2flags & FF_EXISTS) || !(r2flags & FF_RENDERSIDES)) - continue; - - if (rover->flags & FF_EXTRA) - { - if (!(r2flags & FF_CUTEXTRA)) - continue; - - if (r2flags & FF_EXTRA && (r2flags & (FF_TRANSLUCENT|FF_FOG)) != (rover->flags & (FF_TRANSLUCENT|FF_FOG))) - continue; - } - else - { - if (!(r2flags & FF_CUTSOLIDS)) - continue; - } - - SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight) - SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight) - - if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) - continue; - if ((high1 > high2 || highslope1 > highslope2) || (low1 < low2 || lowslope1 < lowslope2)) - continue; - - break; - } - - if (r2) - continue; - - side_t *side = R_GetFFloorSide(gl_curline->linedef, rover, gl_backsector); - - boolean do_texture_skew; - boolean dont_peg_bottom; - - if (rover->master->flags & ML_TFERLINE) - { - line_t *newline = R_GetFFloorLine(gl_curline->linedef, rover, gl_backsector); - do_texture_skew = newline->flags & ML_DONTPEGTOP; - dont_peg_bottom = newline->flags & ML_DONTPEGBOTTOM; - } - else - { - do_texture_skew = rover->master->flags & ML_DONTPEGTOP; - dont_peg_bottom = gl_curline->linedef->flags & ML_DONTPEGBOTTOM; - } - - texnum = R_GetTextureNum(side->midtexture); - - h = P_GetFFloorTopZAt (rover, v1x, v1y); - hS = P_GetFFloorTopZAt (rover, v2x, v2y); - l = P_GetFFloorBottomZAt(rover, v1x, v1y); - lS = P_GetFFloorBottomZAt(rover, v2x, v2y); - - // Adjust the heights so the FOF does not overlap with top and bottom textures. - if (h >= highcut && hS >= highcutslope) - { - h = highcut; - hS = highcutslope; - } - if (l <= lowcut && lS <= lowcutslope) - { - l = lowcut; - lS = lowcutslope; - } - - //Hurdler: HW code starts here - //FIXME: check if peging is correct - // set top/bottom coords - - wallVerts[3].y = FixedToFloat(h); - wallVerts[2].y = FixedToFloat(hS); - wallVerts[0].y = FixedToFloat(l); - wallVerts[1].y = FixedToFloat(lS); - - if (roverflags & FF_FOG) - { - wallVerts[3].t = wallVerts[2].t = 0; - wallVerts[0].t = wallVerts[1].t = 0; - wallVerts[0].s = wallVerts[3].s = 0; - wallVerts[2].s = wallVerts[1].s = 0; - } - else - { - // Wow, how was this missing from OpenGL for so long? - // ...Oh well, anyway, Lower Unpegged now changes pegging of FOFs like in software - // -- Monster Iestyn 26/06/18 - fixed_t texturevpeg = side->rowoffset; - - glTex = HWR_GetTexture(texnum, noencore); - - if (!do_texture_skew) // no skewing - { - if (dont_peg_bottom) - texturevpeg -= (*rover->topheight - *rover->bottomheight); - - wallVerts[3].t = static_cast((*rover->topheight - h) + texturevpeg) * glTex->scaleY; - wallVerts[2].t = static_cast((*rover->topheight - hS) + texturevpeg) * glTex->scaleY; - wallVerts[0].t = static_cast((*rover->topheight - l) + texturevpeg) * glTex->scaleY; - wallVerts[1].t = static_cast((*rover->topheight - lS) + texturevpeg) * glTex->scaleY; - } - else - { - if (!dont_peg_bottom) // skew by top - { - wallVerts[3].t = wallVerts[2].t = (static_cast(texturevpeg) * glTex->scaleY); - wallVerts[0].t = static_cast((h - l) + texturevpeg) * glTex->scaleY; - wallVerts[1].t = static_cast((hS - lS) + texturevpeg) * glTex->scaleY; - } - else // skew by bottom - { - wallVerts[0].t = wallVerts[1].t = (static_cast(texturevpeg) * glTex->scaleY); - wallVerts[3].t = wallVerts[0].t - static_cast(h - l) * glTex->scaleY; - wallVerts[2].t = wallVerts[1].t - static_cast(hS - lS) * glTex->scaleY; - } - } - - wallVerts[0].s = wallVerts[3].s = cliplow * glTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX; - } - - FBITFIELD blendmode; - - if (roverflags & FF_FOG) - { - blendmode = PF_Fog|PF_NoTexture; - - lightnum = rover->master->frontsector->lightlevel; - colormap = rover->master->frontsector->extra_colormap; - - Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(lightnum, colormap); - - lightnum = HWR_CalcWallLight(lightnum, gl_curline, colormap); - - if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, 0, false, &Surf, roverflags, rover, blendmode); - else - HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); - } - else - { - blendmode = PF_Masked; - - if ((roverflags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) - { - blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast(PF_Translucent); - Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); - } - - if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, texnum, noencore, &Surf, roverflags, rover, blendmode); - else - { - if (blendmode != PF_Masked) - HWR_AddTransparentWall(wallVerts, &Surf, texnum, noencore, blendmode, false, lightnum, colormap); - else - HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); - } - } - } + process_ffloors(false); } } #undef SLOPEPARAMS @@ -2407,7 +2243,7 @@ static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2) // SoM: Backsector needs to be run through R_FakeFlat static sector_t tempsec; - auto do_addline = [&](bool dontdraw) + auto do_addline = [&](bool dontdraw) FUNCINLINE { // Single sided line? if (!line->backsector) @@ -2823,19 +2659,20 @@ static void HWR_AddPolyObjectPlanes(void) for (i = 0; i < numpolys; i++) { - polyobjsector = po_ptrs[i]->lines[0]->backsector; // the in-level polyobject sector - if (!(po_ptrs[i]->flags & POF_RENDERPLANES)) // Only render planes when you should continue; if (po_ptrs[i]->translucency >= NUMTRANSMAPS) continue; + polyobjsector = po_ptrs[i]->lines[0]->backsector; // the in-level polyobject sector + if (polyobjsector->floorheight <= gl_frontsector->ceilingheight && polyobjsector->floorheight >= gl_frontsector->floorheight && (viewz < polyobjsector->floorheight)) { light = R_GetPlaneLight(gl_frontsector, polyobjsector->floorheight, true); + if (po_ptrs[i]->translucency > 0) { FSurfaceInfo Surf = {}; @@ -2858,6 +2695,7 @@ static void HWR_AddPolyObjectPlanes(void) && (viewz > polyobjsector->ceilingheight)) { light = R_GetPlaneLight(gl_frontsector, polyobjsector->ceilingheight, true); + if (po_ptrs[i]->translucency > 0) { FSurfaceInfo Surf = {}; @@ -3077,105 +2915,91 @@ static void HWR_Subsector(size_t num) if (sub->validcount == validcount) continue; - // rendering heights for bottom and top planes - // yes there were functions for this stuff, no idea why it wasnt used but bleh - bottomCullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); - topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); - if (gl_frontsector->cullheight) { if (HWR_DoCulling(gl_frontsector->cullheight, viewsector->cullheight, gl_viewz, FixedToFloat(*rover->bottomheight), FixedToFloat(*rover->topheight))) continue; } - // bottom plane - centerHeight = P_GetFFloorBottomZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); - - if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight && - ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + auto render_plane = [&](boolean bottom, fixed_t cullheight) FUNCINLINE { + fixed_t roverheight; + lumpnum_t flatlump; + + if (bottom) + { + roverheight = *rover->bottomheight; + flatlump = levelflats[*rover->bottompic].lumpnum; + } + else + { + roverheight = *rover->topheight; + flatlump = levelflats[*rover->toppic].lumpnum; + } + if (rover->flags & FF_FOG) { UINT8 alpha; - light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < bottomCullHeight)); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < cullheight)); alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, &extrasubsectors[num], - false, - *rover->bottomheight, + !bottom, + roverheight, *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)); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < cullheight)); - HWR_AddTransparentFloor(levelflats[*rover->bottompic].lumpnum, + HWR_AddTransparentFloor(flatlump, &extrasubsectors[num], - false, - *rover->bottomheight, + !bottom, + roverheight, *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) : static_cast(PF_Translucent)), + CLAMP(rover->alpha, 0, 255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : static_cast(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)); + HWR_GetFlat(flatlump, R_NoEncore(gl_frontsector, !bottom)); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < cullheight)); - 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, + HWR_RenderPlane(sub, &extrasubsectors[num], !bottom, roverheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, flatlump, rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); } + }; + + // bottom plane + centerHeight = P_GetFFloorBottomZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); + + if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight) + { + bottomCullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); + + if ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) + { + render_plane(true, bottomCullHeight); + } } // top plane centerHeight = P_GetFFloorTopZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); - if (centerHeight >= locFloorHeight && - centerHeight <= locCeilingHeight && - ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight) { - if (rover->flags & FF_FOG) + topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); + + if ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) { - UINT8 alpha; - - 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); - } - else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) - { - light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < topCullHeight)); - - HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, - &extrasubsectors[num], - true, - *rover->topheight, - *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) : static_cast(PF_Translucent)), - false, gl_frontsector->lightlist[light].extra_colormap); - } - else - { - HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gl_frontsector, true)); - 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); + render_plane(false, topCullHeight); } } } @@ -4328,7 +4152,7 @@ static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, I wallinfo_t *wallinfo = static_cast(HWR_CreateDrawNode(DRAWNODE_WALL)); memcpy(wallinfo->wallVerts, wallVerts, sizeof (wallinfo->wallVerts)); - memcpy(&wallinfo->Surf, pSurf, sizeof (FSurfaceInfo)); + memcpy(&wallinfo->Surf, pSurf, sizeof(FSurfaceInfo)); wallinfo->texnum = texnum; wallinfo->noencore = noencore; wallinfo->blend = blend; @@ -4460,7 +4284,7 @@ static void HWR_RenderDrawNodes(void) gl_frontsector = NULL; if (!(plane->blend & PF_NoTexture)) - HWR_GetFlat(plane->lumpnum, R_NoEncore(plane->FOFSector, plane->isceiling)); + HWR_GetFlat(plane->lumpnum, R_NoEncore(plane->FOFSector, plane->isceiling)); HWR_RenderPlane(NULL, plane->xsub, plane->isceiling, plane->fixedheight, plane->blend, plane->lightlevel, plane->lumpnum, plane->FOFSector, plane->alpha, plane->planecolormap); @@ -4474,10 +4298,10 @@ static void HWR_RenderDrawNodes(void) gl_frontsector = NULL; if (!(polyplane->blend & PF_NoTexture)) - HWR_GetFlat(polyplane->lumpnum, R_NoEncore(polyplane->FOFSector, polyplane->isceiling)); + HWR_GetFlat(polyplane->lumpnum, R_NoEncore(polyplane->FOFSector, polyplane->isceiling)); HWR_RenderPolyObjectPlane(polyplane->polysector, polyplane->isceiling, polyplane->fixedheight, polyplane->blend, polyplane->lightlevel, - polyplane->lumpnum, polyplane->FOFSector, polyplane->alpha, polyplane->planecolormap); + polyplane->lumpnum, polyplane->FOFSector, polyplane->alpha, polyplane->planecolormap); } break; @@ -4489,7 +4313,7 @@ static void HWR_RenderDrawNodes(void) HWR_GetTexture(wall->texnum, wall->noencore); HWR_RenderWall(wall->wallVerts, &wall->Surf, wall->blend, wall->fogwall, - wall->lightlevel, wall->wallcolormap); + wall->lightlevel, wall->wallcolormap); } break; default: @@ -5501,6 +5325,7 @@ void HWR_SetTransform(float fpov) void HWR_ClearClipper(void) { const angle_t a1 = gld_FrustumAngle(gl_aimingangle); + gld_clipper_Clear(); gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1); #ifdef HAVE_SPHEREFRUSTRUM @@ -5533,9 +5358,9 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool player_t *viewplayer = &players[displayplayers[viewssnum]]; const float fpov = FixedToFloat(R_GetPlayerFov(viewplayer)); - auto reset_viewstate = [&]() + auto reset_viewstate = [](const float pfov) FUNCINLINE { - HWR_SetTransform(fpov); + HWR_SetTransform(pfov); HWR_ClearSprites(); HWR_ClearClipper(); }; @@ -5553,7 +5378,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool currentportallist = &portallist; HWR_SetPortalState(GLPORTAL_SEARCH); - reset_viewstate(); + reset_viewstate(fpov); if (rootportal) { @@ -5579,13 +5404,13 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool // draw normal things in current frame in current incremented stencil buffer area HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); - reset_viewstate(); + reset_viewstate(fpov); if constexpr (Type == RenderViewpointType::kPortal) { if (allow_portals && rootportal) { - HWR_PortalFrame(rootportal);// for portalclipsector, it could have gone null from search + HWR_PortalFrame(rootportal); // for portalclipsector, it could have gone null from search HWR_PortalClipping(rootportal); } } @@ -5661,6 +5486,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool PS_START_TIMING(ps_hw_spritesorttime); HWR_SortVisSprites(); PS_STOP_TIMING(ps_hw_spritesorttime); + PS_START_TIMING(ps_hw_spritedrawtime); if (UNLIKELY(cv_glmdls.value)) HWR_DrawSprites(); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index c8d60871b..de27795e3 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1122,7 +1122,7 @@ static void GL_Perspective(GLfloat fovy, GLfloat aspect) const GLfloat deltaZ = FAR_CLIPPING_PLANE - NEAR_CLIPPING_PLANE; - if ((fabsf((float)deltaZ) < 1.0E-36f) || fpclassify(aspect) == FP_ZERO) + if ((fabsf(deltaZ) < 1.0E-36f) || fpclassify(aspect) == FP_ZERO) { return; } @@ -1583,6 +1583,7 @@ void GL_Draw2DLine(F2DCoord * v1, F2DCoord * v2, RGBA_t Color) angle = atanf((v2->y-v1->y)/(v2->x-v1->x)); else angle = (float)N_PI_DEMI; + dx = sinf(angle) / (float)screen_width; dy = cosf(angle) / (float)screen_height; From ac52ec2c483d71758bed4ddafddec202c0a8f3ec Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 14:50:38 +0200 Subject: [PATCH 359/589] print netcmd name for SendNetXCmdForPlayer warnings makes those prints a little more useful for debug --- src/d_clisrv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 23c0551b5..d5f10daa3 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -357,12 +357,13 @@ void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_ if (2+nparam > MAXTEXTCMD) { - CONS_Alert(CONS_ERROR, M_GetText("packet too large to fit NetXCmd, cannot add netcmd %d! (size: %s, max: %d)\n"), id, sizeu1(2+nparam), MAXTEXTCMD); + CONS_Alert(CONS_ERROR, M_GetText("packet too large to fit NetXCmd, cannot add netcmd %s with id %d! (size: %s, max: %d)\n"), netxcmdnames[id-1], id, sizeu1(2+nparam), MAXTEXTCMD); return; } // for future reference: if (cv_debug) != debug disabled. - CONS_Alert(CONS_NOTICE, M_GetText("NetXCmd buffer full, delaying netcmd %d... (size: %d, needed: %s)\n"), id, localtextcmd[playerid][0], sizeu1(nparam)); + CONS_Alert(CONS_NOTICE, M_GetText("NetXCmd buffer full, delaying netcmd %s with id %d... (size: %d, needed: %s)\n"), netxcmdnames[id-1], id, localtextcmd[playerid][0], sizeu1(nparam)); + if (buf == NULL) { textcmdbuf[playerid] = (textcmdbuf_t*)Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL); From 72d336071116800e11395e6a809614bcae39c7d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 15:59:47 +0200 Subject: [PATCH 360/589] delet this this doesent exist anymore lol --- src/d_netcmd.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index c9520f1a7..d16d2331f 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -51,10 +51,6 @@ extern consvar_t cv_mousevisible; //WTF extern consvar_t cv_mouseturn; extern consvar_t cv_usejoystick[4]; //MAXSPLITSCREENPLAYERS -#ifdef LJOYSTICK -extern consvar_t cv_joyport; -extern consvar_t cv_joyport2; -#endif extern consvar_t cv_joyscale[4]; //MAXSPLITSCREENPLAYERS // normally in p_mobj but the .h is not read From 761766d353de25972a6381c32e2117a9d48be80e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 16:18:49 +0200 Subject: [PATCH 361/589] whitespace fix --- src/sdl/mixer_sound.c | 4 ++-- src/sounds.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index f177412e7..be67b69eb 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -945,7 +945,7 @@ UINT32 I_GetSongLength(void) boolean I_SetSongLoopPoint(UINT32 looppoint) { - if (!music|| !is_looping) + if (!music || !is_looping) return false; const musictype_t mustype = I_SongType(); @@ -958,7 +958,7 @@ boolean I_SetSongLoopPoint(UINT32 looppoint) if (length > 0) looppoint %= length; - loop_point = max((float)(looppoint / 1000.0L), 0); + loop_point = max((float)(looppoint / 1000.0L), 0.0f); return true; } diff --git a/src/sounds.c b/src/sounds.c index dbd5478bd..611539abe 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -1040,6 +1040,7 @@ sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean return i; } } + I_Error("Out of Sound Freeslots while allocating \"%s\"\nLoad less addons to fix this.", name); return 0; } From 1ac029edc6f730a430a7dbbb4c7f35abb732cb3e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 20:04:48 +0200 Subject: [PATCH 362/589] optimize CL_CheckFiles a bit the "already loaded" check will not first compare the md5sum, which is a very simple memcmp, and only then it will do string copies, nameonly mutation and name compare should the md5sum match this should save quite a few unnecessary string operations since the md5 match case will rarely ever hit --- src/d_netfil.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 8865ab618..8e6888e7d 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -549,7 +549,7 @@ INT32 CL_CheckFiles(void) if (fileneeded[i].status != FS_OPEN) filestoload++; - if (fileneeded[i].status != FS_NOTCHECKED) //since we're running this over multiple tics now, its possible for us to come across files checked in previous tics + if (fileneeded[i].status != FS_NOTCHECKED) // since we're running this over multiple tics now, its possible for us to come across files checked in previous tics continue; CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename); @@ -557,14 +557,17 @@ INT32 CL_CheckFiles(void) // Check in already loaded files for (j = mainwads+1; j < numwadfiles; j++) { - nameonly(strcpy(wadfilename, wadfiles[j]->filename)); - - if (fasticmp(wadfilename, fileneeded[i].filename) && - !memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16)) + if (!memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16)) { - CONS_Debug(DBG_NETPLAY, "already loaded\n"); - fileneeded[i].status = FS_OPEN; - return 4; + strcpy(wadfilename, wadfiles[j]->filename); + nameonly(wadfilename); + + if (fasticmp(wadfilename, fileneeded[i].filename)) + { + CONS_Debug(DBG_NETPLAY, "already loaded\n"); + fileneeded[i].status = FS_OPEN; + return 4; + } } } @@ -645,7 +648,7 @@ boolean CL_LoadServerFiles(void) else { const char *s; - switch(fileneeded[i].status) + switch (fileneeded[i].status) { case FS_NOTFOUND: s = "FS_NOTFOUND"; @@ -1066,7 +1069,7 @@ void Got_Filetxpak(void) { const char *s; - switch(file->status) + switch (file->status) { case FS_NOTFOUND: s = "FS_NOTFOUND"; @@ -1194,7 +1197,7 @@ filestatus_t checkfilemd5(char *filename, const UINT8 *wantedmd5sum) fhandle = fopen(filename, "rb"); if (fhandle) { - md5_stream(fhandle,md5sum); + md5_stream(fhandle, md5sum); fclose(fhandle); if (!memcmp(wantedmd5sum, md5sum, 16)) return FS_FOUND; From a3f557f4df9b2a17c394575ed47ed8cd1e2e39d2 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 20:06:59 +0200 Subject: [PATCH 363/589] SV_SendFile: check if I_GetNodeAddress is set before use --- src/d_netfil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 8e6888e7d..8ad9cf07d 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -691,7 +691,7 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid) char wadfilename[MAX_WADPATH]; - if (cv_noticedownload.value) + if (cv_noticedownload.value && I_GetNodeAddress) CONS_Printf("Sending file \"%s\" (id %d) to node %d (%s)\n", filename, fileid, node, I_GetNodeAddress(node)); // Find the last file in the list and set a pointer to its "next" field From df9a23a6c7e9d8d10edc3398833bcd69ae7d6d88 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 20:20:20 +0200 Subject: [PATCH 364/589] CL_CheckFiles: avoid using strcpy wadfile->filename has not a fixed size, so it theoretically might be bigger than wadfilename buffer this probably wont ever happen but better be safe than sorry honestly --- src/d_netfil.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 8ad9cf07d..ff9b1061a 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -559,7 +559,8 @@ INT32 CL_CheckFiles(void) { if (!memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16)) { - strcpy(wadfilename, wadfiles[j]->filename); + strncpy(wadfilename, wadfiles[j]->filename, MAX_WADPATH); + wadfilename[MAX_WADPATH-1] = '\0'; nameonly(wadfilename); if (fasticmp(wadfilename, fileneeded[i].filename)) From 667c67a61aa33d2564498af2e8ee2df62a14e851 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 20:43:11 +0200 Subject: [PATCH 365/589] also avoid strcpy for PutFileNeeded --- src/d_netfil.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index ff9b1061a..61852b436 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -167,7 +167,9 @@ UINT8 *PutFileNeeded(UINT16 firstfile) continue; } - nameonly(strcpy(wadfilename, wadfiles[i]->filename)); + strncpy(wadfilename, wadfiles[i]->filename, MAX_WADPATH); + wadfilename[MAX_WADPATH-1] = '\0'; + nameonly(wadfilename); // Look below at the WRITE macros to understand what these numbers mean. const size_t len = strlen(wadfilename) + 1; @@ -717,7 +719,9 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid) // Look for the requested file through all loaded files for (wadnum = 0; wadfiles[wadnum]; wadnum++) { - strlcpy(wadfilename, wadfiles[wadnum]->filename, MAX_WADPATH); + // im a certified strlcpy hater + strncpy(wadfilename, wadfiles[wadnum]->filename, MAX_WADPATH); + wadfilename[MAX_WADPATH-1] = '\0'; nameonly(wadfilename); if (fasticmp(wadfilename, p->id.filename)) From 4686e8e1125a96d84842d20e23ee7e66f702ad10 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 7 Jun 2022 20:54:10 -0700 Subject: [PATCH 366/589] Do not play invalid sfx --- src/s_sound.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/s_sound.c b/src/s_sound.c index f81690b24..d3265ae0e 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -586,6 +586,14 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) if (!sfx->data) { sfx->data = I_GetSfx(sfx); + + if (!sfx->data) + { + CONS_Alert(CONS_WARNING, + "Tried to load invalid sfx_%s\n", + sfx->name); + return;/* don't play it */ + } } // Avoid channel reverse if surround From b955fdb47db174c2f45b3ae181667b90dcf12357 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 23:07:18 +0200 Subject: [PATCH 367/589] cleanup s_sound a little --- src/s_sound.c | 279 +++++++++++++++++++++++++------------------------- 1 file changed, 142 insertions(+), 137 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index d3265ae0e..5d3c43a3c 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -477,6 +477,11 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) { player_t *player = &players[displayplayers[i]]; + if (!player) + { + continue; + } + if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; @@ -535,87 +540,84 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) i = 0; // sensible default + // Check to see if it is audible, and if not, modify the params + if (origin && !itsUs) { - // Check to see if it is audible, and if not, modify the params - if (origin && !itsUs) + boolean audible = false; + + if (splitscreen > 0) { - boolean audible = false; - if (splitscreen > 0) - { - fixed_t recdist = INT32_MAX; - UINT8 j = 0; + fixed_t recdist = INT32_MAX; + UINT8 j = 0; - for (; j <= splitscreen; j++) + for (; j <= splitscreen; j++) + { + fixed_t thisdist = INT32_MAX; + + if (!listenmobj[j]) { - fixed_t thisdist = INT32_MAX; - - if (!listenmobj[j]) - { - continue; - } - - thisdist = P_AproxDistance(listener[j].x - origin->x, listener[j].y - origin->y); - - if (thisdist >= recdist) - { - continue; - } - - recdist = thisdist; - i = j; + continue; } - } - if (listenmobj[i]) - { - audible = S_AdjustSoundParams(listenmobj[i], origin, &volume, &sep, sfx); - } + thisdist = P_AproxDistance(listener[j].x - origin->x, listener[j].y - origin->y); - if (!audible) - { - return; + if (thisdist >= recdist) + { + continue; + } + + recdist = thisdist; + i = j; } } - // This is supposed to handle the loading/caching. - // For some odd reason, the caching is done nearly - // each time the sound is needed? + if (listenmobj[i]) + { + audible = S_AdjustSoundParams(listenmobj[i], origin, &volume, &sep, sfx); + } + + if (!audible) + { + return; + } + } + + // This is supposed to handle the loading/caching. + // For some odd reason, the caching is done nearly + // each time the sound is needed? + + // cache data if necessary + // NOTE: set sfx->data NULL sfx->lump -1 to force a reload + if (!sfx->data) + { + sfx->data = I_GetSfx(sfx); - // cache data if necessary - // NOTE: set sfx->data NULL sfx->lump -1 to force a reload if (!sfx->data) { - sfx->data = I_GetSfx(sfx); - - if (!sfx->data) - { - CONS_Alert(CONS_WARNING, - "Tried to load invalid sfx_%s\n", - sfx->name); - return;/* don't play it */ - } + CONS_Alert(CONS_WARNING, "Tried to load invalid sfx_%s\n", sfx->name); + return; /* don't play it */ } - - // Avoid channel reverse if surround - if (reverse) - { - sep = (~sep) & 255; - } - - // At this point it is determined that a sound can and should be played, so find a free channel to play it on - cnum = S_getChannel(origin, sfx); - - if (cnum < 0) - { - return; // If there's no free channels, there won't be any for anymore players either - } - - // Now that we know we are going to play a sound, fill out this info - channels[cnum].sfxinfo = sfx; - channels[cnum].origin = origin; - channels[cnum].volume = initial_volume; - channels[cnum].handle = I_StartSound(sfx_id, volume, sep, cnum); } + + // Avoid channel reverse if surround + if (reverse) + { + sep = (~sep) & 255; + } + + // At this point it is determined that a sound can and should be played, so find a free channel to play it on + cnum = S_getChannel(origin, sfx); + + if (cnum < 0) + { + return; // If there's no free channels, there won't be any for anymore players either + } + + // Now that we know we are going to play a sound, fill out this info + channels[cnum].sfxinfo = sfx; + channels[cnum].origin = origin; + channels[cnum].volume = initial_volume; + channels[cnum].handle = I_StartSound(sfx_id, volume, sep, cnum); } void S_StartSound(const void *origin, sfxenum_t sfx_id) @@ -736,6 +738,11 @@ void S_UpdateSounds(void) { player_t *player = &players[displayplayers[i]]; + if (!player) + { + continue; + } + if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; @@ -769,84 +776,83 @@ void S_UpdateSounds(void) { c = &channels[cnum]; - if (c->sfxinfo) + if (c->sfxinfo == NULL) + continue; + + // if channel is allocated but sound has stopped, free it + if (!I_SoundIsPlaying(c->handle)) { - if (I_SoundIsPlaying(c->handle)) + S_StopChannel(cnum); + continue; + } + + if (c->origin == NULL) + continue; + + // initialize parameters + volume = c->volume; // 8 bits internal volume precision + sep = NORM_SEP; + + // check non-local sounds for distance clipping + // or modify their params + boolean itsUs = false; + + for (i = splitscreen; i >= 0; i--) + { + if (camera[i].freecam) + continue; + + if (c->origin != listenmobj[i]) + continue; + + itsUs = true; + } + + if (itsUs == false) + { + const mobj_t *origin = c->origin; + + i = 0; + + if (splitscreen > 0) { - // initialize parameters - volume = c->volume; // 8 bits internal volume precision - sep = NORM_SEP; + fixed_t recdist = INT32_MAX; + UINT8 j = 0; - // check non-local sounds for distance clipping - // or modify their params - if (c->origin) + for (; j <= splitscreen; j++) { - boolean itsUs = false; + fixed_t thisdist = INT32_MAX; - for (i = splitscreen; i >= 0; i--) + if (!listenmobj[j]) { - if (camera[i].freecam) - continue; - - if (c->origin != listenmobj[i]) - continue; - - itsUs = true; + continue; } - if (itsUs == false) + thisdist = P_AproxDistance(listener[j].x - origin->x, listener[j].y - origin->y); + + if (thisdist >= recdist) { - const mobj_t *origin = c->origin; - - i = 0; - - if (splitscreen > 0) - { - fixed_t recdist = INT32_MAX; - UINT8 j = 0; - - for (; j <= splitscreen; j++) - { - fixed_t thisdist = INT32_MAX; - - if (!listenmobj[j]) - { - continue; - } - - thisdist = P_AproxDistance(listener[j].x - origin->x, listener[j].y - origin->y); - - if (thisdist >= recdist) - { - continue; - } - - recdist = thisdist; - i = j; - } - } - - if (listenmobj[i]) - { - audible = S_AdjustSoundParams( - listenmobj[i], c->origin, - &volume, &sep, - c->sfxinfo - ); - } - - if (audible) - I_UpdateSoundParams(c->handle, volume, sep); - else - S_StopChannel(cnum); + continue; } + + recdist = thisdist; + i = j; } } - else + + if (listenmobj[i]) { - // if channel is allocated but sound has stopped, free it - S_StopChannel(cnum); + audible = S_AdjustSoundParams( + listenmobj[i], c->origin, + &volume, &sep, + c->sfxinfo + ); } + + if (audible) + I_UpdateSoundParams(c->handle, volume, sep); + else + S_StopChannel(cnum); } } @@ -874,7 +880,6 @@ void S_ClearSfx(void) static void S_StopChannel(INT32 cnum) { - INT32 i; channel_t *c = &channels[cnum]; if (c->sfxinfo) @@ -883,12 +888,6 @@ static void S_StopChannel(INT32 cnum) if (I_SoundIsPlaying(c->handle)) I_StopSound(c->handle); - // check to see - // if other channels are playing the sound - for (i = 0; i < numofchannels; i++) - if (cnum != i && c->sfxinfo == channels[i].sfxinfo) - break; - c->sfxinfo = NULL; } @@ -1054,12 +1053,14 @@ static boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32 S_OriginPlaying(void *origin) { INT32 cnum; + if (!origin) return false; for (cnum = 0; cnum < numofchannels; cnum++) if (channels[cnum].origin == origin) return 1; + return 0; } @@ -1072,6 +1073,7 @@ INT32 S_IdPlaying(sfxenum_t id) for (cnum = 0; cnum < numofchannels; cnum++) if ((size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)id) return 1; + return 0; } @@ -1080,6 +1082,7 @@ INT32 S_IdPlaying(sfxenum_t id) INT32 S_SoundPlaying(void *origin, sfxenum_t id) { INT32 cnum; + if (!origin) return 0; @@ -1089,6 +1092,7 @@ INT32 S_SoundPlaying(void *origin, sfxenum_t id) && (size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)id) return 1; } + return 0; } @@ -1101,6 +1105,7 @@ static sfxenum_t newsounds[MAXNEWSOUNDS] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; void S_StartSoundName(void *mo, const char *soundname) { INT32 i, soundnum = 0; + // Search existing sounds... for (i = sfx_None + 1; i < NUMSFX; i++) { From fa899d39705c1a658f473754b6ce6efc2b64364a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 7 Jun 2026 07:07:56 +0200 Subject: [PATCH 368/589] fix a few more style issues --- src/d_netfil.c | 16 +++- src/hardware/hw_main.cpp | 193 +++++++++++++++++++-------------------- src/p_spec.c | 49 +++++----- src/p_user.c | 2 +- src/r_bsp.cpp | 21 ++++- src/r_fps.cpp | 8 +- src/r_things.cpp | 3 + 7 files changed, 159 insertions(+), 133 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 61852b436..944d9560b 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -259,9 +259,10 @@ void CL_PrepareDownloadSaveGame(const char *tmpsave) */ boolean CL_CheckDownloadable(void) { - UINT8 i,dlstatus = 0; + UINT8 i, dlstatus = 0; for (i = 0; i < fileneedednum; i++) + { if (fileneeded[i].status != FS_FOUND && fileneeded[i].status != FS_OPEN) { if (fileneeded[i].willsend == 1) @@ -272,6 +273,7 @@ boolean CL_CheckDownloadable(void) else //if (fileneeded[i].willsend == 2) dlstatus = 2; } + } // Downloading locally disabled if (!dlstatus && M_CheckParm("-nodownload")) @@ -282,15 +284,17 @@ boolean CL_CheckDownloadable(void) // not downloadable, put reason in console CONS_Alert(CONS_NOTICE, M_GetText("You need additional files to connect to this server:\n")); + for (i = 0; i < fileneedednum; i++) + { if (fileneeded[i].status != FS_FOUND && fileneeded[i].status != FS_OPEN) { CONS_Printf(" * \"%s\" (%dK)", fileneeded[i].filename, fileneeded[i].totalsize >> 10); - if (fileneeded[i].status == FS_MD5SUMBAD) - CONS_Printf(M_GetText(" wrong version, md5: ")); - else - CONS_Printf(M_GetText(" not found, md5: ")); + if (fileneeded[i].status == FS_MD5SUMBAD) + CONS_Printf(M_GetText(" wrong version, md5: ")); + else + CONS_Printf(M_GetText(" not found, md5: ")); { INT32 j; @@ -301,6 +305,7 @@ boolean CL_CheckDownloadable(void) } CONS_Printf("\n"); } + } switch (dlstatus) { @@ -314,6 +319,7 @@ boolean CL_CheckDownloadable(void) CONS_Printf(M_GetText("All files downloadable, but you have chosen to disable downloading locally.\n")); break; } + return false; } diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index c200d6682..cf5d0fda7 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1222,7 +1222,7 @@ static void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) wallVerts[0].s = wallVerts[3].s = 0; wallVerts[2].s = wallVerts[1].s = 0; - if (UNLIKELY(gl_collect_skywalls)) + if (gl_collect_skywalls) { HWR_SkyWallList_Add(wallVerts); } @@ -2323,7 +2323,7 @@ static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2) } } else - return;// dont do anything with the other side i guess? + return; // dont do anything with the other side i guess? } doaddline: @@ -2829,21 +2829,21 @@ static void HWR_Subsector(size_t num) if (anyMoved == false) { - for (rover = gl_frontsector->ffloors; rover; rover = rover->next) + if (sub->validcount != validcount) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) - continue; + for (rover = gl_frontsector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + continue; - if (sub->validcount == validcount) - continue; + const sector_t *controlSec = §ors[rover->secnum]; - const sector_t *controlSec = §ors[rover->secnum]; + if (controlSec->moved != true) + continue; - if (controlSec->moved != true) - continue; - - anyMoved = true; - break; + anyMoved = true; + break; + } } } @@ -2900,106 +2900,103 @@ static void HWR_Subsector(size_t num) PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum, NULL, 255, ceilingcolormap); } } - } - if (gl_frontsector->ffloors) - { - /// \todo fix light, xoffs, yoffs, extracolormap ? - for (rover = gl_frontsector->ffloors; rover; rover = rover->next) + if (gl_frontsector->ffloors) { - fixed_t bottomCullHeight, topCullHeight, centerHeight; - - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) - continue; - - if (sub->validcount == validcount) - continue; - - if (gl_frontsector->cullheight) + /// \todo fix light, xoffs, yoffs, extracolormap ? + for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { - if (HWR_DoCulling(gl_frontsector->cullheight, viewsector->cullheight, gl_viewz, FixedToFloat(*rover->bottomheight), FixedToFloat(*rover->topheight))) + fixed_t bottomCullHeight, topCullHeight, centerHeight; + + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) continue; - } - auto render_plane = [&](boolean bottom, fixed_t cullheight) FUNCINLINE - { - fixed_t roverheight; - lumpnum_t flatlump; - - if (bottom) + if (gl_frontsector->cullheight) { - roverheight = *rover->bottomheight; - flatlump = levelflats[*rover->bottompic].lumpnum; - } - else - { - roverheight = *rover->topheight; - flatlump = levelflats[*rover->toppic].lumpnum; + if (HWR_DoCulling(gl_frontsector->cullheight, viewsector->cullheight, gl_viewz, FixedToFloat(*rover->bottomheight), FixedToFloat(*rover->topheight))) + continue; } - if (rover->flags & FF_FOG) + auto render_fof_plane = [&](boolean bottom, boolean underside) FUNCINLINE { - UINT8 alpha; + fixed_t roverheight; + lumpnum_t flatlump; - light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < cullheight)); + if (bottom) + { + roverheight = *rover->bottomheight; + flatlump = levelflats[*rover->bottompic].lumpnum; + } + else + { + roverheight = *rover->topheight; + flatlump = levelflats[*rover->toppic].lumpnum; + } - alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + if (rover->flags & FF_FOG) + { + UINT8 alpha; - HWR_AddTransparentFloor(0, - &extrasubsectors[num], - !bottom, - roverheight, - *gl_frontsector->lightlist[light].lightlevel, - alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, - true, rover->master->frontsector->extra_colormap); + light = R_GetPlaneLight(gl_frontsector, centerHeight, underside); + + alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); + + HWR_AddTransparentFloor(0, + &extrasubsectors[num], + !bottom, + roverheight, + *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, underside); + + HWR_AddTransparentFloor(flatlump, + &extrasubsectors[num], + !bottom, + roverheight, + *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) : static_cast(PF_Translucent)), + false, gl_frontsector->lightlist[light].extra_colormap); + } + else + { + HWR_GetFlat(flatlump, R_NoEncore(gl_frontsector, !bottom)); + light = R_GetPlaneLight(gl_frontsector, centerHeight, underside); + + HWR_RenderPlane(sub, &extrasubsectors[num], !bottom, roverheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, flatlump, + rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); + } + }; + + // bottom plane + centerHeight = P_GetFFloorBottomZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); + + if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight) + { + bottomCullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); + + if ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) + { + render_fof_plane(true, (viewz < bottomCullHeight)); + } } - else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient + + // top plane + centerHeight = P_GetFFloorTopZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); + + if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight) { - light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < cullheight)); + topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); - HWR_AddTransparentFloor(flatlump, - &extrasubsectors[num], - !bottom, - roverheight, - *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) : static_cast(PF_Translucent)), - false, gl_frontsector->lightlist[light].extra_colormap); - } - else - { - HWR_GetFlat(flatlump, R_NoEncore(gl_frontsector, !bottom)); - light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < cullheight)); - - HWR_RenderPlane(sub, &extrasubsectors[num], !bottom, roverheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, flatlump, - rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); - } - }; - - // bottom plane - centerHeight = P_GetFFloorBottomZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); - - if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight) - { - bottomCullHeight = P_GetFFloorBottomZAt(rover, viewx, viewy); - - if ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) - { - render_plane(true, bottomCullHeight); - } - } - - // top plane - centerHeight = P_GetFFloorTopZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); - - if (centerHeight >= locFloorHeight && centerHeight <= locCeilingHeight) - { - topCullHeight = P_GetFFloorTopZAt(rover, viewx, viewy); - - if ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) - { - render_plane(false, topCullHeight); + if ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES))) + { + render_fof_plane(false, (viewz < topCullHeight)); + } } } } diff --git a/src/p_spec.c b/src/p_spec.c index 265ff4afb..ca86f8ee4 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -881,7 +881,7 @@ static boolean PolyDoor(line_t *line) pdd.polyObjNum = line->tag; // polyobject id - switch(line->special) + switch (line->special) { case 480: // Polyobj_DoorSlide pdd.doorType = POLY_DOOR_SLIDE; @@ -1597,19 +1597,21 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller) if (lines[masterline].tag != tag) continue; + const INT16 specialtype = lines[masterline].special; + // "No More Enemies" and "Level Load" take care of themselves. - if (lines[masterline].special == 313 - || lines[masterline].special == 399 - || lines[masterline].special == 328 - || lines[masterline].special == 323 + if (specialtype == 313 + || specialtype == 399 + || specialtype == 328 + || specialtype == 323 // Each-time executors handle themselves, too - || lines[masterline].special == 301 // Each time - || lines[masterline].special == 306 // Character ability - Each time - || lines[masterline].special == 310 // CTF Red team - Each time - || lines[masterline].special == 312 // CTF Blue team - Each time - || lines[masterline].special == 322 // Trigger on X calls - Each Time - || lines[masterline].special < 300 - || lines[masterline].special > 399) + || specialtype == 301 // Each time + || specialtype == 306 // Character ability - Each time + || specialtype == 310 // CTF Red team - Each time + || specialtype == 312 // CTF Blue team - Each time + || specialtype == 322 // Trigger on X calls - Each Time + || specialtype < 300 + || specialtype > 399) continue; if (!P_RunTriggerLinedef(&lines[masterline], actor, caller)) @@ -4736,7 +4738,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f P_AddSpikeThinker(sec, (INT32)sec2num); } // Should this FOF have friction? - else if(th->function == (actionf_p1)T_Friction) + else if (th->function == (actionf_p1)T_Friction) { f = (friction_t *)th; @@ -4744,7 +4746,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f Add_Friction(f->friction, f->movefactor, (INT32)(sec-sectors), f->affectee); } // Should this FOF have wind/current/pusher? - else if(th->function == (actionf_p1)T_Pusher) + else if (th->function == (actionf_p1)T_Pusher) { p = (pusher_t *)th; @@ -6946,6 +6948,7 @@ static void P_SpawnFriction(void) INT32 movefactor; // applied to each player move to simulate inertia for (i = 0; i < numlines; i++, l++) + { if (l->special == 540) { //length = P_AproxDistance(l->dx, l->dy)>>FRACBITS; @@ -6979,6 +6982,7 @@ static void P_SpawnFriction(void) for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) Add_Friction(friction, movefactor, s, -1); } + } } /* @@ -7293,13 +7297,16 @@ void T_Pusher(pusher_t *p) if (thing->flags2 & MF2_PUSHED) continue; - if (thing->player && thing->player->pflags & PF_ROPEHANG) - continue; + if (thing->player) + { + if (thing->player->pflags & PF_ROPEHANG) + continue; - if (thing->player && (thing->state == &states[thing->info->painstate]) - && (thing->player->powers[pw_flashing] > (K_GetKartFlashing(thing->player)/4)*3 - && thing->player->powers[pw_flashing] <= K_GetKartFlashing(thing->player))) - continue; + if ((thing->state == &states[thing->info->painstate]) + && (thing->player->powers[pw_flashing] > (K_GetKartFlashing(thing->player)/4)*3 + && thing->player->powers[pw_flashing] <= K_GetKartFlashing(thing->player))) + continue; + } inFOF = touching = moved = false; @@ -7429,7 +7436,7 @@ void T_Pusher(pusher_t *p) if (p->slider && thing->player) { boolean jumped = (thing->player->pflags & PF_JUMPED); - P_ResetPlayer (thing->player); + P_ResetPlayer(thing->player); if (jumped) thing->player->pflags |= PF_JUMPED; diff --git a/src/p_user.c b/src/p_user.c index 26e358cc8..11c5e0b81 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2361,7 +2361,7 @@ static void P_MovePlayer(player_t *player) if (onground && leveltime % 50 == 0 && player->kartstuff[k_drift] != 0) S_StartSound(player->mo, sfx_drift); // Leveltime being 50 might take a while at times. We'll start it up once, isntantly. - else if (onground && !S_SoundPlaying(player->mo, sfx_drift) && player->kartstuff[k_drift] != 0) + else if (onground && player->kartstuff[k_drift] != 0 && !S_SoundPlaying(player->mo, sfx_drift)) S_StartSound(player->mo, sfx_drift); // Ok, we'll stop now. else if (player->kartstuff[k_drift] == 0 || !onground) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 8fd66299c..68de16478 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -321,12 +321,19 @@ static void R_AddLine(seg_t *line) angle_t angle1, angle2, span, tspan; static sector_t tempsec; boolean bothfloorssky = false; + fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t g_portal = NULL; + v1x = line->v1->x; + v1y = line->v1->y; + + v2x = line->v2->x; + v2y = line->v2->y; + // big room fix - angle1 = R_PointToAngle64(line->v1->x, line->v1->y); - angle2 = R_PointToAngle64(line->v2->x, line->v2->y); + angle1 = R_PointToAngle64(v1x, v1y); + angle2 = R_PointToAngle64(v2x, v2y); curline = line; @@ -519,6 +526,7 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) angle_t angle1, angle2; INT32 sx1, sx2; const INT32* check; + fixed_t x1, y1, x2, y2; // Find the corners of the box // that define the edges from current viewpoint. @@ -532,9 +540,14 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) check = checkcoord[boxpos]; + x1 = bspcoord[check[0]]; + y1 = bspcoord[check[1]]; + x2 = bspcoord[check[2]]; + y2 = bspcoord[check[3]]; + // big room fix - angle1 = R_PointToAngle64(bspcoord[check[0]], bspcoord[check[1]]) - viewangle; - angle2 = R_PointToAngle64(bspcoord[check[2]], bspcoord[check[3]]) - viewangle; + angle1 = R_PointToAngle64(x1, y1) - viewangle; + angle2 = R_PointToAngle64(x2, y2) - viewangle; // cph - replaced old code, which was unclear and badly commented // Much more efficient code now diff --git a/src/r_fps.cpp b/src/r_fps.cpp index 7ccebf8e5..8372fa30f 100644 --- a/src/r_fps.cpp +++ b/src/r_fps.cpp @@ -387,10 +387,10 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst return; } - out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); - out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); - out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); - out->scale = mapobjectscale; + out->x = R_LerpFixed(mobj->old_x, mobj->x, frac); + out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); + out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); + out->scale = mapobjectscale; } static levelinterpolator_t *CreateInterpolator(levelinterpolator_type_e type, thinker_t *thinker) diff --git a/src/r_things.cpp b/src/r_things.cpp index 52f8be112..875cb7290 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -773,6 +773,7 @@ static void R_DrawVisSprite(vissprite_t *vis) R_SetColumnFunc(BASEDRAWFUNC); // hack: this isn't resetting properly somewhere. dc.colormap = vis->colormap; + if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" { R_SetColumnFunc(COLDRAWFUNC_TRANS); // translate certain pixels to white @@ -825,6 +826,7 @@ static void R_DrawVisSprite(vissprite_t *vis) else dc.colormap = &vis->extra_colormap->colormap[dc.colormap - colormaps]; } + if (!dc.colormap) dc.colormap = colormaps; @@ -849,6 +851,7 @@ static void R_DrawVisSprite(vissprite_t *vis) vis->xiscale = FixedDiv(vis->xiscale, this_scale); vis->isScaled = true; } + dc.texturemid = FixedDiv(dc.texturemid, this_scale); } From b4cad08ad330aa2162b87193c4bc7d9b72a2d681 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 8 Jun 2026 09:44:19 +0200 Subject: [PATCH 369/589] cleanup p_spec/p_setup a bit --- src/p_setup.c | 26 ++++++------ src/p_spec.c | 114 ++++++++++++++++++++++++++++++++++---------------- src/sounds.c | 2 +- 3 files changed, 91 insertions(+), 51 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index afc53234b..a1b1fb3cb 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1215,14 +1215,14 @@ static void P_LoadSideChangeMusic(boolean firstside, mapsidedef_t *msd, side_t * if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') { - memcpy(process,msd->bottomtexture,8); + 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') { - memcpy(process,msd->midtexture,8); + memcpy(process, msd->midtexture, 8); process[8] = '\0'; sd->midtexture = get_number(process); } @@ -1232,7 +1232,7 @@ static void P_LoadSideChangeMusic(boolean firstside, mapsidedef_t *msd, side_t * if (firstside || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') { - memcpy(process,msd->toptexture,8); + memcpy(process, msd->toptexture, 8); process[8] = '\0'; // If they type in O_ or D_ and their music name, just shrug, @@ -1272,7 +1272,7 @@ static void P_LoadSidedefs(void *data) // Colormaps! switch (sd->special) { - case 63: // variable colormap via 242 linedef + case 63: // variable colormap via 242 linedef 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. @@ -1288,21 +1288,21 @@ static void P_LoadSidedefs(void *data) if (msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') { char process[8+1]; - memcpy(process,msd->toptexture,8); + memcpy(process, msd->toptexture, 8); process[8] = '\0'; sd->toptexture = get_number(process); } break; } - case 9: // Mace parameters - case 14: // Bustable block parameters - case 15: // Fan particle spawner parameters + case 9: // Mace parameters + case 14: // Bustable block parameters + case 15: // Fan particle spawner parameters case 425: // Calls P_SetMobjState on calling mobj case 434: // Custom Power case 442: // Calls P_SetMobjState on mobjs of a given type in the tagged sectors { char process[8*3+1]; - memset(process,0,8*3+1); + memset(process, 0, 8*3+1); sd->toptexture = sd->midtexture = sd->bottomtexture = 0; if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0') break; @@ -1319,7 +1319,7 @@ static void P_LoadSidedefs(void *data) case 443: // Calls a named Lua function { char process[8*3+1]; - memset(process,0,8*3+1); + memset(process, 0, 8*3+1); sd->toptexture = sd->midtexture = sd->bottomtexture = 0; if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0') break; @@ -2927,7 +2927,7 @@ static size_t sreplaces = 0, mreplaces = 0, digmreplaces = 0; static boolean P_CheckSoundReplacements(UINT16 wadnum, char *name, size_t i) { size_t j; - lumpnum_t lumpnum = (i|(wadnum<<16)); + lumpnum_t lumpnum = (i | (wadnum<<16)); if (name[0] == 'D') { @@ -2935,8 +2935,8 @@ static boolean P_CheckSoundReplacements(UINT16 wadnum, char *name, size_t i) { for (j = 1; j < NUMSFX; j++) { - if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6) - && (S_sfx[j].lumpnum != lumpnum) && (S_sfx[j].lumpnum != LUMPERROR)) + if ((S_sfx[j].lumpnum != lumpnum) && (S_sfx[j].lumpnum != LUMPERROR) && + S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6)) { // the sound will be reloaded when needed, // since sfx->data will be NULL diff --git a/src/p_spec.c b/src/p_spec.c index ca86f8ee4..63a0ceaea 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1338,6 +1338,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller else if (secspecial == 7) // SRB2Kart: reusing for Race Lap executor { UINT8 lap; + INT32 targlap; if (actor && actor->player && triggerline->flags & ML_EFFECT4) { @@ -1348,19 +1349,21 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller lap = P_FindLowestLap(); } + targlap = (INT32)(sides[triggerline->sidenum[0]].textureoffset >> FRACBITS); + if (triggerline->flags & ML_NOCLIMB) // Need higher than or equal to { - if (lap < (sides[triggerline->sidenum[0]].textureoffset >> FRACBITS)) + if (lap < targlap) return false; } else if (triggerline->flags & ML_BLOCKMONSTERS) // Need lower than or equal to { - if (lap > (sides[triggerline->sidenum[0]].textureoffset >> FRACBITS)) + if (lap > targlap) return false; } else // Need equal to { - if (lap != (sides[triggerline->sidenum[0]].textureoffset >> FRACBITS)) + if (lap != targlap) return false; } @@ -1452,6 +1455,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller if (triggerline->flags & ML_EFFECT5) // disregard order for efficiency { for (i = 0; i < linecnt; i++) + { if (ctlsector->lines[i]->special >= 400 && ctlsector->lines[i]->special < 500) { @@ -1460,6 +1464,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller else P_ProcessLineSpecial(ctlsector->lines[i], actor, caller); } + } } else // walk around the sector in a defined order { @@ -1467,11 +1472,13 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller size_t j, masterlineindex = (size_t)-1; for (i = 0; i < linecnt; i++) + { if (ctlsector->lines[i] == triggerline) { masterlineindex = i; break; } + } #ifdef PARANOIA if (masterlineindex == (size_t)-1) @@ -1490,11 +1497,13 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller { if (i == j) continue; + if (ctlsector->lines[i]->v1 == ctlsector->lines[j]->v2) { i = j; break; } + if (ctlsector->lines[i]->v1 == ctlsector->lines[j]->v1) { i = j; @@ -1502,6 +1511,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller break; } } + if (j == linecnt) { const size_t vertexei = (size_t)(ctlsector->lines[i]->v1 - vertexes); @@ -1516,11 +1526,13 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller { if (i == j) continue; + if (ctlsector->lines[i]->v2 == ctlsector->lines[j]->v1) { i = j; break; } + if (ctlsector->lines[i]->v2 == ctlsector->lines[j]->v2) { i = j; @@ -2423,7 +2435,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_SetPlayerMobjState(mo, S_KART_STND1); // SRB2kart - was S_PLAY_STND // Reset bot too. - if (bot) { + if (bot) + { if (line->flags & ML_NOCLIMB) P_SetOrigin(bot, mo->x, mo->y, mo->z); bot->momx = bot->momy = bot->momz = 1; @@ -2506,6 +2519,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_SetTarget(&dummy->target, bot); A_CustomPower(dummy); } + P_RemoveMobj(dummy); } break; @@ -2569,11 +2583,15 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (mo && mo->player) { UINT16 fractime = (UINT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); + if (fractime < 1) fractime = 1; //instantly wears off upon leaving + if (line->flags & ML_NOCLIMB) fractime |= 1<<15; //more crazy &ing, as if music stuff wasn't enough + mo->player->powers[pw_nocontrol] = fractime; + if (bot) bot->player->powers[pw_nocontrol] = fractime; } @@ -2583,8 +2601,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (mo) { mo->destscale = FixedDiv(P_AproxDistance(line->dx, line->dy), 100<destscale < FRACUNIT/100) mo->destscale = FRACUNIT/100; + if (mo->player && bot) bot->destscale = mo->destscale; } @@ -2669,9 +2689,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { boolean tryagain; sec = sectors + secnum; + do { tryagain = false; for (thing = sec->thinglist; thing; thing = thing->snext) + { if (thing->type == type) { if (state != NUMSTATES) @@ -2688,6 +2710,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; } } + } } while (tryagain); } break; @@ -3263,6 +3286,7 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers case 3: // Linedef executor requires all players present // Trigger Linedef Exec (Floor Touch, All Players) /// \todo check continues for proper splitscreen support? for (i = 0; i < MAXPLAYERS; i++) + { if (playeringame[i] && !players[i].bot && players[i].mo && (gametype != GT_COOP || players[i].lives > 0)) { if (roversector) @@ -3316,6 +3340,7 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers goto DoneSection2; } } + } /* FALLTHRU */ case 4: // Linedef executor that doesn't require touching floor // Trigger Linedef Exec (Anywhere in Sector) case 5: // Linedef executor // Trigger Linedef Exec (Floor Touch) @@ -3451,8 +3476,10 @@ DoneSection2: angle_t lineangle; fixed_t linespeed; - lineangle = lines[i].angle; - linespeed = P_AproxDistance(lines[i].v2->x-lines[i].v1->x, lines[i].v2->y-lines[i].v1->y); + const line_t *line = &lines[i]; + + lineangle = line->angle; + linespeed = P_AproxDistance(line->v2->x-line->v1->x, line->v2->y-line->v1->y); player->mo->angle = lineangle; @@ -3466,7 +3493,7 @@ DoneSection2: P_ForceLocalAngle(player, player->mo->angle); } - if (!(lines[i].flags & ML_EFFECT4)) + if (!(line->flags & ML_EFFECT4)) { P_UnsetThingPosition(player->mo); if (roversector) // make FOF speed pads work @@ -3537,21 +3564,25 @@ DoneSection2: P_DoPlayerExit(player); P_SetupSignExit(player); - // important: use sector->tag on next line instead of player->mo->subsector->tag - // this part is different from in P_PlayerThink, this is what was causing - // FOF custom exits not to work. - lineindex = P_FindSpecialLineFromTag(2, sector->tag, -1); - if (gametype == GT_COOP && lineindex != -1) // Custom exit! + if (gametype == GT_COOP) { - // Special goodies with the block monsters flag depending on emeralds collected - if ((lines[lineindex].flags & ML_BLOCKMONSTERS) && ALL7EMERALDS(emeralds)) - nextmapoverride = (INT16)(lines[lineindex].frontsector->ceilingheight>>FRACBITS); - else - nextmapoverride = (INT16)(lines[lineindex].frontsector->floorheight>>FRACBITS); + // important: use sector->tag on next line instead of player->mo->subsector->tag + // this part is different from in P_PlayerThink, this is what was causing + // FOF custom exits not to work. + lineindex = P_FindSpecialLineFromTag(2, sector->tag, -1); - if (lines[lineindex].flags & ML_NOCLIMB) - skipstats = true; + if (lineindex != -1) // Custom exit!) + { + // Special goodies with the block monsters flag depending on emeralds collected + if ((lines[lineindex].flags & ML_BLOCKMONSTERS) && ALL7EMERALDS(emeralds)) + nextmapoverride = (INT16)(lines[lineindex].frontsector->ceilingheight>>FRACBITS); + else + nextmapoverride = (INT16)(lines[lineindex].frontsector->floorheight>>FRACBITS); + + if (lines[lineindex].flags & ML_NOCLIMB) + skipstats = true; + } } } break; @@ -3658,7 +3689,6 @@ DoneSection2: mobj_t *waypoint = NULL; mobj_t *mo2; - if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) break; @@ -4523,27 +4553,13 @@ void P_PlayerInSpecialSector(player_t *player) #undef TELEPORTED -/** Animate planes, scroll walls, etc. and keeps track of level timelimit and exits if time is up. - * - * \sa P_CheckTimeLimit, P_CheckPointLimit - */ -void P_UpdateSpecials(void) +static void P_UpdateAnimFlats(void) { anim_t *anim; INT32 i; size_t j; levelflat_t *foundflats; // for flat animation - // LEVEL TIMER - P_CheckTimeLimit(); - - // POINT LIMIT - P_CheckPointLimit(); - - // Dynamic slopeness - if (!midgamejoin) // run here when not joined midgame to prevent any potential issues that may arise - P_RunDynamicSlopes(); - // ANIMATE TEXTURES for (anim = anims; anim < lastanim; anim++) { @@ -4573,15 +4589,38 @@ void P_UpdateSpecials(void) } } +/** Animate planes, scroll walls, etc. and keeps track of level timelimit and exits if time is up. + * + * \sa P_CheckTimeLimit, P_CheckPointLimit + */ +void P_UpdateSpecials(void) +{ + // LEVEL TIMER + P_CheckTimeLimit(); + + // POINT LIMIT + P_CheckPointLimit(); + + // Dynamic slopeness + // we run this here only when not joined midrace + // for vanilla compat reasons :chaosleep: + if (!midgamejoin) + P_RunDynamicSlopes(); + + P_UpdateAnimFlats(); +} + static inline ffloor_t *P_GetFFloorBySec(sector_t *sec, sector_t *sec2) { ffloor_t *rover; if (!sec->ffloors) return NULL; + for (rover = sec->ffloors; rover; rover = rover->next) if (rover->secnum == (size_t)(sec2 - sectors)) return rover; + return NULL; } @@ -4632,6 +4671,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if (sec == sec2) return NULL; //Don't need a fake floor on a control sector. + if ((ffloor = (P_GetFFloorBySec(sec, sec2)))) return ffloor; // If this ffloor already exists, return it @@ -7031,9 +7071,9 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t * // "The right triangle of the square of the length of the hypotenuse is equal to the sum of the squares of the lengths of the other two sides." // "Bah! Stupid brains! Don't you know anything besides the Pythagorean Theorem?" - Earthworm Jim if (type == p_downcurrent || type == p_upcurrent || type == p_upwind || type == p_downwind) - p->magnitude = P_AproxDistance(p->x_mag,p->y_mag)<<(FRACBITS-PUSH_FACTOR); + p->magnitude = P_AproxDistance(p->x_mag, p->y_mag)<<(FRACBITS-PUSH_FACTOR); else - p->magnitude = P_AproxDistance(p->x_mag,p->y_mag); + p->magnitude = P_AproxDistance(p->x_mag, p->y_mag); if (source) // point source exist? { diff --git a/src/sounds.c b/src/sounds.c index 611539abe..3769bf65b 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -975,7 +975,7 @@ sfxinfo_t S_sfx[NUMSFX] = char freeslotnames[sfx_freeslot0 + NUMSFXFREESLOTS + NUMSKINSFXSLOTS][7] = {}; // Prepare free sfx slots to add sfx at run time -void S_InitRuntimeSounds (void) +void S_InitRuntimeSounds(void) { sfxenum_t i; INT32 value; From 8cb321993e93bc33721ea934b24dbc8c53bcc50e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 8 Jun 2026 09:45:29 +0200 Subject: [PATCH 370/589] restore functionality to set zipper/speed pad sounds set using the front side upper texture field like the play sound special per "DSXXXX" the parsing part already was there but not the actual code to make it use the specified sound for some reason lul shouldnt break anything and is vanilla compatible! --- src/p_spec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 63a0ceaea..978c3041e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3473,6 +3473,7 @@ DoneSection2: if (i != -1) { + INT32 sfxnum; angle_t lineangle; fixed_t linespeed; @@ -3515,7 +3516,14 @@ DoneSection2: player->kartstuff[k_drift] = 0; player->kartstuff[k_driftcharge] = 0; player->kartstuff[k_pogospring] = 0; - S_StartSound(player->mo, sfx_spdpad); + + sfxnum = sides[line->sidenum[0]].toptexture; + + // none or invalid sound? + if (sfxnum <= sfx_None || sfxnum >= NUMSFX) + sfxnum = sfx_spdpad; // use the zippy sound then! + + S_StartSound(player->mo, sfxnum); { sfxenum_t pick = P_RandomKey(2); // Gotta roll the RNG every time this is called for sync reasons From 8db399be9bb00706d3fd50269133d7c60d7bb130 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 12 Jun 2026 16:38:25 +0300 Subject: [PATCH 371/589] Allow lookback in replays (currently only works for player 1) --- src/p_tick.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/p_tick.c b/src/p_tick.c index 24142a823..51aa89487 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -611,6 +611,16 @@ void P_Ticker(boolean run) #ifdef DEMO_COMPAT_100 } #endif + + // Lookback is normally handled inside G_BuildTiccmd, which isn't called in replays so we're doing that manually + // idk if this is best place to handle this tho... + // TODO - make it actually work for players other than player 1, other splitscreen players still ignore camspin for some reason + for (INT32 i = 0; i <= splitscreen; ++i) + { + const boolean usejoystick = cv_usejoystick[i].value; + INT32 axis = JoyAxis(AXISLOOKBACK, i); + camspin[i] = (InputDown(gc_lookback, i) || (usejoystick && axis > 0)); + } } ps_lua_mobjhooks.value.i = 0; From 50f839e1ad6a846e5de55fd5304cebc274246c17 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 12 Jun 2026 16:47:55 +0300 Subject: [PATCH 372/589] Fix JoyAxis and InputDown inputs being off by one, this fixes lookback only working for p1 (ty lug <3) --- src/p_tick.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 51aa89487..3692f9205 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -614,12 +614,11 @@ void P_Ticker(boolean run) // Lookback is normally handled inside G_BuildTiccmd, which isn't called in replays so we're doing that manually // idk if this is best place to handle this tho... - // TODO - make it actually work for players other than player 1, other splitscreen players still ignore camspin for some reason - for (INT32 i = 0; i <= splitscreen; ++i) + for (i = 0; i <= splitscreen; ++i) { const boolean usejoystick = cv_usejoystick[i].value; - INT32 axis = JoyAxis(AXISLOOKBACK, i); - camspin[i] = (InputDown(gc_lookback, i) || (usejoystick && axis > 0)); + INT32 axis = JoyAxis(AXISLOOKBACK, i+1); + camspin[i] = (InputDown(gc_lookback, i+1) || (usejoystick && axis > 0)); } } From 3c227ec532592ec91da874ff992a8d330016e10c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 12 Jun 2026 22:06:47 +0200 Subject: [PATCH 373/589] P_CheckSight: fix rare overflow in rejectmatrix check didnt think this could overflow here but well it does wish there was a better way to bounds check heap arrays in C --- src/p_local.h | 8 +++++++- src/p_setup.c | 19 ++++++++++++------- src/p_sight.c | 21 ++++++++++++--------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 383469bcc..eb55f5dd4 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -414,7 +414,13 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object); // // P_SETUP // -extern UINT8 *rejectmatrix; // for fast sight rejection +typedef struct +{ + UINT8* data; + size_t size; +} reject_t; + +extern reject_t rejectmatrix; // for fast sight rejection extern INT32 *blockmaplump; // offsets in blockmap are from here extern INT32 *blockmap; // Big blockmap extern INT32 bmapwidth; diff --git a/src/p_setup.c b/src/p_setup.c index a1b1fb3cb..c8403538a 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -145,7 +145,7 @@ precipmobj_t **precipblocklinks = NULL; // Speeds up enemy AI by skipping detailed LineOf Sight calculation. // Without special effect, this could be used as a PVS lookup as well. // -UINT8 *rejectmatrix = NULL; +reject_t rejectmatrix = {}; // Maintain single and multi player starting spots. INT32 numdmstarts = 0, numcoopstarts = 0, numredctfstarts = 0, numbluectfstarts = 0; @@ -1307,7 +1307,7 @@ static void P_LoadSidedefs(void *data) if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0') break; else - memcpy(process,msd->toptexture,8); + memcpy(process, msd->toptexture, 8); if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0') memcpy(process+strlen(process), msd->midtexture, 8); if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') @@ -1324,7 +1324,7 @@ static void P_LoadSidedefs(void *data) if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0') break; else - memcpy(process,msd->toptexture,8); + memcpy(process,msd->toptexture, 8); if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0') memcpy(process+strlen(process), msd->midtexture, 8); if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') @@ -1787,14 +1787,16 @@ static void P_LoadReject(UINT8 *data, size_t count) { if (!count) // zero length, someone probably used ZDBSP { - rejectmatrix = NULL; + rejectmatrix.data = NULL; CONS_Debug(DBG_SETUP, "P_LoadReject: REJECT lump has size 0, will not be loaded\n"); } else { - rejectmatrix = Z_Malloc(count, PU_LEVEL, NULL); // allocate memory for the reject matrix - memcpy(rejectmatrix, data, count); // copy the data into it + rejectmatrix.data = Z_Malloc(count, PU_LEVEL, NULL); // allocate memory for the reject matrix + memcpy(rejectmatrix.data, data, count); // copy the data into it } + + rejectmatrix.size = count; } static void P_LoadMapBSP(const virtres_t* virt) @@ -1833,7 +1835,10 @@ static void P_LoadMapLUT(const virtres_t* virt) if (virtreject) P_LoadReject(virtreject->data, virtreject->size); else - rejectmatrix = NULL; + { + rejectmatrix.data = NULL; + rejectmatrix.size = 0; + } if (!(virtblockmap && P_LoadRawBlockMap(virtblockmap->data, virtblockmap->size))) P_CreateBlockMap(); diff --git a/src/p_sight.c b/src/p_sight.c index 896da76d6..63b87820e 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -31,8 +31,6 @@ typedef struct { fixed_t bbox[4]; } los_t; -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); @@ -366,18 +364,25 @@ boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast) I_Assert(!P_MobjWasRemoved(t2)); if (!t1->subsector || !t2->subsector - || !t1->subsector->sector || !t2->subsector->sector) + || !t1->subsector->sector || !t2->subsector->sector) + { return false; + } s1 = t1->subsector->sector; s2 = t2->subsector->sector; pnum = (s1-sectors)*numsectors + (s2-sectors); - if (rejectmatrix != NULL) + if (rejectmatrix.data != NULL) { + const size_t shiftnum = pnum>>3; + // Check in REJECT table. - if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected + if (shiftnum < rejectmatrix.size && // check for overflow + (rejectmatrix.data[shiftnum] & (1 << (pnum&7)))) // can't possibly be connected + { return false; + } } // killough 11/98: shortcut for melee situations @@ -385,11 +390,9 @@ boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast) // haleyjd 02/23/06: can't do this if there are polyobjects in the subsec if (!t1->subsector->polyList && t1->subsector == t2->subsector) + { return true; - - // An unobstructed LOS is possible. - // Now look from eyes of t1 to any part of t2. - sightcounts[1]++; + } validcount++; From eef1c55549a034eef15f188986eaf1dd893ea14b Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 13 Jun 2026 01:40:08 +0300 Subject: [PATCH 374/589] Add option for item roulette to use 'local' colors instead of player color --- src/k_hud.c | 36 ++++++++++++++++++++---------------- src/k_hud.h | 1 + src/m_menudefs.c | 31 +++++++++++++++++-------------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index a5f184f7b..e3a7f3ec5 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -109,6 +109,8 @@ consvar_t cv_huditemamount = {"showitemamountnumber", "Vanilla", CV_SAVE, hudite consvar_t cv_fancyroulette = {"animatedroulette", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_darkitembox = {"darkitembox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // itembox gets a dark border with specific items consvar_t cv_multiitemicon = {"multiitemicon", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t roulettecolor_cons_t[] = {{0, "Player"}, {1, "Item"}, {0, NULL}}; +consvar_t cv_roulettecolor = {"roulettecolor", "Player", CV_SAVE, roulettecolor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showlaptimes = {"showlaptimes", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -243,6 +245,8 @@ void K_RegisterKartHudStuff(void) CV_RegisterVar(&cv_multiitemicon); CV_RegisterVar(&cv_huditemamount); + CV_RegisterVar(&cv_roulettecolor); + CV_RegisterVar(&cv_highresportrait); CV_RegisterVar(&cv_nametag); @@ -1514,67 +1518,67 @@ static void K_drawKartItem(void) // Each case is handled in threes, to give three frames of in-game time to see the item on the roulette case 0: // Sneaker localpatch = kp_sneaker[offset]; - //localcolor = SKINCOLOR_RASPBERRY; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_RASPBERRY; break; case 1: // Banana localpatch = kp_banana[offset]; - //localcolor = SKINCOLOR_YELLOW; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_YELLOW; break; case 2: // Orbinaut localpatch = kp_orbinaut[3+offset]; - //localcolor = SKINCOLOR_STEEL; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_STEEL; break; case 3: // Mine localpatch = kp_mine[offset]; - //localcolor = SKINCOLOR_JET; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_JET; break; case 4: // Grow localpatch = kp_grow[offset]; - //localcolor = SKINCOLOR_TEAL; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_TEAL; break; case 5: // Hyudoro localpatch = kp_hyudoro[offset]; - //localcolor = SKINCOLOR_STEEL; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_STEEL; break; case 6: // Rocket Sneaker localpatch = kp_rocketsneaker[offset]; - //localcolor = SKINCOLOR_TANGERINE; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_TANGERINE; break; case 7: // Jawz localpatch = kp_jawz[offset]; - //localcolor = SKINCOLOR_JAWZ; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_JAWZ; break; case 8: // Self-Propelled Bomb localpatch = kp_selfpropelledbomb[offset]; - //localcolor = SKINCOLOR_JET; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_JET; break; case 9: // Shrink localpatch = kp_shrink[offset]; - //localcolor = SKINCOLOR_ORANGE; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_ORANGE; break; case 10: // Invincibility localpatch = localinv; - //localcolor = SKINCOLOR_GREY; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_GREY; break; case 11: // Eggman Monitor localpatch = kp_eggman[offset]; - //localcolor = SKINCOLOR_ROSE; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_ROSE; break; case 12: // Ballhog localpatch = kp_ballhog[offset]; - //localcolor = SKINCOLOR_LILAC; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_LILAC; break; case 13: // Thunder Shield localpatch = kp_thundershield[offset]; - //localcolor = SKINCOLOR_CYAN; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_CYAN; break; /*case 14: // Pogo Spring localpatch = kp_pogospring[offset]; - localcolor = SKINCOLOR_TANGERINE; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_TANGERINE; break; case 15: // Kitchen Sink localpatch = kp_kitchensink[offset]; - localcolor = SKINCOLOR_STEEL; + if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_STEEL; break;*/ default: break; diff --git a/src/k_hud.h b/src/k_hud.h index ca38f43ea..45d5260d6 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -41,6 +41,7 @@ extern consvar_t cv_showlaptimes; extern consvar_t cv_battlespeedo; extern consvar_t cv_multiitemicon; extern consvar_t cv_huditemamount; +extern consvar_t cv_roulettecolor; // for use in timeattack menu extern patch_t *kp_facenum[MAXPLAYERS+1]; diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 3189bbc1a..912ee3dec 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1848,26 +1848,28 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING|IT_CVAR, NULL, "Item Amount Number", &cv_huditemamount, 110}, {IT_STRING|IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 115}, - {IT_STRING|IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 125}, - {IT_STRING|IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 130}, + {IT_STRING|IT_CVAR, NULL, "Item Roulette Color", &cv_roulettecolor, 120}, - {IT_STRING|IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 140}, - {IT_STRING|IT_CVAR, NULL, "Show Finished on Minimap", &cv_showminimapfinished, 145}, - {IT_STRING|IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 150}, - {IT_STRING|IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 155}, - {IT_STRING|IT_CVAR, NULL, "Player Angle Visual", &cv_showminimapangle, 160}, + {IT_STRING|IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 130}, + {IT_STRING|IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 135}, - {IT_STRING|IT_CVAR, NULL, "Music Credits", &cv_songcredits, 170}, - {IT_STRING|IT_CVAR, NULL, "Music Credits on Pause", &cv_pausesongcredits, 175}, + {IT_STRING|IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 145}, + {IT_STRING|IT_CVAR, NULL, "Show Finished on Minimap", &cv_showminimapfinished, 150}, + {IT_STRING|IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 155}, + {IT_STRING|IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 160}, + {IT_STRING|IT_CVAR, NULL, "Player Angle Visual", &cv_showminimapangle, 165}, - {IT_STRING|IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 185}, + {IT_STRING|IT_CVAR, NULL, "Music Credits", &cv_songcredits, 175}, + {IT_STRING|IT_CVAR, NULL, "Music Credits on Pause", &cv_pausesongcredits, 180}, - {IT_STRING|IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 195}, + {IT_STRING|IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 190}, - {IT_STRING|IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 205}, - {IT_STRING|IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 210}, + {IT_STRING|IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 200}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 220}, + {IT_STRING|IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 210}, + {IT_STRING|IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 215}, + + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 225}, }; static const char* OP_SaturnHudTooltips[] = @@ -1888,6 +1890,7 @@ static const char* OP_SaturnHudTooltips[] = "Use extra graphics for multiple sneakers, bananas and jawz.", "Change when the item amount is to be displayed.\nMultiple will always display the number.\nWhen you have multiple of the same Item.\nAlways will always display the number regardless of Item amount.", "Enables an animation while the roulette is active.", + "Changes whether items in roulette have same color as player or an item-specific one.", "Show the big 'LAP' text on a lap change.", "Show the big Cecho Messages.", "Show player names on the minimap.", From 5f559af29c83790cf5637df4312acc9826ff0c6e Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 13 Jun 2026 02:12:23 +0300 Subject: [PATCH 375/589] Add more options to roulettecolor --- src/k_hud.c | 44 +++++++++++++++++++++++++------------------- src/m_menudefs.c | 2 +- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index e3a7f3ec5..a068bb7f8 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -109,8 +109,11 @@ consvar_t cv_huditemamount = {"showitemamountnumber", "Vanilla", CV_SAVE, hudite consvar_t cv_fancyroulette = {"animatedroulette", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_darkitembox = {"darkitembox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // itembox gets a dark border with specific items consvar_t cv_multiitemicon = {"multiitemicon", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t roulettecolor_cons_t[] = {{0, "Player"}, {1, "Item"}, {0, NULL}}; -consvar_t cv_roulettecolor = {"roulettecolor", "Player", CV_SAVE, roulettecolor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +enum { ROULETTECOLOR_NONE = -1, ROULETTECOLOR_HUD, ROULETTECOLOR_PLAYER, ROULETTECOLOR_ITEM }; +static CV_PossibleValue_t roulettecolor_cons_t[] = { + {ROULETTECOLOR_NONE, "None"}, {ROULETTECOLOR_HUD, "Hud"}, {ROULETTECOLOR_PLAYER, "Player"}, {ROULETTECOLOR_ITEM, "Item"}, {0, NULL}}; +consvar_t cv_roulettecolor = {"roulettecolor", "Hud", CV_SAVE, roulettecolor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showlaptimes = {"showlaptimes", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1505,7 +1508,7 @@ static void K_drawKartItem(void) INT32 maxl = 0; // itembar's normal highest value const INT32 barlength = (splitscreen > 1 ? 12 : 26); UINT8 localcolor = SKINCOLOR_NONE; - SINT8 colormode = TC_RAINBOW; + SINT8 colormode = cv_roulettecolor.value == ROULETTECOLOR_NONE ? TC_DEFAULT : TC_RAINBOW; UINT8 *colmap = NULL; UINT8 *colormap = NULL; @@ -1513,72 +1516,75 @@ static void K_drawKartItem(void) { localcolor = K_GetHudColor(); + if (cv_roulettecolor.value == ROULETTECOLOR_PLAYER) + localcolor = stplyr->skincolor; + switch ((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3) { // Each case is handled in threes, to give three frames of in-game time to see the item on the roulette case 0: // Sneaker localpatch = kp_sneaker[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_RASPBERRY; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_RASPBERRY; break; case 1: // Banana localpatch = kp_banana[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_YELLOW; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_YELLOW; break; case 2: // Orbinaut localpatch = kp_orbinaut[3+offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_STEEL; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_STEEL; break; case 3: // Mine localpatch = kp_mine[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_JET; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_JET; break; case 4: // Grow localpatch = kp_grow[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_TEAL; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_TEAL; break; case 5: // Hyudoro localpatch = kp_hyudoro[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_STEEL; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_STEEL; break; case 6: // Rocket Sneaker localpatch = kp_rocketsneaker[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_TANGERINE; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_TANGERINE; break; case 7: // Jawz localpatch = kp_jawz[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_JAWZ; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_JAWZ; break; case 8: // Self-Propelled Bomb localpatch = kp_selfpropelledbomb[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_JET; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_JET; break; case 9: // Shrink localpatch = kp_shrink[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_ORANGE; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_ORANGE; break; case 10: // Invincibility localpatch = localinv; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_GREY; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_GREY; break; case 11: // Eggman Monitor localpatch = kp_eggman[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_ROSE; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_ROSE; break; case 12: // Ballhog localpatch = kp_ballhog[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_LILAC; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_LILAC; break; case 13: // Thunder Shield localpatch = kp_thundershield[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_CYAN; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_CYAN; break; /*case 14: // Pogo Spring localpatch = kp_pogospring[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_TANGERINE; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_TANGERINE; break; case 15: // Kitchen Sink localpatch = kp_kitchensink[offset]; - if (cv_roulettecolor.value == 1) localcolor = SKINCOLOR_STEEL; + if (cv_roulettecolor.value == ROULETTECOLOR_ITEM) localcolor = SKINCOLOR_STEEL; break;*/ default: break; diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 912ee3dec..0f7b5736d 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1890,7 +1890,7 @@ static const char* OP_SaturnHudTooltips[] = "Use extra graphics for multiple sneakers, bananas and jawz.", "Change when the item amount is to be displayed.\nMultiple will always display the number.\nWhen you have multiple of the same Item.\nAlways will always display the number regardless of Item amount.", "Enables an animation while the roulette is active.", - "Changes whether items in roulette have same color as player or an item-specific one.", + "Changes the way items are colorized in roulette.", "Show the big 'LAP' text on a lap change.", "Show the big Cecho Messages.", "Show player names on the minimap.", From b24f6683b77076f64c01e04209de0f3bc5eb24c1 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 13 Jun 2026 02:25:43 +0300 Subject: [PATCH 376/589] Use SKINCOLOR_NONE for ROULETTECOLOR_NONE instead of TC_DEFAULT --- src/k_hud.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index a068bb7f8..335e97340 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1508,16 +1508,16 @@ static void K_drawKartItem(void) INT32 maxl = 0; // itembar's normal highest value const INT32 barlength = (splitscreen > 1 ? 12 : 26); UINT8 localcolor = SKINCOLOR_NONE; - SINT8 colormode = cv_roulettecolor.value == ROULETTECOLOR_NONE ? TC_DEFAULT : TC_RAINBOW; + SINT8 colormode = TC_RAINBOW; UINT8 *colmap = NULL; UINT8 *colormap = NULL; if (stplyr->kartstuff[k_itemroulette]) { - localcolor = K_GetHudColor(); - if (cv_roulettecolor.value == ROULETTECOLOR_PLAYER) localcolor = stplyr->skincolor; + else if (cv_roulettecolor.value != ROULETTECOLOR_NONE) + localcolor = K_GetHudColor(); switch ((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3) { From cc6437285fa3be85ca439d2477b9bd6702ec753a Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jun 2026 12:58:29 +0200 Subject: [PATCH 377/589] =?UTF-8?q?check=20for=20missized=20rejectmatrix?= =?UTF-8?q?=C2=B4s=20on=20load,=20pad=20them=20if=20needed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this is what dsda-doom/prboom does ensures we wont crash from oob reads and makes us print a warning --- src/p_local.h | 8 +------- src/p_setup.c | 29 ++++++++++++++++++----------- src/p_sight.c | 7 ++----- src/y_inter.c | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index eb55f5dd4..383469bcc 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -414,13 +414,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object); // // P_SETUP // -typedef struct -{ - UINT8* data; - size_t size; -} reject_t; - -extern reject_t rejectmatrix; // for fast sight rejection +extern UINT8 *rejectmatrix; // for fast sight rejection extern INT32 *blockmaplump; // offsets in blockmap are from here extern INT32 *blockmap; // Big blockmap extern INT32 bmapwidth; diff --git a/src/p_setup.c b/src/p_setup.c index c8403538a..e8e654c3c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -145,7 +145,7 @@ precipmobj_t **precipblocklinks = NULL; // Speeds up enemy AI by skipping detailed LineOf Sight calculation. // Without special effect, this could be used as a PVS lookup as well. // -reject_t rejectmatrix = {}; +UINT8 *rejectmatrix = NULL; // Maintain single and multi player starting spots. INT32 numdmstarts = 0, numcoopstarts = 0, numredctfstarts = 0, numbluectfstarts = 0; @@ -1780,23 +1780,29 @@ static void P_GroupLines(void) } } - // PK3 version // -- Monster Iestyn 09/01/18 -static void P_LoadReject(UINT8 *data, size_t count) +static void P_LoadReject(UINT8 *data, size_t rejectsize) { - if (!count) // zero length, someone probably used ZDBSP + const size_t neededsize = (numsectors * numsectors + 7) >> 3; + size_t allocsize = rejectsize; + + if (!rejectsize) // zero length, someone probably used ZDBSP { - rejectmatrix.data = NULL; + rejectmatrix = NULL; CONS_Debug(DBG_SETUP, "P_LoadReject: REJECT lump has size 0, will not be loaded\n"); } else { - rejectmatrix.data = Z_Malloc(count, PU_LEVEL, NULL); // allocate memory for the reject matrix - memcpy(rejectmatrix.data, data, count); // copy the data into it - } + if (rejectsize < neededsize) + { + CONS_Alert(CONS_WARNING, "REJECT is %lu byte%s too small. REJECT might be invalid and might crash vanilla clients!\n", (neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); + allocsize = neededsize; + } - rejectmatrix.size = count; + rejectmatrix = Z_Calloc(allocsize, PU_LEVEL, NULL); // allocate memory for the reject matrix + memcpy(rejectmatrix, data, rejectsize); // copy the data into it + } } static void P_LoadMapBSP(const virtres_t* virt) @@ -1833,11 +1839,12 @@ static void P_LoadMapLUT(const virtres_t* virt) // Lookup tables if (virtreject) + { P_LoadReject(virtreject->data, virtreject->size); + } else { - rejectmatrix.data = NULL; - rejectmatrix.size = 0; + rejectmatrix = NULL; } if (!(virtblockmap && P_LoadRawBlockMap(virtblockmap->data, virtblockmap->size))) diff --git a/src/p_sight.c b/src/p_sight.c index 63b87820e..7bde2d737 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -373,13 +373,10 @@ boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast) s2 = t2->subsector->sector; pnum = (s1-sectors)*numsectors + (s2-sectors); - if (rejectmatrix.data != NULL) + if (rejectmatrix != NULL) { - const size_t shiftnum = pnum>>3; - // Check in REJECT table. - if (shiftnum < rejectmatrix.size && // check for overflow - (rejectmatrix.data[shiftnum] & (1 << (pnum&7)))) // can't possibly be connected + if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected { return false; } diff --git a/src/y_inter.c b/src/y_inter.c index 19b696b0e..a92392f39 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -586,7 +586,7 @@ void Y_Ticker(void) if (data.rankingsmode && intertic > sorttic+16+(2*TICRATE)) { - INT32 q=0,r=0; + INT32 q = 0, r = 0; boolean kaching = true; for (q = 0; q < data.numplayers; q++) From 2c1bb6c268cbd754d425b9eb3b2e44658692ff05 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jun 2026 13:06:37 +0200 Subject: [PATCH 378/589] smol optimize fof checks in P_CheckSight check if fof is solid before height comparisons, also split initial height comparisons to save on some height checks in some cases --- src/p_sight.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index 7bde2d737..73c98f8f3 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -432,21 +432,30 @@ boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast) continue; } - topz1 = P_GetFFloorTopZAt (rover, t1->x, t1->y); - topz2 = P_GetFFloorTopZAt (rover, t2->x, t2->y); - bottomz1 = P_GetFFloorBottomZAt(rover, t1->x, t1->y); - bottomz2 = P_GetFFloorBottomZAt(rover, t2->x, t2->y); + if (rover->flags & FF_SOLID) + { + continue; // shortcut since neither mobj can be inside the 3dfloor + } // Check for blocking floors here. - if ((los.sightzstart < bottomz1 && t2->z >= topz2) - || (los.sightzstart >= topz1 && t2->z + t2->height < bottomz2)) + + topz2 = P_GetFFloorTopZAt (rover, t2->x, t2->y); + bottomz1 = P_GetFFloorBottomZAt(rover, t1->x, t1->y); + + if (los.sightzstart < bottomz1 && t2->z >= topz2) { // no way to see through that return false; } - if (rover->flags & FF_SOLID) - continue; // shortcut since neither mobj can be inside the 3dfloor + topz1 = P_GetFFloorTopZAt (rover, t1->x, t1->y); + bottomz2 = P_GetFFloorBottomZAt(rover, t2->x, t2->y); + + if (los.sightzstart >= topz1 && t2->z + t2->height < bottomz2) + { + // no way to see through that + return false; + } if (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES)) { From 14aaba7a879cfb7615af0d423f4bfa2fd4992151 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jun 2026 13:20:43 +0200 Subject: [PATCH 379/589] make reject matrix print an error instead of warning better on 2nd thought as this may crash vanilla clients that use nametags --- src/p_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index e8e654c3c..f0b931d27 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1796,7 +1796,7 @@ static void P_LoadReject(UINT8 *data, size_t rejectsize) { if (rejectsize < neededsize) { - CONS_Alert(CONS_WARNING, "REJECT is %lu byte%s too small. REJECT might be invalid and might crash vanilla clients!\n", (neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); + CONS_Alert(CONS_ERROR, "REJECT is %lu byte%s too small. REJECT might be invalid and might crash vanilla clients!\n", (neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); allocsize = neededsize; } From 8129b89034b84819ef270560526b9f85924ed7cf Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jun 2026 13:34:43 +0200 Subject: [PATCH 380/589] port P_VerifyBlockMap from dsda-doom to check for blockmap issues that might cause crashes --- src/p_setup.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index f0b931d27..95d3144b3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1625,6 +1625,80 @@ static void P_CreateBlockMap(void) } } +// +// P_VerifyBlockMap +// +// haleyjd 03/04/10: do verification on validity of blockmap. +// +static boolean P_VerifyBlockMap(INT32 count) +{ + // FIXME: should any of this shit be unsinged? + INT32 x, y; + INT32 *maxoffs = blockmaplump + count; + + //skipblstart = true; + + for (y = 0; y < bmapheight; y++) + { + for (x = 0; x < bmapwidth; x++) + { + INT32 offset; + INT32 *list, *tmplist; + INT32 *blockoffset; + + offset = y * bmapwidth + x; + blockoffset = blockmaplump + offset + 4; + + // check that block offset is in bounds + if (blockoffset >= maxoffs) + { + CONS_Alert(CONS_ERROR, "P_VerifyBlockMap: block offset overflow\n"); + return false; + } + + offset = *blockoffset; + + // check that list offset is in bounds + if (offset < 4 || offset >= count) + { + CONS_Alert(CONS_ERROR, "P_VerifyBlockMap: list offset overflow\n"); + return false; + } + + list = blockmaplump + offset; + + //if (*list != 0) + //skipblstart = false; + + // scan forward for a -1 terminator before maxoffs + for (tmplist = list; ; tmplist++) + { + // we have overflowed the lump? + if (tmplist >= maxoffs) + { + CONS_Alert(CONS_ERROR, "P_VerifyBlockMap: open blocklist\n"); + return false; + } + + if (*tmplist == -1) // found -1 + break; + } + + // scan the list for out-of-range linedef indicies in list + for (tmplist = list; *tmplist != -1; tmplist++) + { + if (*tmplist < 0 || *tmplist >= (INT32)numlines) + { + CONS_Alert(CONS_ERROR, "P_VerifyBlockMap: index >= numlines\n"); + return false; + } + } + } + } + + return true; +} + // Split from P_LoadBlockMap for convenience // -- Monster Iestyn 08/01/18 static void P_ReadBlockMapLump(INT16 *wadblockmaplump, size_t count) @@ -1669,6 +1743,14 @@ static boolean P_LoadRawBlockMap(UINT8 *data, size_t count) bmapwidth = blockmaplump[2]; bmapheight = blockmaplump[3]; + // haleyjd 03/04/10: check for blockmap problems + // http://www.doomworld.com/idgames/index.php?id=12935 + if (!P_VerifyBlockMap(count)) + { + CONS_Alert(CONS_ERROR, "P_LoadBlockMap: erroneous BLOCKMAP lump may cause crashes.\n"); + //CONS_Alert(CONS_NOTICE, "P_LoadBlockMap: use \"-blockmap\" command line switch for rebuilding\n"); + } + // clear out mobj chains count = sizeof (*blocklinks)* bmapwidth*bmapheight; blocklinks = Z_Calloc(count, PU_LEVEL, NULL); From ab0d071d35e53af3380b73392ea899fc1350a5b0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jun 2026 13:41:00 +0200 Subject: [PATCH 381/589] use sizeu1 instead of %lu windoze....... --- src/p_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index 95d3144b3..4423b7d26 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1878,7 +1878,7 @@ static void P_LoadReject(UINT8 *data, size_t rejectsize) { if (rejectsize < neededsize) { - CONS_Alert(CONS_ERROR, "REJECT is %lu byte%s too small. REJECT might be invalid and might crash vanilla clients!\n", (neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); + CONS_Alert(CONS_ERROR, "REJECT is %s byte%s too small. REJECT might be invalid and might crash vanilla clients!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); allocsize = neededsize; } From e1061ab4b4db007518a3fabcf19cbdb4232251aa Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 13 Jun 2026 15:11:41 +0200 Subject: [PATCH 382/589] add PARANOIA cases for reject and blockmap stuff also see comment --- src/p_setup.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 4423b7d26..0be23b262 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1740,15 +1740,23 @@ static boolean P_LoadRawBlockMap(UINT8 *data, size_t count) bmaporgx = blockmaplump[0]< Date: Mon, 15 Jun 2026 14:48:21 +0200 Subject: [PATCH 383/589] handle interrupt signals during CONS_Error also move stuff into smol inline function --- src/console.c | 2 ++ src/d_clisrv.c | 5 +---- src/d_main.c | 5 +---- src/f_wipe.c | 5 +---- src/i_system.h | 5 +++++ 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/console.c b/src/console.c index d02f68bb6..8ca29f901 100644 --- a/src/console.c +++ b/src/console.c @@ -1437,6 +1437,8 @@ void CONS_Error(const char *msg) // dirty quick hack, but for the good cause while (I_GetKey() != KEY_ENTER) { + I_HandleInterrupt(); + // Sleep so we don't take too much of cpu usage I_Sleep(1.f/TICRATE*1000); diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d5f10daa3..7113f6ca9 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2858,10 +2858,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic { INT32 key; - if (I_Interrupted()) - { - I_Quit(); - } + I_HandleInterrupt(); I_OsPolling(); diff --git a/src/d_main.c b/src/d_main.c index c9df6e441..be19da2de 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -726,10 +726,7 @@ void D_SRB2Loop(void) enterprecise = I_GetPreciseTime(); - if (I_Interrupted()) - { - I_Quit(); - } + I_HandleInterrupt(); memset(&g_dc, 0, sizeof(g_dc)); Z_Frame_Reset(); diff --git a/src/f_wipe.c b/src/f_wipe.c index 18100da4c..32b385c9e 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -361,10 +361,7 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu) // on for fade-to-black for (;;) { - if (I_Interrupted()) - { - I_Quit(); - } + I_HandleInterrupt(); // get fademask first so we can tell if it exists or not fmask = F_GetFadeMask(wipetype, wipeframe++); diff --git a/src/i_system.h b/src/i_system.h index 9457e9c6d..9e981cf0f 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -203,6 +203,11 @@ void I_ShutdownSystem(void); /** \brief To check if a Interrupt or Terminate Signal was fired */ boolean I_Interrupted(void); +static inline void I_HandleInterrupt(void) +{ + if (I_Interrupted()) + I_Quit(); +} /** \brief The I_GetDiskFreeSpace function From 96a29abc62e53f9cdd455fae517ad1743e9ca0df Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 15 Jun 2026 14:53:20 +0200 Subject: [PATCH 384/589] move this back might change behavior of this, which may desynch in rare cases --- src/p_sight.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/p_sight.c b/src/p_sight.c index 73c98f8f3..3eb4788b0 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -432,11 +432,6 @@ boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast) continue; } - if (rover->flags & FF_SOLID) - { - continue; // shortcut since neither mobj can be inside the 3dfloor - } - // Check for blocking floors here. topz2 = P_GetFFloorTopZAt (rover, t2->x, t2->y); @@ -457,6 +452,11 @@ boolean P_CheckSight2(mobj_t *t1, mobj_t *t2, boolean fast) return false; } + if (rover->flags & FF_SOLID) + { + continue; // shortcut since neither mobj can be inside the 3dfloor + } + if (rover->flags & FF_BOTHPLANES || !(rover->flags & FF_INVERTPLANES)) { if (los.sightzstart >= topz1 && t2->z + t2->height < topz2) From 51d9aa6197d04efe8ed5764a1b05b1f9f8f738b6 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 16 Jun 2026 12:31:53 +0200 Subject: [PATCH 385/589] add credit to bayer dither shader sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit completely forgot about this (sry!) the original implementation was mostly based on hughsk´s 8x8 bayer shader while the current is mostly adapted from the libretro 4x4 bayer shader --- src/hardware/hw_shaders.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index ff8b229de..baedebf64 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -76,6 +76,11 @@ // // Include GLSL_FLOOR_FUDGES or GLSL_WALL_FUDGES or define the fudges in shaders that use this macro. + +// dither shader based on +// https://github.com/hughsk/glsl-dither/blob/master/8x8.glsl +// https://github.com/libretro/glsl-shaders/blob/master/dithering/shaders/bayer_4x4.glsl +// adapted and messed about to work with srb2 and scale per resolution #define GLSL_DOOM_COLORMAP_DITHER \ "float baseValue = max(startmap * STARTMAP_FUDGE - scale * 0.5 * SCALE_FUDGE, cap);\n" \ "float patscale = min(scr_resolution.x / 1280.0, scr_resolution.y / 720.0);\n" \ From e94fecf56d2e6b67aaddaa125628c9a73cf310ea Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 16 Jun 2026 19:07:54 +0200 Subject: [PATCH 386/589] cleanup even more style issues also should fix R_InitSprites printing the wrong spritename in some cases --- src/dehacked.c | 137 +++++++++++++++++++++++++-------------- src/g_demo.c | 20 +++--- src/hardware/hw_portal.c | 12 ++-- src/r_patch.cpp | 2 +- src/r_skins.c | 2 +- src/r_things.cpp | 64 ++++++++++-------- 6 files changed, 142 insertions(+), 95 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 323261243..cfac59656 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -337,12 +337,14 @@ static void readfreeslots(MYFILE *f) { if (used_spr[(i-SPR_FIRSTFREESLOT)/8] & (1<<(i%8))) { - if (!sprnames[i][4] && memcmp(sprnames[i],word,4)==0) + if (!sprnames[i][4] && memcmp(sprnames[i], word, 4) == 0) sprnames[i][4] = (char)f->wad; + continue; // Already allocated, next. } + // Found a free slot! - strncpy(sprnames[i],word,4); + strncpy(sprnames[i], word, 4); //sprnames[i][4] = 0; CONS_Printf("Sprite SPR_%s allocated.\n",word); @@ -351,22 +353,26 @@ static void readfreeslots(MYFILE *f) used_spr[(i-SPR_FIRSTFREESLOT)/8] |= 1<<(i%8); // Okay, this sprite slot has been named now. break; } + if (i > SPR_LASTFREESLOT) I_Error("Out of Sprite Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); } else if (fastcmp(type, "S")) { for (i = 0; i < NUMSTATEFREESLOTS; i++) - if (!FREE_STATES[i]) { - CONS_Printf("State S_%s allocated.\n",word); + { + if (!FREE_STATES[i]) + { + CONS_Printf("State S_%s allocated.\n", word); LUA_InvalidateMathlibCache(va("S_%s", word)); FREE_STATES[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_STATES[i],word); + strcpy(FREE_STATES[i], word); freeslotusage[0][0]++; break; } + } if (i == NUMSTATEFREESLOTS) I_Error("Out of State Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); @@ -374,16 +380,19 @@ static void readfreeslots(MYFILE *f) else if (fastcmp(type, "MT")) { for (i = 0; i < NUMMOBJFREESLOTS; i++) - if (!FREE_MOBJS[i]) { - CONS_Printf("MobjType MT_%s allocated.\n",word); + { + if (!FREE_MOBJS[i]) + { + CONS_Printf("MobjType MT_%s allocated.\n", word); LUA_InvalidateMathlibCache(va("MT_%s", word)); FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_MOBJS[i],word); + strcpy(FREE_MOBJS[i], word); freeslotusage[1][0]++; break; } + } if (i == NUMMOBJFREESLOTS) I_Error("Out of Mobj Freeslots while allocating \"%s\"\nLoad less addons to fix this.", word); @@ -426,8 +435,11 @@ static void readthing(MYFILE *f, INT32 num) strupr(word2); else break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + + const size_t word2len = strlen(word2); + + if (word2[word2len-1] == '\n') + word2[word2len-1] = '\0'; if (fastcmp(word, "MAPTHINGNUM") || fastcmp(word, "DOOMEDNUM")) { @@ -734,14 +746,20 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) { UINT16 tol = 0; tmp = strtok(word2,","); + do { for (i = 0; TYPEOFLEVEL[i].name; i++) + { if (fastcmp(tmp, TYPEOFLEVEL[i].name)) break; + } + if (!TYPEOFLEVEL[i].name) deh_warning("Level header %d: unknown typeoflevel flag %s\n", num, tmp); + tol |= TYPEOFLEVEL[i].flag; } while((tmp = strtok(NULL,",")) != NULL); + mapheaderinfo[num-1]->typeoflevel = tol; } } @@ -1037,8 +1055,11 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) else break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + const size_t word2len = strlen(word2); + + if (word2[word2len-1] == '\n') + word2[word2len-1] = '\0'; + i = atoi(word2); usi = (UINT16)i; @@ -1088,12 +1109,14 @@ static void readcutscenescene(MYFILE *f, INT32 num, INT32 scenenum) else if (fastcmp(word, "MUSICSLOT")) { i = get_mus(word2, true); + if (i && i <= 1035) snprintf(cutscenes[num]->scene[scenenum].musswitch, 7, "%sM", G_BuildMapName(i)); else if (i && i <= 1050) strncpy(cutscenes[num]->scene[scenenum].musswitch, compat_special_music_slots[i - 1036], 7); else cutscenes[num]->scene[scenenum].musswitch[0] = 0; // becomes empty string + cutscenes[num]->scene[scenenum].musswitch[6] = 0; } #endif @@ -1498,8 +1521,11 @@ static void readframe(MYFILE *f, INT32 num) strupr(word2); else break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; + + const size_t word2len = strlen(word2); + + if (word2[word2len-1] == '\n') + word2[word2len-1] = '\0'; if (fastcmp(word1, "SPRITENUMBER") || fastcmp(word1, "SPRITENAME")) { @@ -1828,13 +1854,19 @@ static void readextraemblemdata(MYFILE *f, INT32 num) value = atoi(word2); // used for numerical settings if (fastcmp(word, "NAME")) + { deh_strlcpy(extraemblems[num-1].name, word2, - sizeof (extraemblems[num-1].name), va("Extra emblem %d: name", num)); + sizeof (extraemblems[num-1].name), va("Extra emblem %d: name", num)); + } else if (fastcmp(word, "OBJECTIVE")) + { deh_strlcpy(extraemblems[num-1].description, word2, - sizeof (extraemblems[num-1].description), va("Extra emblem %d: objective", num)); + sizeof (extraemblems[num-1].description), va("Extra emblem %d: objective", num)); + } else if (fastcmp(word, "CONDITIONSET")) + { extraemblems[num-1].conditionset = (UINT8)value; + } else if (fastcmp(word, "SPRITE")) { if (word2[0] >= 'A' && word2[0] <= 'Z') @@ -1906,11 +1938,15 @@ static void readunlockable(MYFILE *f, INT32 num) i = atoi(word2); // used for numerical settings if (fastcmp(word, "NAME")) + { deh_strlcpy(unlockables[num].name, word2, - sizeof (unlockables[num].name), va("Unlockable %d: name", num)); + sizeof (unlockables[num].name), va("Unlockable %d: name", num)); + } else if (fastcmp(word, "OBJECTIVE")) + { deh_strlcpy(unlockables[num].objective, word2, - sizeof (unlockables[num].objective), va("Unlockable %d: objective", num)); + sizeof (unlockables[num].objective), va("Unlockable %d: objective", num)); + } else if (fastcmp(word, "SHOWCONDITIONSET")) unlockables[num].showconditionset = (UINT8)i; else if (fastcmp(word, "CONDITIONSET")) @@ -8102,7 +8138,7 @@ static mobjtype_t get_mobjtype(const char *word) if (*word >= '0' && *word <= '9') return atoi(word); - if (fastncmp("MT_",word,3)) + if (fastncmp("MT_", word, 3)) word += 3; // take off the MT_ for (i = 0; i < NUMMOBJFREESLOTS; i++) @@ -8128,7 +8164,7 @@ static statenum_t get_state(const char *word) if (*word >= '0' && *word <= '9') return atoi(word); - if (fastncmp("S_",word,2)) + if (fastncmp("S_", word, 2)) word += 2; // take off the S_ for (i = 0; i < NUMSTATEFREESLOTS; i++) @@ -8155,11 +8191,11 @@ static spritenum_t get_sprite(const char *word) if (*word >= '0' && *word <= '9') return atoi(word); - if (fastncmp("SPR_",word,4)) + if (fastncmp("SPR_", word, 4)) word += 4; // take off the SPR_ for (i = 0; i < NUMSPRITES; i++) - if (!sprnames[i][4] && memcmp(word,sprnames[i],4) == 0) + if (!sprnames[i][4] && memcmp(word, sprnames[i], 4) == 0) return i; deh_warning("Couldn't find sprite named 'SPR_%s'",word); @@ -8200,14 +8236,15 @@ static UINT16 get_mus(const char *word, UINT8 dehacked_mode) if (!word[2] && toupper(word[0]) >= 'A' && toupper(word[0]) <= 'Z') return (UINT16)M_MapNumber(word[0], word[1]); - if (fastncmp("MUS_",word,4)) + if (fastncmp("MUS_", word, 4)) word += 4; // take off the MUS_ - else if (fastncmp("O_",word,2) || fastncmp("D_",word,2)) + else if (fastncmp("O_", word, 2) || fastncmp("D_", word, 2)) word += 2; // take off the O_ or D_ strncpy(lumptmp, word, 4); lumptmp[3] = 0; - if (fasticmp("MAP",lumptmp)) + + if (fasticmp("MAP", lumptmp)) { word += 3; if (toupper(word[0]) >= 'A' && toupper(word[0]) <= 'Z') @@ -8320,7 +8357,7 @@ static inline int lib_freeslot(lua_State *L) { sfxenum_t sfx; strlwr(word); - CONS_Printf("Sound sfx_%s allocated.\n",word); + CONS_Printf("Sound sfx_%s allocated.\n", word); sfx = S_AddSoundFx(word, false, 0, false); if (sfx != sfx_None) @@ -8344,8 +8381,10 @@ static inline int lib_freeslot(lua_State *L) { if (!sprnames[j][4] && memcmp(sprnames[j], word, 4) == 0) sprnames[j][4] = wad; + continue; // Already allocated, next. } + // Found a free slot! CONS_Printf("Sprite SPR_%s allocated.\n",word); @@ -8353,7 +8392,7 @@ static inline int lib_freeslot(lua_State *L) lua_pushfstring(L, "SPR_%s", word); lua_call(L, 1, 0); - strncpy(sprnames[j],word,4); + strncpy(sprnames[j], word, 4); //sprnames[j][4] = 0; used_spr[(j-SPR_FIRSTFREESLOT)/8] |= 1<<(j%8); // Okay, this sprite slot has been named now. lua_pushinteger(L, j); @@ -8371,7 +8410,7 @@ static inline int lib_freeslot(lua_State *L) { if (!FREE_STATES[i]) { - CONS_Printf("State S_%s allocated.\n",word); + CONS_Printf("State S_%s allocated.\n", word); lua_pushcfunction(L, lua_glib_invalidate_cache); lua_pushfstring(L, "S_%s", word); @@ -8396,14 +8435,14 @@ static inline int lib_freeslot(lua_State *L) { if (!FREE_MOBJS[i]) { - CONS_Printf("MobjType MT_%s allocated.\n",word); + CONS_Printf("MobjType MT_%s allocated.\n", word); lua_pushcfunction(L, lua_glib_invalidate_cache); lua_pushfstring(L, "MT_%s", word); lua_call(L, 1, 0); FREE_MOBJS[i] = Z_Malloc(strlen(word)+1, PU_STATIC, NULL); - strcpy(FREE_MOBJS[i],word); + strcpy(FREE_MOBJS[i], word); freeslotusage[1][0]++; lua_pushinteger(L, i); r++; @@ -8590,6 +8629,7 @@ static int lua_enumlib_mobjtype_get(lua_State *L) { if (!FREE_MOBJS[i]) break; + if (fastcmp(s+3, FREE_MOBJS[i])) { lua_pushinteger(L, MT_FIRSTFREESLOT+i); @@ -8678,30 +8718,29 @@ static int lua_enumlib_sfx_get_ds(lua_State *L) } #ifdef MUSICSLOT_COMPATIBILITY +static int lua_enumlib_mus_get(lua_State *L) +{ + const char *name = strchr(lua_tostring(L, 1), '_') + 1; + int mus = get_mus(name, false); - static int lua_enumlib_mus_get(lua_State *L) - { - const char *name = strchr(lua_tostring(L, 1), '_') + 1; - int mus = get_mus(name, false); + if (mus == 0) + return 0; - if (mus == 0) - return 0; + lua_pushinteger(L, mus); + return 1; +} - lua_pushinteger(L, mus); - return 1; - } +static int lua_enumlib_mus_get_mathlib(lua_State *L) +{ + const char *name = strchr(lua_tostring(L, 1), '_') + 1; + int mus = get_mus(name, false); - static int lua_enumlib_mus_get_mathlib(lua_State *L) - { - const char *name = strchr(lua_tostring(L, 1), '_') + 1; - int mus = get_mus(name, false); + if (mus == 0) + return luaL_error(L, "music '%s' could not be found.\n", lua_tostring(L, 1)); - if (mus == 0) - return luaL_error(L, "music '%s' could not be found.\n", lua_tostring(L, 1)); - - lua_pushinteger(L, mus); - return 1; - } + lua_pushinteger(L, mus); + return 1; +} #endif static int lua_enumlib_power_get(lua_State *L) diff --git a/src/g_demo.c b/src/g_demo.c index 850e08048..de6a1bb5d 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -515,49 +515,49 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) if (cmd->forwardmove != oldcmd[playernum].forwardmove) { - WRITEUINT8(demobuf.p,cmd->forwardmove); + WRITEUINT8(demobuf.p, cmd->forwardmove); oldcmd[playernum].forwardmove = cmd->forwardmove; ziptic |= ZT_FWD; } if (cmd->sidemove != oldcmd[playernum].sidemove) { - WRITEUINT8(demobuf.p,cmd->sidemove); + WRITEUINT8(demobuf.p, cmd->sidemove); oldcmd[playernum].sidemove = cmd->sidemove; ziptic |= ZT_SIDE; } if (cmd->angleturn != oldcmd[playernum].angleturn) { - WRITEINT16(demobuf.p,cmd->angleturn); + WRITEINT16(demobuf.p, cmd->angleturn); oldcmd[playernum].angleturn = cmd->angleturn; ziptic |= ZT_ANGLE; } if (cmd->buttons != oldcmd[playernum].buttons) { - WRITEUINT16(demobuf.p,cmd->buttons); + WRITEUINT16(demobuf.p, cmd->buttons); oldcmd[playernum].buttons = cmd->buttons; ziptic |= ZT_BUTTONS; } if (cmd->aiming != oldcmd[playernum].aiming) { - WRITEINT16(demobuf.p,cmd->aiming); + WRITEINT16(demobuf.p, cmd->aiming); oldcmd[playernum].aiming = cmd->aiming; ziptic |= ZT_AIMING; } if (cmd->driftturn != oldcmd[playernum].driftturn) { - WRITEINT16(demobuf.p,cmd->driftturn); + WRITEINT16(demobuf.p, cmd->driftturn); oldcmd[playernum].driftturn = cmd->driftturn; ziptic |= ZT_DRIFT; } if (cmd->latency != oldcmd[playernum].latency) { - WRITEUINT8(demobuf.p,cmd->latency); + WRITEUINT8(demobuf.p, cmd->latency); oldcmd[playernum].latency = cmd->latency; ziptic |= ZT_LATENCY; } @@ -726,8 +726,8 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) // GZT_XYZ is only useful if you've moved 256 FRACUNITS or more in a single tic. if (abs(ghost->x-oldghost[playernum].x) > MAXMOM - || abs(ghost->y-oldghost[playernum].y) > MAXMOM - || abs(ghost->z-oldghost[playernum].z) > MAXMOM + || abs(ghost->y-oldghost[playernum].y) > MAXMOM + || abs(ghost->z-oldghost[playernum].z) > MAXMOM || ((UINT8)(leveltime & 255) > 0 && (UINT8)(leveltime & 255) <= (UINT8)cv_netdemosyncquality.value)) // Hack to enable slightly nicer resyncing { oldghost[playernum].x = ghost->x; @@ -1375,7 +1375,7 @@ fadeghost: UINT16 i, health; UINT16 count = READUINT16(g->p); //UINT32 type; - fixed_t x,y,z; + fixed_t x, y, z; angle_t angle; mobj_t *poof; diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index 117d59725..c64eedad0 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -80,8 +80,8 @@ void HWR_Portal_Add2Lines(const INT32 line1, const INT32 line2, seg_t *seg) gl_portal_t *portal = HWR_Portal_Add(seg); // Offset the portal view by the linedef centers - line_t* start = &lines[line1]; - line_t* dest = &lines[line2]; + line_t* start = &lines[line1]; + line_t* dest = &lines[line2]; angle_t dangle = R_PointToAngle2(0, 0, dest->dx, dest->dy) - R_PointToAngle2(start->dx, start->dy, 0, 0); @@ -99,7 +99,7 @@ void HWR_Portal_Add2Lines(const INT32 line1, const INT32 line2, seg_t *seg) dest_c.y = dest->v1->y/2 + dest->v2->y/2; disttopoint = R_PointToDist2(start_c.x, start_c.y, viewx, viewy); - angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy); + angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy); angtopoint += dangle; portal->viewx = dest_c.x + FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); @@ -220,9 +220,9 @@ boolean HWR_PortalCheckBBox(const fixed_t *bspcoord) if (!portalclipline) return true; - if (HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXTOP]) || - HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]) || - HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXTOP]) || + if (HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXTOP]) || + HWR_PortalCheckPointSide(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]) || + HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXTOP]) || HWR_PortalCheckPointSide(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM])) { return true; diff --git a/src/r_patch.cpp b/src/r_patch.cpp index f578a8f32..c7c49b827 100644 --- a/src/r_patch.cpp +++ b/src/r_patch.cpp @@ -289,7 +289,7 @@ void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum) sprinfoLumpLength = W_LumpLengthPwad(wadNum, lumpNum); sprinfoText = (char *)Z_Malloc((sprinfoLumpLength+1)*sizeof(char),PU_STATIC,NULL); // Now move the contents of the lump into this new location. - memmove(sprinfoText,sprinfoLump,sprinfoLumpLength); + memmove(sprinfoText, sprinfoLump, sprinfoLumpLength); // Make damn well sure the last character in our new memory location is \0. sprinfoText[sprinfoLumpLength] = '\0'; // Finally, free up the memory from the first data load, because we really diff --git a/src/r_skins.c b/src/r_skins.c index 9ab6e0fbf..b45dd0d58 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -712,7 +712,7 @@ void R_AddSkins(UINT16 wadnum, boolean local) // skip to end of this skin's frames lastlump = lump; - while (W_CheckNameForNumPwad(wadnum, lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump), csprname,4)==0) + while (W_CheckNameForNumPwad(wadnum, lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump), csprname, 4) == 0) lastlump++; // allocate (or replace) sprite frames, and set spritedef diff --git a/src/r_things.cpp b/src/r_things.cpp index 875cb7290..b4707db6f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -182,15 +182,14 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch UINT8 rightfactor = ((rotation == ROT_R) ? 4 : 0); // the lump should be used for half of all rotations - if (sprtemp[frame].rotate == SRF_SINGLE) + if (sprtemp[frame].rotate == SRF_NONE) + sprtemp[frame].rotate = SRF_SINGLE; + else if (sprtemp[frame].rotate == SRF_SINGLE) CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has L/R rotations and a rot = 0 lump\n", spritename, cn); else if (sprtemp[frame].rotate == SRF_3D) CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has both L/R and 1-8 rotations\n", spritename, cn); // Let's not complain about multiple L/R rotations. It's not worth the effort. - if (sprtemp[frame].rotate == SRF_NONE) - sprtemp[frame].rotate = SRF_SINGLE; - sprtemp[frame].rotate |= ((rotation == ROT_R) ? SRF_RIGHT : SRF_LEFT); if (sprtemp[frame].rotate == (SRF_3D|SRF_2D)) @@ -233,6 +232,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch // when using sprites in pwad : the lumppat points the new graphics sprtemp[frame].lumppat[rotation] = lumppat; sprtemp[frame].lumpid[rotation] = lumpid; + if (flipped) sprtemp[frame].flip |= (1<numframes) // (then spriteframes is not null) @@ -289,7 +291,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 if (frame >= 64 || !(R_ValidSpriteAngle(rotation))) // Give an actual NAME error -_-... { - CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum,l)); + CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum, l)); continue; } @@ -315,6 +317,15 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 { frame = R_Char2Frame(lumpinfo[l].name[6]); rotation = (UINT8)(lumpinfo[l].name[7] - '0'); + + /* + if (frame >= 64 || !(R_ValidSpriteAngle(rotation))) // Give an actual NAME error -_-... + { + CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum, l)); + continue; + } + */ + R_InstallSpriteLump(wadnum, l, numspritelumps, frame, rotation, 1); } @@ -363,30 +374,32 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 switch (sprtemp[frame].rotate) { case SRF_NONE: - // no rotations were found for that frame at all - I_Error("R_AddSingleSpriteDef: No patches found for %.4s frame %c", sprname, R_Frame2Char(frame)); - break; + // no rotations were found for that frame at all + I_Error("R_AddSingleSpriteDef: No patches found for %.4s frame %c", sprname, R_Frame2Char(frame)); + break; case SRF_SINGLE: - // only the first rotation is needed - break; + // only the first rotation is needed + break; case SRF_2D: // both Left and Right rotations // we test to see whether the left and right slots are present if ((sprtemp[frame].lumppat[2] == LUMPERROR) || (sprtemp[frame].lumppat[6] == LUMPERROR)) I_Error("R_AddSingleSpriteDef: Sprite %s frame %c is missing rotations", sprname, R_Frame2Char(frame)); - break; + break; default: - // must have all 8 frames - for (rotation = 0; rotation < 8; rotation++) - // we test the patch lump, or the id lump whatever - // if it was not loaded the two are LUMPERROR - if (sprtemp[frame].lumppat[rotation] == LUMPERROR) - I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations", - sprname, R_Frame2Char(frame)); - break; + // must have all 8 frames + for (rotation = 0; rotation < 8; rotation++) + { + // we test the patch lump, or the id lump whatever + // if it was not loaded the two are LUMPERROR + if (sprtemp[frame].lumppat[rotation] == LUMPERROR) + I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations", + sprname, R_Frame2Char(frame)); + } + break; } } @@ -394,7 +407,6 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 if (spritedef->numframes && // has been allocated spritedef->numframes < maxframe) // more frames are defined ? { - Z_Free(spritedef->spriteframes); spritedef->spriteframes = NULL; } @@ -451,12 +463,10 @@ void R_AddSpriteDefs(UINT16 wadnum) // for (i = 0; i < numsprites; i++) { - spritename = sprnames[i]; - - if (spritename[4] && wadnum >= (UINT16)spritename[4]) + if (sprnames[i][4] && wadnum >= (UINT16)sprnames[i][4]) continue; - if (R_AddSingleSpriteDef(spritename, &sprites[i], wadnum, start, end)) + if (R_AddSingleSpriteDef(sprnames[i], &sprites[i], wadnum, start, end)) { #ifdef HWRENDER if (rendermode == render_opengl) @@ -464,9 +474,7 @@ void R_AddSpriteDefs(UINT16 wadnum) #endif // if a new sprite was added (not just replaced) addsprites++; -#ifndef ZDEBUG - CONS_Debug(DBG_SETUP, "sprite %s set in pwad %d\n", spritename, wadnum); -#endif + CONS_Debug(DBG_SETUP, "sprite %s set in pwad %d\n", sprnames[i], wadnum); } } From 14ac3ca9b0bf3b8e2bd984bbf351b59210094b8a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 16 Jun 2026 20:05:04 +0200 Subject: [PATCH 387/589] ;;... --- src/hardware/r_opengl/r_opengl.c | 2 +- src/p_floor.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index de27795e3..d3136cbfc 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1698,7 +1698,7 @@ static void GL_SetBlendMode(FBITFIELD flags) void GL_SetBlend(FBITFIELD PolyFlags) { - const FBITFIELD Xor = CurrentPolyFlags^PolyFlags;; + const FBITFIELD Xor = CurrentPolyFlags^PolyFlags; if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Skydecal|PF_Invisible)) { diff --git a/src/p_floor.c b/src/p_floor.c index 3c4128777..29f872745 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -845,7 +845,7 @@ void T_BounceCheese(levelspecthink_t *bouncer) T_MovePlane(bouncer->sector, 0, bouncer->sector->ceilingheight, 0, 1, -1); // update things on ceiling T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor bouncer->sector->ceilingdata = NULL; - bouncer->sector->floordata = NULL;; + bouncer->sector->floordata = NULL; bouncer->sector->moved = true; P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives } From cfda853e6f19b6f797c3c000e2b8fb1afc42b759 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 18 Jun 2026 16:35:42 +0300 Subject: [PATCH 388/589] Add console variant for mute command, also fix it applying mute for players that are not in game --- src/hu_stuff.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 65bcf4e94..67bcf6371 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -133,6 +133,7 @@ static void Command_Say_f(void); static void Command_Sayto_f(void); static void Command_Sayteam_f(void); static void Command_CSay_f(void); +static void Command_Mute_f(void); static void Got_Saycmd(const UINT8 **p, INT32 playernum); void HU_LoadGraphics(void) @@ -260,6 +261,8 @@ void HU_Init(void) COM_AddCommand("csay", Command_CSay_f); RegisterNetXCmd(XD_SAY, Got_Saycmd); + COM_AddCommand("muteplayer", Command_Mute_f); + if (dedicated || rendermode == render_none) return; @@ -1022,21 +1025,42 @@ static boolean HU_clearChatSpaces(void) return nothingbutspaces; } -static void DoMute(const char *name) +static void DoMute(const char *name, boolean chat) { INT32 pnum = D_LookupPlayer(name); - if (pnum < 0) + // Shortcut to reuse this function for console and chat command +#define PRINT(msg, sound) do { \ + if (chat) \ + HU_AddChatText((msg), (sound)); \ + else \ + CONS_Printf("%s\n", msg); \ +} while (0) + + if (pnum < 0 || !playeringame[pnum]) { - HU_AddChatText("\x85""ERROR: \x80Player not found.", false); + PRINT("\x85""ERROR: \x80Player not found.", false); return; } player_muted[pnum] = !player_muted[pnum]; - HU_AddChatText(va("Player '%s' has been %smuted.", player_names[pnum], player_muted[pnum] ? "" : "un"), false); + PRINT(va("Player '%s' has been %smuted.", player_names[pnum], player_muted[pnum] ? "" : "un"), false); if (player_muted[pnum]) - HU_AddChatText("Use same command to unmute them.", false); + PRINT("Use same command to unmute them.", false); + +#undef PRINT +} + +static void Command_Mute_f(void) +{ + if (COM_Argc() < 2) + { + CONS_Printf(M_GetText("mute : mute/unmute a player\n")); + return; + } + + DoMute(COM_Argv(1), false); } static void HU_SendChatMessage(void) @@ -1070,7 +1094,7 @@ static void HU_SendChatMessage(void) if (msglength >= 5 && strnicmp(msg, "/mute", 5) == 0) // Used /mute { if (msglength > 6) - DoMute(msg+6); + DoMute(msg+6, true); else HU_AddChatText("\x82NOTICE: \x80Usage: /mute ", false); From f9a6702219d27a1f1421670b2510851b05398628 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 18 Jun 2026 17:28:27 +0300 Subject: [PATCH 389/589] Fix player node staying muted when player leaves --- src/d_clisrv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7113f6ca9..cabbc1227 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3497,6 +3497,9 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) while ((doomcom->numslots > 1) && !playeringame[doomcom->numslots-1]) doomcom->numslots--; + // Unmute slot if player was muted + player_muted[playernum] = false; + // Reset the name sprintf(player_names[playernum], "Player %d", playernum+1); From b575c288fa6c7a77459daf87d594b5b9db5a5e7d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 18 Jun 2026 16:34:51 +0200 Subject: [PATCH 390/589] allow page up/down to scroll through chat like in console --- src/hu_stuff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 67bcf6371..51f9a7dad 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1281,13 +1281,15 @@ boolean HU_Responder(event_t *ev) chat_on = false; I_SetTextInput(false); } - else if ((c == KEY_UPARROW || c == KEY_MOUSEWHEELUP) && chat_scroll > 0 && !OLDCHAT) // CHAT SCROLLING YAYS! + else if ((c == KEY_UPARROW || c == KEY_PGUP || c == KEY_MOUSEWHEELUP) && + ((chat_scroll > 0) && !OLDCHAT)) // CHAT SCROLLING YAYS! { chat_scroll--; justscrolledup = true; chat_scrolltime = 4; } - else if ((c == KEY_DOWNARROW || c == KEY_MOUSEWHEELDOWN) && chat_scroll < chat_maxscroll && chat_maxscroll > 0 && !OLDCHAT) + else if ((c == KEY_DOWNARROW || c == KEY_PGDN || c == KEY_MOUSEWHEELDOWN) && + ((chat_scroll < chat_maxscroll) && (chat_maxscroll > 0) && !OLDCHAT)) { chat_scroll++; justscrolleddown = true; From 17093e80227fa50cdd138ee3e2c877c238e837c6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 18:03:40 +0200 Subject: [PATCH 391/589] add command to list unused map slots less pain for server owners hope this is sufficient --- src/d_netcmd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 8fbac60a6..61ba54002 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -150,6 +150,7 @@ static void Command_ListWADS_f(void); static void Command_LocateLump_f(void); static void Command_ListDoomednums_f(void); static void Command_ListUnusedSprites_f(void); +static void Command_ListUnusedMapSlots_f(void); static void Command_RunSOC(void); static void Command_Pause(void); static void Command_Respawn(void); @@ -645,6 +646,7 @@ void D_RegisterServerCommands(void) COM_AddCommand("locatelump", Command_LocateLump_f); COM_AddCommand("listmapthings", Command_ListDoomednums_f); COM_AddCommand("listunusedsprites", Command_ListUnusedSprites_f); + COM_AddCommand("listunusedmapslots", Command_ListUnusedMapSlots_f); COM_AddCommand("runsoc", Command_RunSOC); COM_AddCommand("pause", Command_Pause); @@ -4591,6 +4593,23 @@ void Command_ListUnusedSprites_f(void) } } +void Command_ListUnusedMapSlots_f(void) +{ + INT32 i; + + CONS_Printf("\x82Printing map slot non-usage...\n"); + + for (i = 0; i < NUMMAPS; i++) + { + // is checking this enough? + if (mapheaderinfo[i]) + continue; + + CONS_Printf("%s\n", G_BuildMapName(i+1)); + } +} + + // ========================================================================= // MISC. COMMANDS // ========================================================================= From fc588f8046f0c42a7b71ca5aac71efebe2bc5d94 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Sun, 20 Nov 2022 11:50:57 +0100 Subject: [PATCH 392/589] Make con_height adjustable on the fly --- src/console.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/console.c b/src/console.c index 8ca29f901..c155bd745 100644 --- a/src/console.c +++ b/src/console.c @@ -103,6 +103,8 @@ static void CON_InputInit(void); static void CON_RecalcSize(void); static void CON_ChangeHeight(void); +static void CON_DrawBackpic(void); +static void CONS_height_Change(void); static void CONS_hudlines_Change(void); static void CONS_backcolor_Change(void); @@ -131,7 +133,7 @@ static CV_PossibleValue_t speed_cons_t[] = {{0, "MIN"}, {64, "MAX"}, {0, NULL}}; static consvar_t cons_speed = {"con_speed", "8", CV_SAVE, speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // percentage of screen height to use for console -static consvar_t cons_height = {"con_height", "50", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cons_height = {"con_height", "50", CV_CALL|CV_SAVE, CV_Unsigned, CONS_height_Change, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t backpic_cons_t[] = {{0, "translucent"}, {1, "picture"}, {0, NULL}}; // whether to use console background picture, or translucent mode @@ -173,6 +175,18 @@ consvar_t cons_consoleprintinmenu = {"consoleprintinmenu", "Off", CV_SAVE, CV_On static void CON_Print(char *msg); +// Change the console height on demand +// +static void CONS_height_Change(void) +{ + Lock_state(); + + if (con_destlines > 0 && !con_startup) // If the console is open (as in, not using "bind")... + CON_ChangeHeight(); // ...update its height now, not only when it's closed and re-opened + + Unlock_state(); +} + // // static void CONS_hudlines_Change(void) From c275555678edf16413de1c70e8c50d2fb3910a1b Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony Date: Sun, 20 Nov 2022 11:51:40 +0100 Subject: [PATCH 393/589] Draw the input prompt while the console is moving --- src/console.c | 77 ++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/src/console.c b/src/console.c index c155bd745..517ab9f58 100644 --- a/src/console.c +++ b/src/console.c @@ -62,7 +62,7 @@ static boolean con_started = false; // console has been initialised static boolean con_forcepic = true; // at startup toggle console translucency when first off boolean con_recalc = false; // set true when screen size has changed -static tic_t con_tick; // console ticker for anim or blinking prompt cursor +static tic_t con_tick; // console ticker for blinking prompt cursor // con_scrollup should use time (currenttime - lasttime).. static boolean consoletoggle; // true when console key pushed, ticker will handle @@ -1651,53 +1651,54 @@ static void CON_DrawConsole(void) } // draw console text lines from top to bottom - if (con_curlines < minheight) - return; - - i = con_cy - con_scrollup; - - // skip the last empty line due to the cursor being at the start of a new line - i--; - - i -= (con_curlines - minheight) / charheight; - - if (rendermode == render_none) return; - - for (y = (con_curlines-minheight) % charheight; y <= con_curlines-minheight; y += charheight, i++) + if (con_curlines >= minheight) { - INT32 x; - size_t c; + i = con_cy - con_scrollup; - p = (UINT8 *)&con_buffer[((i > 0 ? i : 0)%con_totallines)*con_width]; + // skip the last empty line due to the cursor being at the start of a new line + i--; - for (c = 0, x = charwidth; c < con_width; c++, x += charwidth, p++) + i -= (con_curlines - minheight) / charheight; + + if (rendermode == render_none) + return; + + for (y = (con_curlines-minheight) % charheight; y <= con_curlines-minheight; y += charheight, i++) { - while (*p & 0x80) + INT32 x; + size_t c; + + p = (UINT8 *)&con_buffer[((i > 0 ? i : 0)%con_totallines)*con_width]; + + for (c = 0, x = charwidth; c < con_width; c++, x += charwidth, p++) { - charflags = (*p & 0x7f) << V_CHARCOLORSHIFT; - p++; - c++; + while (*p & 0x80) + { + charflags = (*p & 0x7f) << V_CHARCOLORSHIFT; + p++; + c++; + } + + if (c >= con_width) + break; + + int emotelen; + emote_t *emote; + + if ((emote = M_VerifyEmote((const char *)p, &emotelen))) + { + M_DrawScaledEmote(x<= con_width) - break; - - int emotelen; - emote_t *emote; - - if ((emote = M_VerifyEmote((const char *)p, &emotelen))) - { - M_DrawScaledEmote(x<= minheight) && !con_startup) + if ((con_curlines >= (minheight-charheight)) && !con_startup) CON_DrawInput(); } From 3b6a09da9b5178dd316b01d483d9d7998667951c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 19:04:42 +0200 Subject: [PATCH 394/589] oops --- src/console.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/console.c b/src/console.c index 517ab9f58..40a3d1700 100644 --- a/src/console.c +++ b/src/console.c @@ -103,7 +103,6 @@ static void CON_InputInit(void); static void CON_RecalcSize(void); static void CON_ChangeHeight(void); -static void CON_DrawBackpic(void); static void CONS_height_Change(void); static void CONS_hudlines_Change(void); static void CONS_backcolor_Change(void); From 9bdda66a0ca8d2c9cd4898fdd3ad4e646485e1be Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 19:14:15 +0200 Subject: [PATCH 395/589] rename this to D_CheckMapReplacements --- src/d_main.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index be19da2de..e821de566 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1353,7 +1353,7 @@ static void IdentifyVersion(void) // // search for maps // -static void D_CheckMaps(boolean checkreplaced) +static void D_CheckMapReplacements(boolean checkreplaced) { INT32 i; char *name; @@ -1829,17 +1829,19 @@ void D_SRB2Main(void) // conversion sometimes needs the palette V_ReloadPalette(); - D_CheckMaps(false); + D_CheckMapReplacements(false); - W_InitMultipleFiles(startuppwads, startuppwadcount, true); - - // Only search for pwad maps if we actually have a pwad added if (startuppwadcount > 0) { - D_CheckMaps(true); + CONS_Printf("W_InitMultipleFiles(): Adding extra PWADs.\n"); + W_InitMultipleFiles(startuppwads, startuppwadcount, true); + + // Only search for pwad maps if we actually have a pwad added + D_CheckMapReplacements(true); + + D_CleanFile(startuppwads, startuppwadcount); } - D_CleanFile(startuppwads, startuppwadcount); startuppwadcount = 0; cht_Init(); @@ -1926,7 +1928,7 @@ void D_SRB2Main(void) CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n"); R_Init(); -#if SOUND==SOUND_DUMMY +#if SOUND == SOUND_DUMMY sound_disabled = true; music_disabled = true; #else From 0cff3c23f3fc8bb7d9ef7c9746a69af7643560f8 Mon Sep 17 00:00:00 2001 From: AJ Martinez Date: Tue, 6 Feb 2024 06:00:59 -0700 Subject: [PATCH 396/589] Don't attempt itemamount correction after orbitals self-destruct --- src/k_kart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index ac1a3a8fd..4c41735d1 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4686,7 +4686,6 @@ void K_RepairOrbitChain(mobj_t *orbit) // Then recount to make sure item amount is correct if (orbit->target && orbit->target->player) { - player_t *player = orbit->target->player; INT32 num = 0; mobj_t *cur = orbit->target->hnext; @@ -4696,13 +4695,14 @@ void K_RepairOrbitChain(mobj_t *orbit) { prev = cur; cur = cur->hnext; - if (++num > player->kartstuff[k_itemamount]) + if (++num > orbit->target->player->kartstuff[k_itemamount]) P_RemoveMobj(prev); else prev->movedir = num; } - player->kartstuff[k_itemamount] = num; + if (orbit->target) // !P_MobjWasRemoved(orbit->target) + orbit->target->player->kartstuff[k_itemamount] = num; } } From 40537eca811629344027ae43520be0a8725838d3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 22:53:49 +0200 Subject: [PATCH 397/589] cleanup P_KillMobj a little --- src/k_kart.c | 2 +- src/p_inter.c | 148 ++++++++++++++++++++++++++++---------------------- 2 files changed, 83 insertions(+), 67 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 4c41735d1..dbe13ebd7 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4684,7 +4684,7 @@ void K_RepairOrbitChain(mobj_t *orbit) } // Then recount to make sure item amount is correct - if (orbit->target && orbit->target->player) + if (orbit->target && orbit->target->player) // !P_MobjWasRemoved(orbit->target) { INT32 num = 0; diff --git a/src/p_inter.c b/src/p_inter.c index 0a35cab3c..76e4d2e8b 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1462,48 +1462,11 @@ boolean P_CheckRacers(void) return false; } -/** Kills an object. - * - * \param target The victim. - * \param inflictor The attack weapon. May be NULL (environmental damage). - * \param source The attacker. May be NULL. - * \todo Cleanup, refactor, split up. - * \sa P_DamageMobj - */ -void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) +static void P_UpdateRemovedOrbital(mobj_t *target, mobj_t *inflictor, mobj_t *source) { - mobjtype_t item; - mobj_t *mo; - int ms; - - if (target->flags & (MF_ENEMY|MF_BOSS)) - target->momx = target->momy = target->momz = 0; - - // SRB2kart - if (target->type != MT_PLAYER && !(target->flags & MF_MONITOR) - && !(target->type == MT_ORBINAUT || target->type == MT_ORBINAUT_SHIELD - || target->type == MT_JAWZ || target->type == MT_JAWZ_DUD || target->type == MT_JAWZ_SHIELD - || target->type == MT_BANANA || target->type == MT_BANANA_SHIELD - || target->type == MT_EGGMANITEM || target->type == MT_EGGMANITEM_SHIELD - || target->type == MT_BALLHOG || target->type == MT_SPB)) // kart dead items - target->flags |= MF_NOGRAVITY; // Don't drop Tails 03-08-2000 - else - target->flags &= ~MF_NOGRAVITY; // lose it if you for whatever reason have it, I'm looking at you shields - // - - if (target->flags2 & MF2_NIGHTSPULL) - P_SetTarget(&target->tracer, NULL); - - // dead target is no more shootable - target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SPECIAL); - target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL); - target->health = 0; // This makes it easy to check if something's dead elsewhere. - - if (LUA_HookMobjDeath(target, inflictor, source) || P_MobjWasRemoved(target)) - return; - // SRB2kart // I wish I knew a better way to do this + //if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) if (target->target && target->target->player && target->target->player->mo) { if (target->target->player->kartstuff[k_eggmanheld] && target->type == MT_EGGMANITEM_SHIELD) @@ -1517,7 +1480,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { if (target->movedir != 0 && target->movedir < (UINT16)target->target->player->kartstuff[k_itemamount]) { - if (target->target->hnext) + if (target->target->hnext) // !P_MobjWasRemoved(target->target->hnext)) K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; @@ -1546,14 +1509,60 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) P_SetTarget(&target->target->hnext, NULL); } } - // Above block does not clean up rocket sneakers when a player dies, so we need to do it here target->target is null when using rocket sneakers +} + + +/** Kills an object. + * + * \param target The victim. + * \param inflictor The attack weapon. May be NULL (environmental damage). + * \param source The attacker. May be NULL. + * \todo Cleanup, refactor, split up. + * \sa P_DamageMobj + */ +void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) +{ + mobjtype_t item; + mobj_t *mo; + int ms; + + if (target->flags & (MF_ENEMY|MF_BOSS)) + target->momx = target->momy = target->momz = 0; + + // SRB2kart + if (target->type != MT_PLAYER + && !(target->flags & MF_MONITOR) + && !(target->type == MT_ORBINAUT || target->type == MT_ORBINAUT_SHIELD + || target->type == MT_JAWZ || target->type == MT_JAWZ_DUD || target->type == MT_JAWZ_SHIELD + || target->type == MT_BANANA || target->type == MT_BANANA_SHIELD + || target->type == MT_EGGMANITEM || target->type == MT_EGGMANITEM_SHIELD + || target->type == MT_BALLHOG || target->type == MT_SPB)) // kart dead items + target->flags |= MF_NOGRAVITY; // Don't drop Tails 03-08-2000 + else + target->flags &= ~MF_NOGRAVITY; // lose it if you for whatever reason have it, I'm looking at you shields + // + + if (target->flags2 & MF2_NIGHTSPULL) + P_SetTarget(&target->tracer, NULL); + + // dead target is no more shootable + target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SPECIAL); + target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL); + target->health = 0; // This makes it easy to check if something's dead elsewhere. + + if (LUA_HookMobjDeath(target, inflictor, source) || P_MobjWasRemoved(target)) + return; + + P_UpdateRemovedOrbital(target, inflictor, source); + if (target->player) + { + // Above block does not clean up rocket sneakers when a player dies, so we need to do it here target->target is null when using rocket sneakers K_DropRocketSneaker(target->player); - // Let EVERYONE know what happened to a player! 01-29-2002 Tails - if (target->player && !target->player->spectator) - { - target->flags2 &= ~MF2_DONTDRAW; + // Let EVERYONE know what happened to a player! 01-29-2002 Tails + if (!target->player->spectator) + target->flags2 &= ~MF2_DONTDRAW; } // if killed by a player @@ -1563,6 +1572,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { P_SetTarget(&target->target, source); source->player->numboxes++; + if (cv_itemrespawn.value && (netgame || multiplayer)) { target->fuse = cv_itemrespawntime.value*TICRATE + 2; // Random box generation @@ -1580,35 +1590,41 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) target->player->playerstate = PST_DEAD; - if (cv_fading.value && P_IsLocalPlayer(target->player)) + if (P_IsLocalPlayer(target->player)) { - if (netgame || multiplayer) - ms = cv_respawntime.value * 1000; - else - ms = 1000; + if (cv_fading.value) + { + if (netgame || multiplayer) + ms = cv_respawntime.value * 1000; + else + ms = 1000; - /* - If the time spent with the music paused is less than half - a second, continue playing the song (just mute it). - */ - if ((ms - cv_respawnfademusicout.value) < 500) - S_FadeMusic(0, cv_respawnfademusicout.value); - else - S_FadeOutStopMusic(cv_respawnfademusicout.value); - } + /* + * If the time spent with the music paused is less than half + * a second, continue playing the song (just mute it). + */ + if ((ms - cv_respawnfademusicout.value) < 500) + S_FadeMusic(0, cv_respawnfademusicout.value); + else + S_FadeOutStopMusic(cv_respawnfademusicout.value); + } - for (UINT8 i = 0; i <= splitscreen; i++) - { - if (target->player == P_GetLocalPlayerForNum(i)) + if (target->player == &players[consoleplayer]) { // don't die in auto map, // switch view prior to dying - if (i == 0 && automapactive) + if (automapactive) AM_Stop(); + } - // added : 22-02-98: recenter view for next life... - localaiming[i] = 0; - break; + for (UINT8 i = 0; i <= splitscreen; i++) + { + if (target->player == P_GetLocalPlayerForNum(i)) + { + // added : 22-02-98: recenter view for next life... + localaiming[i] = 0; + break; + } } } From 0f1ad8a086334d806604ed8b9320c72148f0c919 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:07:12 +0200 Subject: [PATCH 398/589] few more smaller cleanups --- src/g_game.c | 5 +++-- src/hu_stuff.c | 1 + src/p_map.c | 4 ++-- src/p_maputl.cpp | 3 +++ src/p_setup.c | 16 +++++++++++----- src/r_segs.cpp | 31 ++++++++++++++++++------------- src/s_sound.c | 1 + 7 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index f6941a911..22f811bc8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -857,7 +857,8 @@ static void G_HandleLocalDriftturn(ticcmd_t *cmd, UINT8 ssplayer) static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) { INT32 axis = 0; - const boolean usejoystick = cv_usejoystick[(ssplayer-1)].value; + const UINT8 forplayer = (ssplayer-1); + const boolean usejoystick = cv_usejoystick[forplayer].value; // check for inputs and return button commands // for stuff like joining with item button, saltyhop, honking, etc. @@ -893,7 +894,7 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) #undef CHECKINPUT axis = JoyAxis(AXISLOOKBACK, ssplayer); - camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); + camspin[forplayer] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); // Reset to our spec player if we watch someone else. if ((cmd->driftturn || cmd->buttons) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 51f9a7dad..2c509080b 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1135,6 +1135,7 @@ static void HU_SendChatMessage(void) return; } } + // I'm very bad at C, I swear I am, additional checks eww! if (spc != 0) { diff --git a/src/p_map.c b/src/p_map.c index ee013a2ab..e4a7323ca 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1575,13 +1575,13 @@ static boolean PIT_CheckLine(line_t *ld) tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - return true; + return true; // didn't hit it if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return true; if (P_BoxOnLineSide(tmbbox, ld) != -1) - return true; + return true; // didn't hit it if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag. { diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 592f57e92..38e350409 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -1000,11 +1000,13 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) for (mobj = blocklinks[y*bmapwidth + x]; mobj; mobj = bnext) { P_SetTarget(&bnext, mobj->bnext); // We want to note our reference to bnext here incase it is MF_NOTHINK and gets removed! + if (!func(mobj)) { P_SetTarget(&bnext, NULL); return false; } + if (P_MobjWasRemoved(tmthing) // func just popped our tmthing, cannot continue. || (bnext && P_MobjWasRemoved(bnext))) // func just broke blockmap chain, cannot continue. { @@ -1012,6 +1014,7 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) return true; } } + P_SetTarget(&bnext, NULL); return true; } diff --git a/src/p_setup.c b/src/p_setup.c index 0be23b262..aee747626 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1025,6 +1025,7 @@ static void P_InitializeLinedef(line_t *ld) CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has two-sided flag set, but no second sidedef\n", sizeu1((size_t)(ld - lines))); } + // killough 4/4/98: support special sidedef interpretation below if (ld->sidenum[0] != 0xffff && ld->special) sides[ld->sidenum[0]].special = ld->special; if (ld->sidenum[1] != 0xffff && ld->special) @@ -2329,7 +2330,9 @@ static void P_LoadRecordGhosts(void) if (!gpath) return; - sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); + const char *mapname = G_BuildMapName(gamemap); + + sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, mapname); // Best Time ghost if (cv_ghost_besttime.value) @@ -2379,9 +2382,10 @@ static void P_LoadRecordGhosts(void) { lumpnum_t l; UINT8 j = 1; - while (j <= 99 && (l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(gamemap),j))) != LUMPERROR) + + while (j <= 99 && (l = W_CheckNumForName(va("%sS%02u", mapname, j))) != LUMPERROR) { - G_AddGhost(va("%sS%02u",G_BuildMapName(gamemap),j)); + G_AddGhost(va("%sS%02u", mapname, j)); j++; } } @@ -2423,10 +2427,12 @@ static void P_InitMinimapInfo(void) Patch_Free(minimapinfo.minimap_pic); minimapinfo.minimap_pic = NULL; - lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap))); + const char *mapname = G_BuildMapName(gamemap); + + lumpnum = W_CheckNumForName(va("%sR", mapname)); if (lumpnum != LUMPERROR) - minimapinfo.minimap_pic = W_CachePatchName(va("%sR", G_BuildMapName(gamemap)), PU_PATCH); + minimapinfo.minimap_pic = W_CachePatchName(va("%sR", mapname), PU_PATCH); minimapinfo.min_x = bsp->bbox[0][BOXLEFT]; minimapinfo.max_x = bsp->bbox[0][BOXRIGHT]; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index f94e72b4c..26e5a582b 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -311,6 +311,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 { rw_scalestep = drawseg->scalestep; spryscale = drawseg->scale1 + (x1 - drawseg->x1)*rw_scalestep; + if (dc->numlights) { // reset all lights to their starting heights for (i = 0; i < dc->numlights; i++) @@ -435,6 +436,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3 windowtop = windowbottom + 1; set_colormap_below_light(); } + windowbottom = realbot; if (windowtop < windowbottom) colfunc_2s(dc, col); @@ -2615,8 +2617,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) auto set_topstep_normal = [&] { - topstep = -FixedMul (rw_scalestep, worldtop); - topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); + topstep = -FixedMul(rw_scalestep, worldtop); + topfrac = (centeryfrac>>4) - FixedMul(worldtop, rw_scale); }; // untextured seg @@ -2625,7 +2627,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) const bool tophigh = (worldhigh <= worldtop && worldhighslope <= worldtopslope); // if we cant see the goddamn skyplane, well there wont be any skybox - // we could kill skyVisible instead, but i want to keep the performance improvemnts it yields + // we could kill skyVisible instead, but i want to keep the performance improvements it yields // so we do this absolute trash if ((tophigh && (frontsector->floorpic != skyflatnum && frontsector->ceilingpic != skyflatnum)) // try to guess if its a "window" @@ -2637,14 +2639,16 @@ void R_StoreWallRange(INT32 start, INT32 stop) // this is an attempt to fix issues with textureless single sided lines drawing nothing where they should just draw sky instead if (tophigh && !backsector && frontsector->ceilingpic == skyflatnum) { - topstep = -FixedMul (rw_scalestep, worldbottom); - topfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); - // account for slopes to try and get rid of sharp edges from the black void if (frontsector->f_slope || (backsector && backsector->f_slope)) { - topstep = -FixedMul (rw_scalestep, worldbottomslope); - topfrac = (centeryfrac>>4) - FixedMul (worldbottomslope, rw_scale); + topstep = -FixedMul(rw_scalestep, worldbottomslope); + topfrac = (centeryfrac>>4) - FixedMul(worldbottomslope, rw_scale); + } + else + { + topstep = -FixedMul(rw_scalestep, worldbottom); + topfrac = (centeryfrac>>4) - FixedMul(worldbottom, rw_scale); } } else @@ -2653,18 +2657,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) else set_topstep_normal(); - bottomstep = -FixedMul (rw_scalestep, worldbottom); - bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); + bottomstep = -FixedMul(rw_scalestep, worldbottom); + bottomfrac = (centeryfrac>>4) - FixedMul(worldbottom, rw_scale); if (frontsector->c_slope) { - fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2); + fixed_t topfracend = (centeryfrac>>4) - FixedMul(worldtopslope, ds_p->scale2); topstep = (topfracend-topfrac)/(range); } if (frontsector->f_slope) { - fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2); + fixed_t bottomfracend = (centeryfrac>>4) - FixedMul(worldbottomslope, ds_p->scale2); bottomstep = (bottomfracend-bottomfrac)/(range); } } @@ -2782,7 +2786,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (bottomtexture) { - fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2); + fixed_t bottomfracend = (centeryfrac>>4) - FixedMul(worldlowslope, ds_p->scale2); pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); pixlowstep = (bottomfracend-pixlow)/(range); @@ -3045,6 +3049,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->silhouette |= SIL_BOTTOM; ds_p->bsilheight = backsector->f_slope ? INT32_MAX : backsector->floorheight; } + if (!(ds_p->silhouette & SIL_TOP)) { ds_p->silhouette |= SIL_TOP; diff --git a/src/s_sound.c b/src/s_sound.c index 5d3c43a3c..a95fc39c0 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -937,6 +937,7 @@ static boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, listener_t listensource; INT32 i; + // e6y if (!listener) return false; From 066adb972e585e8e21bc85875edff37a7a3bb920 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:05:53 +0200 Subject: [PATCH 399/589] add some more mobj null checks to P_MobjThinker from srb2 ig --- src/p_mobj.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index 96a8e11d5..5e33a9803 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9167,6 +9167,11 @@ void P_MobjThinker(mobj_t *mobj) || P_WeaponOrPanel(mobj->type)) { P_TryMove(mobj, mobj->x, mobj->y, true); // Sets mo->standingslope correctly + + //if (P_MobjWasRemoved(mobj)) + if (!mobj) // anything that calls checkposition can be lethal + return; + P_ButteredSlope(mobj); } @@ -9192,6 +9197,10 @@ void P_MobjThinker(mobj_t *mobj) } } + //if (P_MobjWasRemoved(mobj)) + if (!mobj) + return; // obligatory paranoia check + // Can end up here if a player dies. P_CycleMobjState(mobj); From 9cc74d8b17e2b194d29bed6c7cc749320782829d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:04:36 +0200 Subject: [PATCH 400/589] use P_MobjWasRemoved for P_MoveChaseCamera dont need to care about synch safety here.... --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 11c5e0b81..d952e296d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3739,7 +3739,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall fixed_t f1, f2; // We probably shouldn't move the camera if there is no player or player mobj somehow - if (!player || !player->mo) + if (!player || P_MobjWasRemoved(player->mo)) return true; // This can happen when joining From 4b2a13defbf0a9f7d1ec4c40fd000bcf4cb436ef Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:29:59 +0200 Subject: [PATCH 401/589] cleanup K_DropItems a bit move "paperitem" spawn to its separate function like RR --- src/k_kart.c | 73 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index dbe13ebd7..cb4641849 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4559,50 +4559,59 @@ void K_DropHnextList(player_t *player) P_RemoveMobj(work); } - { - // we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic... - P_SetTarget(&player->mo->hnext, NULL); - player->kartstuff[k_bananadrag] = 0; + // we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic... + P_SetTarget(&player->mo->hnext, NULL); + player->kartstuff[k_bananadrag] = 0; - if (player->kartstuff[k_eggmanheld]) - player->kartstuff[k_eggmanheld] = 0; - else if (player->kartstuff[k_itemheld] - && (dropall || (--player->kartstuff[k_itemamount] <= 0))) - { - player->kartstuff[k_itemamount] = player->kartstuff[k_itemheld] = 0; - player->kartstuff[k_itemtype] = KITEM_NONE; - } + if (player->kartstuff[k_eggmanheld]) + player->kartstuff[k_eggmanheld] = 0; + else if (player->kartstuff[k_itemheld] + && (dropall || (--player->kartstuff[k_itemamount] <= 0))) + { + player->kartstuff[k_itemamount] = player->kartstuff[k_itemheld] = 0; + player->kartstuff[k_itemtype] = KITEM_NONE; } } +static void K_DropPaperItem(player_t *player, boolean thunderhack, INT32 itemamount) +{ + const mobj_t *pmo = player->mo; + + if (P_MobjWasRemoved(pmo)) + { + return; + } + + mobj_t *drop = P_SpawnMobj(pmo->x, pmo->y, (pmo->z + pmo->height/2), MT_FLOATINGITEM); + P_SetScale(drop, drop->scale>>4); + + drop->destscale = (3*drop->destscale)/2; + + drop->angle = pmo->angle + ANGLE_90; + P_Thrust(drop, FixedAngle(P_RandomFixed()*180) + pmo->angle + ANGLE_90, 16*mapobjectscale); + drop->momz = P_MobjFlip(pmo)*3*mapobjectscale; + if (drop->eflags & MFE_UNDERWATER) + drop->momz = (117 * drop->momz) / 200; + + drop->threshold = (thunderhack ? KITEM_THUNDERSHIELD : player->kartstuff[k_itemtype]); + drop->movecount = itemamount; + + drop->flags |= MF_NOCLIPTHING; +} + // For getting EXTRA hit! void K_DropItems(player_t *player) { - boolean thunderhack = (player->kartstuff[k_curshield] && player->kartstuff[k_itemtype] == KITEM_THUNDERSHIELD); + const boolean thunderhack = (player->kartstuff[k_curshield] && player->kartstuff[k_itemtype] == KITEM_THUNDERSHIELD); if (thunderhack) player->kartstuff[k_itemtype] = KITEM_NONE; K_DropHnextList(player); - if (!P_MobjWasRemoved(player->mo) && player->kartstuff[k_itemamount]) + if (player->kartstuff[k_itemamount]) { - mobj_t *drop = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height/2, MT_FLOATINGITEM); - P_SetScale(drop, drop->scale>>4); - drop->destscale = (3*drop->destscale)/2; - - drop->angle = player->mo->angle + ANGLE_90; - P_Thrust(drop, - FixedAngle(P_RandomFixed()*180) + player->mo->angle + ANGLE_90, - 16*mapobjectscale); - drop->momz = P_MobjFlip(player->mo)*3*mapobjectscale; - if (drop->eflags & MFE_UNDERWATER) - drop->momz = (117 * drop->momz) / 200; - - drop->threshold = (thunderhack ? KITEM_THUNDERSHIELD : player->kartstuff[k_itemtype]); - drop->movecount = player->kartstuff[k_itemamount]; - - drop->flags |= MF_NOCLIPTHING; + K_DropPaperItem(player, thunderhack, player->kartstuff[k_itemamount]); } K_StripItems(player); @@ -4658,7 +4667,7 @@ void K_DropKitchenSink(player_t *player) return; if (player->mo->hnext->type != MT_SINK_SHIELD) - return; //so we can just call this function regardless of what is being held + return; // so we can just call this function regardless of what is being held P_KillMobj(player->mo->hnext, NULL, NULL); @@ -4934,8 +4943,10 @@ static void K_MoveHeldObjects(player_t *player) cur->momx = FixedMul(FINECOSINE(cur->angle>>ANGLETOFINESHIFT), cur->extravalue1); cur->momy = FixedMul(FINESINE(cur->angle>>ANGLETOFINESHIFT), cur->extravalue1); cur->flags &= ~MF_NOCLIPTHING; + if (!P_TryMove(cur, player->mo->x + cur->momx, player->mo->y + cur->momy, true)) P_SlideMove(cur, true); + if (P_IsObjectOnGround(player->mo)) { if (P_MobjFlip(cur) > 0) From d8ffffd86eca133c575af291ba08f86aeaaec576 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jun 2026 20:52:11 +0200 Subject: [PATCH 402/589] replace non valid sidenum magic number with what dsda-doom uses --- src/doomdata.h | 4 +++- src/hardware/hw_bsp.c | 2 +- src/hardware/hw_cache.c | 2 +- src/lua_maplib.c | 2 +- src/p_maputl.cpp | 4 ++-- src/p_saveg.c | 10 ++++++---- src/p_setup.c | 20 ++++++++++---------- src/p_spec.c | 18 +++++++++--------- src/r_defs.h | 2 +- src/r_segs.cpp | 2 +- src/r_splats.c | 2 +- 11 files changed, 36 insertions(+), 32 deletions(-) diff --git a/src/doomdata.h b/src/doomdata.h index 2f5e014c7..77dd84c50 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -81,10 +81,12 @@ typedef struct INT16 flags; INT16 special; INT16 tag; - // sidenum[1] will be 0xffff if one sided + // sidenum[1] will be NO_INDEX if one sided UINT16 sidenum[2]; } ATTRPACK maplinedef_t; +#define NO_INDEX 0xffff + // // LineDef attributes. // diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 79069857c..77f66d308 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -373,7 +373,7 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) if (!gl_maphashorizonlines && line->special == HORIZONSPECIAL) gl_maphashorizonlines = true; - if (line->sidenum[1] != 0xffff) + if (line->sidenum[1] != NO_INDEX) { if (sides[line->sidenum[0]].sector == sides[line->sidenum[1]].sector) { diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index d7c25bf3d..9300cbe81 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -729,7 +729,7 @@ static void HWR_PrecacheLevelTextures(void) for (j = 0; j < 2; j++) { // check if single-sided linedef - if (line->sidenum[j] == 0xffff) + if (line->sidenum[j] == NO_INDEX) continue; const side_t *side = &sides[line->sidenum[j]]; diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 279b02883..87639b77b 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -652,7 +652,7 @@ static int line_get(lua_State *L) LUA_PushUserdata(L, &sides[line->sidenum[0]], META_SIDE); return 1; case line_backside: // backside - if (line->sidenum[1] == 0xffff) + if (line->sidenum[1] == NO_INDEX) return 0; LUA_PushUserdata(L, &sides[line->sidenum[1]], META_SIDE); return 1; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 38e350409..d9f22c28a 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -242,7 +242,7 @@ void P_CameraLineOpening(line_t *linedef) sector_t *back; fixed_t frontfloor, frontceiling, backfloor, backceiling; - if (linedef->sidenum[1] == 0xffff) + if (linedef->sidenum[1] == NO_INDEX) { // single sided line openrange = 0; @@ -398,7 +398,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) { sector_t *front, *back; - if (linedef->sidenum[1] == 0xffff) + if (linedef->sidenum[1] == NO_INDEX) { // single sided line openrange = 0; diff --git a/src/p_saveg.c b/src/p_saveg.c index 667ee5c47..0d8ebd713 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -691,7 +691,7 @@ static void ArchiveLines(savebuffer_t *save) if (spawnli->special == 321 || spawnli->special == 322) // only reason li->callcount would be non-zero is if either of these are involved diff |= LD_CLLCOUNT; - if (li->sidenum[0] != 0xffff) + if (li->sidenum[0] != NO_INDEX) { si = &sides[li->sidenum[0]]; spawnsi = &spawnsides[li->sidenum[0]]; @@ -706,7 +706,8 @@ static void ArchiveLines(savebuffer_t *save) if (si->midtexture != spawnsi->midtexture) diff |= LD_S1MIDTEX; } - if (li->sidenum[1] != 0xffff) + + if (li->sidenum[1] != NO_INDEX) { si = &sides[li->sidenum[1]]; spawnsi = &spawnsides[li->sidenum[1]]; @@ -786,6 +787,7 @@ static void UnArchiveFFloors(savebuffer_t *save, const sector_t *ss) I_Error("Sector does not have any ffloors!"); fflr_i = READUINT16(save->p); // get first modified ffloor's number ready + for (;;) // for some reason the usual for (rover = x; ...) thing doesn't work here? { if (fflr_i == 0xffff) // end of modified ffloors list, let's stop already @@ -3510,7 +3512,7 @@ static void P_ReloadSaveLevelData(void) li->firsttag = spawnli->firsttag; li->nexttag = spawnli->nexttag; - if (li->sidenum[0] != 0xffff) + if (li->sidenum[0] != NO_INDEX) { si = &sides[li->sidenum[0]]; spawnsi = &spawnsides[li->sidenum[0]]; @@ -3521,7 +3523,7 @@ static void P_ReloadSaveLevelData(void) si->midtexture = spawnsi->midtexture; } - if (li->sidenum[1] != 0xffff) + if (li->sidenum[1] != NO_INDEX) { si = &sides[li->sidenum[1]]; spawnsi = &spawnsides[li->sidenum[1]]; diff --git a/src/p_setup.c b/src/p_setup.c index aee747626..3af2324a3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1001,9 +1001,9 @@ static void P_InitializeLinedef(line_t *ld) // cph 2002/07/20 - these errors are fatal if not fixed, so apply them for (j = 0; j < 2; j++) { - if (ld->sidenum[j] != 0xffff && ld->sidenum[j] >= (UINT16)numsides) + if (ld->sidenum[j] != NO_INDEX && ld->sidenum[j] >= (UINT16)numsides) { - ld->sidenum[j] = 0xffff; + ld->sidenum[j] = NO_INDEX; CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has out-of-range sidedef number\n", sizeu1((size_t)(ld - lines))); } } @@ -1011,14 +1011,14 @@ static void P_InitializeLinedef(line_t *ld) ld->firsttag = ld->nexttag = -1; // killough 11/98: fix common wad errors (missing sidedefs): - if (ld->sidenum[0] == 0xffff) + if (ld->sidenum[0] == NO_INDEX) { ld->sidenum[0] = 0; // Substitute dummy sidedef for missing right side // cph - print a warning about the bug CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s missing first sidedef\n", sizeu1((size_t)(ld - lines))); } - if ((ld->sidenum[1] == 0xffff) && (ld->flags & ML_TWOSIDED)) + if ((ld->sidenum[1] == NO_INDEX) && (ld->flags & ML_TWOSIDED)) { ld->flags &= ~ML_TWOSIDED; // Clear 2s flag for missing left side // cph - print a warning about the bug @@ -1026,9 +1026,9 @@ static void P_InitializeLinedef(line_t *ld) } // killough 4/4/98: support special sidedef interpretation below - if (ld->sidenum[0] != 0xffff && ld->special) + if (ld->sidenum[0] != NO_INDEX && ld->special) sides[ld->sidenum[0]].special = ld->special; - if (ld->sidenum[1] != 0xffff && ld->special) + if (ld->sidenum[1] != NO_INDEX && ld->special) sides[ld->sidenum[1]].special = ld->special; } @@ -1061,10 +1061,10 @@ static void P_LoadLineDefs2(void) for (; i--; ld++) { ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here - ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : NULL; + ld->backsector = ld->sidenum[1] != NO_INDEX ? sides[ld->sidenum[1]].sector : NULL; // Repeat count for midtexture - if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff)) + if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != NO_INDEX)) { sides[ld->sidenum[0]].repeatcnt = (INT16)(((unsigned)sides[ld->sidenum[0]].textureoffset >> FRACBITS) >> 12); sides[ld->sidenum[0]].textureoffset = (((unsigned)sides[ld->sidenum[0]].textureoffset >> FRACBITS) & 2047) << FRACBITS; @@ -1080,13 +1080,13 @@ static void P_LoadLineDefs2(void) { size_t len = strlen(sides[ld->sidenum[0]].text)+1; - if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text) + if (ld->sidenum[1] != NO_INDEX && sides[ld->sidenum[1]].text) len += strlen(sides[ld->sidenum[1]].text); ld->text = Z_Malloc(len, PU_LEVEL, NULL); memcpy(ld->text, sides[ld->sidenum[0]].text, strlen(sides[ld->sidenum[0]].text)+1); - if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text) + if (ld->sidenum[1] != NO_INDEX && sides[ld->sidenum[1]].text) memcpy(ld->text+strlen(ld->text)+1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text)+1); } break; diff --git a/src/p_spec.c b/src/p_spec.c index 978c3041e..032fdbfbd 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -889,7 +889,7 @@ static boolean PolyDoor(line_t *line) pdd.angle = line->angle; // angle of motion pdd.distance = sides[line->sidenum[0]].rowoffset; - if (line->sidenum[1] != 0xffff) + if (line->sidenum[1] != NO_INDEX) pdd.delay = sides[line->sidenum[1]].textureoffset >> FRACBITS; // delay in tics else pdd.delay = 0; @@ -899,7 +899,7 @@ static boolean PolyDoor(line_t *line) pdd.speed = sides[line->sidenum[0]].textureoffset >> FRACBITS; // angular speed pdd.distance = sides[line->sidenum[0]].rowoffset >> FRACBITS; // angular distance - if (line->sidenum[1] != 0xffff) + if (line->sidenum[1] != NO_INDEX) pdd.delay = sides[line->sidenum[1]].textureoffset >> FRACBITS; // delay in tics else pdd.delay = 0; @@ -1989,8 +1989,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT32 position = (INT32)max(sides[line->sidenum[0]].midtexture, 0); UINT32 prefadems = (UINT32)max(sides[line->sidenum[0]].textureoffset >> FRACBITS, 0); UINT32 postfadems = (UINT32)max(sides[line->sidenum[0]].rowoffset >> FRACBITS, 0); - UINT8 fadetarget = (UINT8)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].textureoffset >> FRACBITS : 0, 0); - INT16 fadesource = (INT16)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].rowoffset >> FRACBITS : -1, -1); + UINT8 fadetarget = (UINT8)max((line->sidenum[1] != NO_INDEX) ? sides[line->sidenum[1]].textureoffset >> FRACBITS : 0, 0); + INT16 fadesource = (INT16)max((line->sidenum[1] != NO_INDEX) ? sides[line->sidenum[1]].rowoffset >> FRACBITS : -1, -1); // Seek offset from current song position if (line->flags & ML_EFFECT1) @@ -2504,7 +2504,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) var1 = sides[line->sidenum[0]].toptexture; //(line->dx>>FRACBITS)-1; - if (line->sidenum[1] != 0xffff && line->flags & ML_BLOCKMONSTERS) // read power from back sidedef + if (line->sidenum[1] != NO_INDEX && line->flags & ML_BLOCKMONSTERS) // read power from back sidedef var2 = sides[line->sidenum[1]].toptexture; else if (line->flags & ML_NOCLIMB) // 'Infinite' var2 = UINT16_MAX; @@ -2633,7 +2633,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (always || this->bottomtexture) this->bottomtexture = set->bottomtexture; - if (lines[linenum].sidenum[1] == 0xffff) + if (lines[linenum].sidenum[1] == NO_INDEX) continue; // One-sided stops here. // Back side @@ -2682,7 +2682,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) sector_t *sec; mobj_t *thing; - if (line->sidenum[1] != 0xffff) + if (line->sidenum[1] != NO_INDEX) state = (statenum_t)sides[line->sidenum[1]].toptexture; while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) @@ -6056,7 +6056,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) break; case 259: // Make-Your-Own FOF! - if (lines[i].sidenum[1] != 0xffff) + if (lines[i].sidenum[1] != NO_INDEX) { UINT8 *data; UINT16 b; @@ -6785,7 +6785,7 @@ static void P_SpawnScrollers(void) case 506: s = lines[i].sidenum[1]; - if (s != 0xffff) + if (s != NO_INDEX) Add_Scroller(sc_side, -sides[s].textureoffset, sides[s].rowoffset, -1, lines[i].sidenum[0], accel, 0); else CONS_Debug(DBG_GAMELOGIC, "Line special 506 (line #%s) missing 2nd side!\n", sizeu1(i)); diff --git a/src/r_defs.h b/src/r_defs.h index 217314028..680a8a9cc 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -430,7 +430,7 @@ typedef struct line_s INT16 tag; // Visual appearance: sidedefs. - UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided + UINT16 sidenum[2]; // sidenum[1] will be NO_INDEX if one-sided fixed_t alpha; // translucency UINT8 blendmode; // blendmode diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 26e5a582b..8460d4679 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -2206,7 +2206,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) topremap = (encoremap && !(curline->linedef->flags & ML_TFERLINE)); if ((linedef->flags & (ML_DONTPEGTOP) && (linedef->flags & ML_DONTPEGBOTTOM)) - && linedef->sidenum[1] != 0xffff) + && linedef->sidenum[1] != NO_INDEX) { // Special case... use offsets from 2nd side but only if it has a texture. side_t *def = &sides[linedef->sidenum[1]]; diff --git a/src/r_splats.c b/src/r_splats.c index bcef8cf24..5560477ba 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -131,7 +131,7 @@ void R_AddWallSplat(line_t *wallline, INT16 sectorside, const char *patchname, f // set the splat splat->patch = W_GetNumForName(patchname); sectorside ^= 1; - if (wallline->sidenum[sectorside] != 0xffff) + if (wallline->sidenum[sectorside] != NO_INDEX) { backsector = sides[wallline->sidenum[sectorside]].sector; From 363612c488a4971efb56832e628b91c91b63db5f Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jun 2026 16:52:33 +0200 Subject: [PATCH 403/589] port more checks from dsda-doom for invalid map data decided to have it i_error for now, not sure what exactly is the best approach here should we just "correct" some of those instead? vanilla probably just crashes anyways --- src/p_setup.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 124 insertions(+), 6 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 3af2324a3..a5769179c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -437,8 +437,41 @@ static void P_LoadSegs(UINT8 *data) for (i = 0; i < numsegs; i++, li++, ml++) { - li->v1 = &vertexes[SHORT(ml->v1)]; - li->v2 = &vertexes[SHORT(ml->v2)]; + INT16 v1, v2; + + v1 = SHORT(ml->v1); + v2 = SHORT(ml->v2); + + // e6y + // check and fix wrong references to non-existent vertexes + // see e1m9 @ NIVELES.WAD + // http://www.doomworld.com/idgames/index.php?id=12647 + if ((unsigned)v1 >= numvertexes || (unsigned)v2 >= numvertexes) + { + if ((unsigned)v1 >= numvertexes) + I_Error("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v1); + if ((unsigned)v2 >= numvertexes) + I_Error("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v2); + + /* + if (li->sidedef == &sides[li->linedef->sidenum[0]]) + { + li->v1 = lines[ml->linedef].v1; + li->v2 = lines[ml->linedef].v2; + } + else + { + li->v1 = lines[ml->linedef].v2; + li->v2 = lines[ml->linedef].v1; + } + */ + } + else + { + li->v1 = &vertexes[v1]; + li->v2 = &vertexes[v2]; + } + #ifdef HWRENDER if (rendermode == render_opengl) { @@ -455,14 +488,60 @@ static void P_LoadSegs(UINT8 *data) li->angle = (SHORT(ml->angle))<offset = (SHORT(ml->offset))<linedef); + + //e6y: check for wrong indexes + if ((unsigned)rawlinedef >= numlines) + { + I_Error("P_LoadSegs: seg %s references a non-existent linedef %d", sizeu1(i), (unsigned)rawlinedef); + } + ldef = &lines[rawlinedef]; li->linedef = ldef; - li->side = rawside = SHORT(ml->side); + rawside = SHORT(ml->side); + + //e6y: fix wrong side index + if (rawside != 0 && rawside != 1) + { + I_Error("P_LoadSegs: seg %s contains wrong side index %d.\n", sizeu1(i), rawside); + //rawside = 1; + } + + //e6y: check for wrong indexes + if (ldef->sidenum[rawside] >= numsides) + { + I_Error("P_LoadSegs: linedef %d for seg %s references a non-existent sidedef %d", rawlinedef, sizeu1(i), ldef->sidenum[rawside]); + } + + li->side = rawside; + li->sidedef = &sides[ldef->sidenum[rawside]]; - li->frontsector = sides[ldef->sidenum[rawside]].sector; + + /* cph 2006/09/30 - our frontsector can be the second side of the + * linedef, so must check for NO_INDEX in case we are incorrectly + * referencing the back of a 1S line */ + if (ldef->sidenum[rawside] == NO_INDEX) + { + I_Error("P_LoadSegs: front of seg %s has no sidedef\n", sizeu1(i)); + //li->frontsector = 0; + } + else + { + li->frontsector = sides[ldef->sidenum[rawside]].sector; + } if (ldef->flags & ML_TWOSIDED) - li->backsector = sides[ldef->sidenum[rawside^1]].sector; + { + if (ldef->sidenum[rawside^1] == NO_INDEX) + { + I_Error("P_LoadSegs: back of seg %s has no sidedef while being marked as double sided\n", sizeu1(i)); + // this is wrong + //li->backsector = GetSectorAtNullAddress(); + } + else + { + li->backsector = sides[ldef->sidenum[rawside^1]].sector; + } + } P_UpdateSegLightOffset(li); } @@ -738,7 +817,33 @@ static void P_LoadNodes(UINT8 *data) for (j = 0; j < 2; j++) { - no->children[j] = SHORT(mn->children[j]); + UINT16 child; + + child = SHORT(mn->children[j]); + + if (child & NF_SUBSECTOR) + { + // Convert to extended type + child &= ~NF_SUBSECTOR; + + // haleyjd 11/06/10: check for invalid subsector reference + if (child >= numsubsectors) + { + I_Error("P_LoadNodes: BSP tree %s references invalid subsector %d\n", sizeu1(i), child); + //child = 0; + } + + child |= NF_SUBSECTOR; + } + else if (child >= numnodes) + { + I_Error("P_LoadNodes: BSP node %s references invalid node.\n", sizeu1(i)); + //I_Error("P_LoadNodes: BSP node %d references invalid node %d.\n", sizeu1(i), Index(((node_t *)no->children[j]))); + //child = 0; + } + + no->children[j] = child; + for (k = 0; k < 4; k++) no->bbox[j][k] = SHORT(mn->bbox[j][k])<firstline >= numsegs) + { CorruptMapError(va("P_GroupLines: ss->firstline invalid " "(subsector %s, firstline refers to %d of %s)", sizeu1(i), ss->firstline, sizeu2(numsegs))); + } + seg = &segs[ss->firstline]; sidei = (size_t)(seg->sidedef - sides); + if (!seg->sidedef) + { CorruptMapError(va("P_GroupLines: seg->sidedef is NULL " "(subsector %s, firstline is %d)", sizeu1(i), ss->firstline)); + } + if (seg->sidedef - sides < 0 || seg->sidedef - sides > (UINT16)numsides) + { CorruptMapError(va("P_GroupLines: seg->sidedef refers to sidedef %s of %s " "(subsector %s, firstline is %d)", sizeu1(sidei), sizeu2(numsides), sizeu3(i), ss->firstline)); + } + if (!seg->sidedef->sector) + { CorruptMapError(va("P_GroupLines: seg->sidedef->sector is NULL " "(subsector %s, firstline is %d, sidedef is %s)", sizeu1(i), ss->firstline, sizeu1(sidei))); + } + ss->sector = seg->sidedef->sector; } From 2dacc333b5ffa4cd601e89b6182e9e0382c84396 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jun 2026 20:52:42 +0200 Subject: [PATCH 404/589] just set backsector to NULL if not in vanilla doom compat mode/overflow emulation GetSectorAtNullAddress will just return NULL, so we can do so aswell --- src/p_setup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index a5769179c..a7435c0c4 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -534,8 +534,7 @@ static void P_LoadSegs(UINT8 *data) if (ldef->sidenum[rawside^1] == NO_INDEX) { I_Error("P_LoadSegs: back of seg %s has no sidedef while being marked as double sided\n", sizeu1(i)); - // this is wrong - //li->backsector = GetSectorAtNullAddress(); + li->backsector = NULL; } else { From 568f29ed1c6fb44204131e1878b1da7d965c9209 Mon Sep 17 00:00:00 2001 From: entryway Date: Sat, 27 Mar 2010 19:34:43 +0000 Subject: [PATCH 405/589] Check for blockmap overflow in P_BlockLinesIterator. Under RANGECHECK define. --- src/p_maputl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index d9f22c28a..041bad1db 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -972,6 +972,10 @@ boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean (*func)(line_t *)) // First index is really empty, so +1 it. for (list = blockmaplump + offset + 1; *list != -1; list++) { +#ifdef RANGECHECK + if (*list < 0 || (UINT32)*list >= numlines) + I_Error("P_BlockLinesIterator: index >= numlines"); +#endif ld = &lines[*list]; if (ld->validcount == validcount) From 029c21eae822953a961a7627ee259de10fa21846 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jun 2026 20:53:49 +0200 Subject: [PATCH 406/589] correct map issues clientside MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit but be loud about it instead of I_Error´ing most of those would be fatal anyways, so screw vanilla desyncing if they crash eitherways --- src/g_game.c | 3 ++ src/p_saveg.c | 3 ++ src/p_setup.c | 103 +++++++++++++++++++++++++++++++++++++------------- src/p_setup.h | 3 ++ 4 files changed, 85 insertions(+), 27 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 22f811bc8..f720f98fd 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1310,6 +1310,7 @@ static void G_DoLoadLevel(boolean resetplayer) { // fail so reset game stuff Command_ExitGame_f(); + P_FreeCorruptMapWarnings(); return; } @@ -1343,6 +1344,8 @@ static void G_DoLoadLevel(boolean resetplayer) // clear hud messages remains (usually from game startup) CON_ClearHUD(); + // print any map errors now due to clearhud above :chaosleep: + P_PrintCorruptMapWarnings(); server_lagless = !cv_gentlemens.value; diff --git a/src/p_saveg.c b/src/p_saveg.c index 0d8ebd713..37fcf4c3e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3590,8 +3590,11 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, bool if (!P_SetupLevel(true, reloading)) { CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); + P_FreeCorruptMapWarnings(); return false; } + + P_PrintCorruptMapWarnings(); } else { diff --git a/src/p_setup.c b/src/p_setup.c index a7435c0c4..c8edf26de 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -188,6 +188,57 @@ FUNCNORETURN static ATTRNORETURN void CorruptMapError(const char *msg) I_Error("Invalid or corrupt map.\nLook in log file or text console for technical details."); } +static char **mapwarnings = NULL; +static size_t nummapwarnings = 0; + +// collect map errors we can fix clientside +// we then can print em when the map finishes loading +// so they actually appear and raise awareness shits fucked +// see G_DoLoadLevel as to why :chaosleep: +static void CorruptMapWarning(const char *msg) +{ +#ifdef PARANOIA + // just error out + I_Error("%sThis WILL crash Vanilla clients!\n", msg); +#endif + nummapwarnings++; + mapwarnings = Z_Realloc(mapwarnings, nummapwarnings * sizeof(*mapwarnings), PU_STATIC, NULL); + mapwarnings[nummapwarnings-1] = Z_StrDup(msg); +} + +void P_PrintCorruptMapWarnings(void) +{ + size_t i; + + if (!nummapwarnings) + return; + + for (i = 0; i < nummapwarnings; i++) + { + CONS_Alert(CONS_ERROR, "%sAttempting to fix... This WILL crash Vanilla clients!\n", mapwarnings[i]); + } + + P_FreeCorruptMapWarnings(); +} + +void P_FreeCorruptMapWarnings(void) +{ + size_t i; + + if (!nummapwarnings) + return; + + for (i = 0; i < nummapwarnings; i++) + { + Z_Free(mapwarnings[i]); + mapwarnings[i] = NULL; + } + + Z_Free(mapwarnings); + mapwarnings = NULL; + nummapwarnings = 0; +} + #define NUMLAPS_DEFAULT 3 static void P_ClearMapHeaderLighting(mapheader_lighting_t *lighting) @@ -449,11 +500,10 @@ static void P_LoadSegs(UINT8 *data) if ((unsigned)v1 >= numvertexes || (unsigned)v2 >= numvertexes) { if ((unsigned)v1 >= numvertexes) - I_Error("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v1); + CorruptMapWarning(va("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v1)); if ((unsigned)v2 >= numvertexes) - I_Error("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v2); + CorruptMapWarning(va("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v2)); - /* if (li->sidedef == &sides[li->linedef->sidenum[0]]) { li->v1 = lines[ml->linedef].v1; @@ -464,7 +514,6 @@ static void P_LoadSegs(UINT8 *data) li->v1 = lines[ml->linedef].v2; li->v2 = lines[ml->linedef].v1; } - */ } else { @@ -502,8 +551,8 @@ static void P_LoadSegs(UINT8 *data) //e6y: fix wrong side index if (rawside != 0 && rawside != 1) { - I_Error("P_LoadSegs: seg %s contains wrong side index %d.\n", sizeu1(i), rawside); - //rawside = 1; + CorruptMapWarning(va("P_LoadSegs: seg %s contains wrong side index %d.\n", sizeu1(i), rawside)); + rawside = 1; } //e6y: check for wrong indexes @@ -521,8 +570,8 @@ static void P_LoadSegs(UINT8 *data) * referencing the back of a 1S line */ if (ldef->sidenum[rawside] == NO_INDEX) { - I_Error("P_LoadSegs: front of seg %s has no sidedef\n", sizeu1(i)); - //li->frontsector = 0; + CorruptMapWarning(va("P_LoadSegs: front of seg %s has no sidedef\n", sizeu1(i))); + li->frontsector = NULL; } else { @@ -533,7 +582,7 @@ static void P_LoadSegs(UINT8 *data) { if (ldef->sidenum[rawside^1] == NO_INDEX) { - I_Error("P_LoadSegs: back of seg %s has no sidedef while being marked as double sided\n", sizeu1(i)); + CorruptMapWarning(va("P_LoadSegs: back of seg %s has no sidedef while being marked as double sided\n", sizeu1(i))); li->backsector = NULL; } else @@ -828,17 +877,17 @@ static void P_LoadNodes(UINT8 *data) // haleyjd 11/06/10: check for invalid subsector reference if (child >= numsubsectors) { - I_Error("P_LoadNodes: BSP tree %s references invalid subsector %d\n", sizeu1(i), child); - //child = 0; + CorruptMapWarning(va("P_LoadNodes: BSP tree %s references invalid subsector %d\n", sizeu1(i), child)); + child = 0; } child |= NF_SUBSECTOR; } else if (child >= numnodes) { - I_Error("P_LoadNodes: BSP node %s references invalid node.\n", sizeu1(i)); + CorruptMapWarning(va("P_LoadNodes: BSP node %s references invalid node.\n", sizeu1(i))); //I_Error("P_LoadNodes: BSP node %d references invalid node %d.\n", sizeu1(i), Index(((node_t *)no->children[j]))); - //child = 0; + child = 0; } no->children[j] = child; @@ -1852,16 +1901,11 @@ static boolean P_LoadRawBlockMap(UINT8 *data, size_t count) // http://www.doomworld.com/idgames/index.php?id=12935 if (!P_VerifyBlockMap(count)) { -#ifdef PARANOIA - I_Error("P_LoadBlockMap: erroneous BLOCKMAP lump may cause crashes.\n"); -#endif - CONS_Alert(CONS_ERROR, "P_LoadBlockMap: erroneous BLOCKMAP lump may cause crashes.\n"); - - //Z_Free(blockmaplump); - //blockmaplump = NULL; - //return false; // ideally we would just let the game rebuild the blockmap - // but this has a chance of desynching vanilla clients - // not sure whats worse honestly and i do not want to decide that :chaosleep: + CorruptMapWarning(va("P_LoadBlockMap: corrupted or invalid BLOCKMAP lump! Check the log for more information.\n")); + // vanilla WILL crash here anyways so just rebuild it ourselves + Z_Free(blockmaplump); + blockmaplump = NULL; + return false; } // clear out mobj chains @@ -2004,11 +2048,16 @@ static void P_LoadReject(UINT8 *data, size_t rejectsize) { if (rejectsize < neededsize) { -#ifdef PARANOIA - I_Error("REJECT is %s byte%s too small. REJECT might be invalid and crash vanilla clients!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); -#endif - CONS_Alert(CONS_ERROR, "REJECT is %s byte%s too small. REJECT might be invalid and crash vanilla clients!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s"); + CorruptMapWarning(va("P_LoadReject: REJECT is %s byte%s too small. REJECT might be invalid!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s")); +#ifdef COMPAT_VANILLA + // we can pad this and somewhat prevent desyncs + // probs not cool if the reject is from a completely different map + // but whatever allocsize = neededsize; +#else + rejectmatrix = NULL; + return; +#endif } rejectmatrix = Z_Calloc(allocsize, PU_LEVEL, NULL); // allocate memory for the reject matrix diff --git a/src/p_setup.h b/src/p_setup.h index c5ad15d44..1d986d925 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -114,6 +114,9 @@ size_t P_PrecacheLevelFlats(void); void P_AllocMapHeader(INT16 i); +void P_PrintCorruptMapWarnings(void); +void P_FreeCorruptMapWarnings(void); + #ifdef __cplusplus } // extern "C" #endif From 593540a3f9c73731847ce2a3fea5d8ca8db472ec Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jun 2026 20:56:53 +0200 Subject: [PATCH 407/589] add flag "COMPAT_VANILLA" undefine to enable features that are not vanilla compatible --- src/doomdef.h | 11 +++++++++++ src/p_spec.c | 2 ++ src/p_tick.c | 2 ++ 3 files changed, 15 insertions(+) diff --git a/src/doomdef.h b/src/doomdef.h index 69347f05a..69c072827 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -602,6 +602,9 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! +// undefine to enable fixes and features that are not vanilla compatible +#define COMPAT_VANILLA + //-- SATURN __ /// Detect if a client is on Saturn in the clientconfig. /// To seperately allow them to join or block joining from vanilla clients. @@ -666,6 +669,14 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #undef UPDATE_ALERT #endif +// overwrite some of those +// when not compiling in vanilla compat mode +#ifndef COMPAT_VANILLA + #define SATURNJOIN + #define SATURNPAK + #undef SEENAMES +#endif + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/p_spec.c b/src/p_spec.c index 032fdbfbd..38b075feb 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4609,11 +4609,13 @@ void P_UpdateSpecials(void) // POINT LIMIT P_CheckPointLimit(); +#ifdef COMPAT_VANILLA // Dynamic slopeness // we run this here only when not joined midrace // for vanilla compat reasons :chaosleep: if (!midgamejoin) P_RunDynamicSlopes(); +#endif P_UpdateAnimFlats(); } diff --git a/src/p_tick.c b/src/p_tick.c index 3692f9205..d0d25be69 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -646,7 +646,9 @@ void P_Ticker(boolean run) if (run) { // Dynamic slopeness +#ifdef COMPAT_VANILLA if (midgamejoin) // only run here if we joined midgame to fix some desynchs +#endif P_RunDynamicSlopes(); PS_START_TIMING(ps_thinkertime); From cabd8baae5555c1753a6f92528dd130cbfa6d52f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:13:39 +0200 Subject: [PATCH 408/589] some P_MobjWasRemoved for non COMPAT_VANILLA builds --- src/k_kart.c | 12 ++++++++++-- src/p_inter.c | 11 +++++++++-- src/p_mobj.c | 26 ++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index cb4641849..c27c8ad73 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4693,7 +4693,11 @@ void K_RepairOrbitChain(mobj_t *orbit) } // Then recount to make sure item amount is correct - if (orbit->target && orbit->target->player) // !P_MobjWasRemoved(orbit->target) +#ifndef COMPAT_VANILLA + if (!P_MobjWasRemoved(orbit->target) && orbit->target->player) +#else + if (orbit->target && orbit->target->player) +#endif { INT32 num = 0; @@ -4710,7 +4714,11 @@ void K_RepairOrbitChain(mobj_t *orbit) prev->movedir = num; } - if (orbit->target) // !P_MobjWasRemoved(orbit->target) +#ifndef COMPAT_VANILLA + if (!P_MobjWasRemoved(orbit->target)) +#else + if (orbit->target) +#endif orbit->target->player->kartstuff[k_itemamount] = num; } } diff --git a/src/p_inter.c b/src/p_inter.c index 76e4d2e8b..48961c229 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1466,8 +1466,11 @@ static void P_UpdateRemovedOrbital(mobj_t *target, mobj_t *inflictor, mobj_t *so { // SRB2kart // I wish I knew a better way to do this - //if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) +#ifndef COMPAT_VANILLA + if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) +#else if (target->target && target->target->player && target->target->player->mo) +#endif { if (target->target->player->kartstuff[k_eggmanheld] && target->type == MT_EGGMANITEM_SHIELD) target->target->player->kartstuff[k_eggmanheld] = 0; @@ -1480,7 +1483,11 @@ static void P_UpdateRemovedOrbital(mobj_t *target, mobj_t *inflictor, mobj_t *so { if (target->movedir != 0 && target->movedir < (UINT16)target->target->player->kartstuff[k_itemamount]) { - if (target->target->hnext) // !P_MobjWasRemoved(target->target->hnext)) +#ifndef COMPAT_VANILLA + if (!P_MobjWasRemoved(target->target->hnext)) +#else + if (target->target->hnext) +#endif K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; diff --git a/src/p_mobj.c b/src/p_mobj.c index 5e33a9803..b885e76dd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3372,7 +3372,11 @@ static void P_PlayerMobjThinker(mobj_t *mobj) I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); +#ifndef COMPAT_VANILLA + if (P_MobjWasRemoved(mobj)) +#else if (!mobj) +#endif return; P_MobjCheckWater(mobj); @@ -5614,7 +5618,11 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale) player_t *player; fixed_t oldscale; +#ifndef COMPAT_VANILLA + if (P_MobjWasRemoved(mobj)) +#else if (!mobj) +#endif return; oldscale = mobj->scale; //keep for adjusting stuff below @@ -8962,7 +8970,11 @@ static boolean P_FuseThink(mobj_t *mobj) static boolean P_MobjPushableThink(mobj_t *mobj) { // would be cool if we could use P_MobjWasRemoved Zzz... +#ifndef COMPAT_VANILLA + if (P_MobjWasRemoved(mobj)) +#else if (!mobj) +#endif return false; P_MobjCheckWater(mobj); @@ -9168,8 +9180,11 @@ void P_MobjThinker(mobj_t *mobj) { P_TryMove(mobj, mobj->x, mobj->y, true); // Sets mo->standingslope correctly - //if (P_MobjWasRemoved(mobj)) +#ifndef COMPAT_VANILLA + if (P_MobjWasRemoved(mobj)) // anything that calls checkposition can be lethal +#else if (!mobj) // anything that calls checkposition can be lethal +#endif return; P_ButteredSlope(mobj); @@ -9197,8 +9212,11 @@ void P_MobjThinker(mobj_t *mobj) } } - //if (P_MobjWasRemoved(mobj)) +#ifndef COMPAT_VANILLA + if (P_MobjWasRemoved(mobj)) +#else if (!mobj) +#endif return; // obligatory paranoia check // Can end up here if a player dies. @@ -9258,7 +9276,11 @@ void P_PushableThinker(mobj_t *mobj) I_Assert(!P_MobjWasRemoved(mobj)); +#ifndef COMPAT_VANILLA + if (P_MobjWasRemoved(mobj)) +#else if (!mobj) +#endif return; sec = mobj->subsector->sector; From 7c84dd56613f5969e04fdf14857a5d4cc1109a0e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:40:32 +0200 Subject: [PATCH 409/589] raise NUMMOBJFREESLOTS to 4096 on non vanilla compat build --- src/info.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/info.h b/src/info.h index c84d63214..59dd2daca 100644 --- a/src/info.h +++ b/src/info.h @@ -452,7 +452,11 @@ void A_SpawnFreshCopy(void *actor); extern boolean actionsoverridden[NUMACTIONS]; // ratio of states to sprites to mobj types is roughly 6 : 1 : 1 +#ifdef COMPAT_VANILLA #define NUMMOBJFREESLOTS 1024 +#else +#define NUMMOBJFREESLOTS 4096 // should be sufficient +#endif #define NUMSPRITEFREESLOTS NUMMOBJFREESLOTS #define NUMSTATEFREESLOTS (NUMMOBJFREESLOTS*8) From 2c8099e2283f3db976817f35374bfbd3948dfefe Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jun 2026 23:41:13 +0200 Subject: [PATCH 410/589] make builds with more than 16 players undefine COMPAT_VANILLA --- src/doomdef.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/doomdef.h b/src/doomdef.h index 69c072827..d4c9d63fa 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -604,6 +604,10 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // undefine to enable fixes and features that are not vanilla compatible #define COMPAT_VANILLA +// if we build with 32 player (or more!) support we dont need to care vanilla compat +#if MAXPLAYERS > 16 +#undef COMPAT_VANILLA +#endif //-- SATURN __ /// Detect if a client is on Saturn in the clientconfig. From f6d3ab1f3a74837c40b67dfcadddaabb36aa3037 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jun 2026 21:02:34 +0200 Subject: [PATCH 411/589] more random style cleanup had those lying around in lugstuff branch --- src/d_clisrv.c | 2 +- src/d_netcmd.c | 5 +- src/g_demo.c | 111 ++++++++++---------- src/hu_stuff.c | 2 +- src/k_kart.c | 2 +- src/lua_hudlib.c | 21 ++-- src/p_floor.c | 4 +- src/p_inter.c | 25 +++-- src/p_map.c | 12 ++- src/p_mobj.c | 266 +++++++++++++++++++++++++---------------------- src/p_setup.c | 4 +- src/p_spec.c | 1 + 12 files changed, 248 insertions(+), 207 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index cabbc1227..8ad162f6e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4798,7 +4798,7 @@ void CL_RemoveSplitscreenPlayer(UINT8 p) // is there a game running boolean Playing(void) { - return (server && serverrunning) || (client && cl_mode == CL_CONNECTED); + return ((server && serverrunning) || (client && cl_mode == CL_CONNECTED)); } boolean SV_SpawnServer(void) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 61ba54002..ecb90f224 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1550,8 +1550,8 @@ static void SendNameAndColor(UINT8 splitplayer) // TODO: make those cvars arrays consvar_t *playercolor, *playername, *playerskin; consvar_t *colorvars[] = {&cv_playercolor, &cv_playercolor2, &cv_playercolor3, &cv_playercolor4}; - consvar_t *namevars[] = {&cv_playername, &cv_playername2, &cv_playername3, &cv_playername4}; - consvar_t *skinvars[] = {&cv_skin, &cv_skin2, &cv_skin3, &cv_skin4}; + consvar_t *namevars[] = {&cv_playername, &cv_playername2, &cv_playername3, &cv_playername4}; + consvar_t *skinvars[] = {&cv_skin, &cv_skin2, &cv_skin3, &cv_skin4}; playercolor = colorvars[splitplayer]; playername = namevars[splitplayer]; @@ -5490,7 +5490,6 @@ static void Name_OnChange(void) } SendNameAndColor(0); - } static void Name2_OnChange(void) diff --git a/src/g_demo.c b/src/g_demo.c index de6a1bb5d..1123aed69 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -447,7 +447,8 @@ void G_WriteDemoExtraData(void) { static UINT8 timeout = 0; - if (timeout) timeout--; + if (timeout) + timeout--; if (demo_writerng == 1 || (demo_writerng == 2 && timeout == 0)) { @@ -467,6 +468,7 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) if (!demobuf.p || !demo.deferstart) return; + ziptic = READUINT8(demobuf.p); if (ziptic & ZT_FWD) @@ -488,11 +490,12 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) // what in the actual fuck is this??? // SRB2kart: Copy-pasted from ticcmd building, removes that crappy demo cam - if (((players[displayplayers[0]].mo && players[displayplayers[0]].speed > 0) // Moving + const player_t *player = &players[displayplayers[0]]; + if (((player->mo && player->speed > 0) // Moving || (leveltime > starttime && (cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE)) // Rubber-burn turn - || (players[displayplayers[0]].kartstuff[k_respawn]) // Respawning - || (players[displayplayers[0]].spectator || objectplacing)) // Not a physical player - && !(players[displayplayers[0]].kartstuff[k_spinouttimer] && players[displayplayers[0]].kartstuff[k_sneakertimer])) // Spinning and boosting cancels out spinout + || (player->kartstuff[k_respawn]) // Respawning + || (player->spectator || objectplacing)) // Not a physical player + && !(player->kartstuff[k_spinouttimer] && player->kartstuff[k_sneakertimer])) // Spinning and boosting cancels out spinout localangle[0] += (cmd->angleturn<<16); if (!(demoflags & DF_GHOST) && *demobuf.p == DEMOMARKER) @@ -1344,7 +1347,7 @@ fadeghost: } else { - mobj = P_SpawnMobj(g->mo->x, g->mo->y, g->mo->z - FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK); + mobj = P_SpawnMobj(g->mo->x, g->mo->y, g->mo->z - FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height, 3*FRACUNIT), MT_THOK); mobj->sprite = states[mobjinfo[type].spawnstate].sprite; mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<tics = -1; // nope. @@ -1518,7 +1521,9 @@ void G_PreviewRewind(tic_t previewtime) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + player_t *player = &players[i]; + + if (!playeringame[i] || player->spectator) { if (info->playerinfo[i].player.mo) { @@ -1530,35 +1535,35 @@ void G_PreviewRewind(tic_t previewtime) if (!info->playerinfo[i].ingame || !info->playerinfo[i].player.mo) { - if (players[i].mo) - players[i].mo->flags2 |= MF2_DONTDRAW; + if (player->mo) + player->mo->flags2 |= MF2_DONTDRAW; continue; } - if (!players[i].mo) + if (!player->mo) continue; //@TODO spawn temp object to act as a player display - players[i].mo->flags2 &= ~MF2_DONTDRAW; + player->mo->flags2 &= ~MF2_DONTDRAW; - P_UnsetThingPosition(players[i].mo); + P_UnsetThingPosition(player->mo); #define TWEEN(pr) info->playerinfo[i].mobj.pr + FixedMul((INT32) (next_info->playerinfo[i].mobj.pr - info->playerinfo[i].mobj.pr), tweenvalue) - players[i].mo->x = TWEEN(x); - players[i].mo->y = TWEEN(y); - players[i].mo->z = TWEEN(z); - players[i].mo->angle = TWEEN(angle); + player->mo->x = TWEEN(x); + player->mo->y = TWEEN(y); + player->mo->z = TWEEN(z); + player->mo->angle = TWEEN(angle); #undef TWEEN - P_SetThingPosition(players[i].mo); + P_SetThingPosition(player->mo); - players[i].frameangle = info->playerinfo[i].player.frameangle + FixedMul((INT32) (next_info->playerinfo[i].player.frameangle - info->playerinfo[i].player.frameangle), tweenvalue); + player->frameangle = info->playerinfo[i].player.frameangle + FixedMul((INT32) (next_info->playerinfo[i].player.frameangle - info->playerinfo[i].player.frameangle), tweenvalue); - players[i].mo->sprite = info->playerinfo[i].mobj.sprite; - players[i].mo->frame = info->playerinfo[i].mobj.frame; + player->mo->sprite = info->playerinfo[i].mobj.sprite; + player->mo->frame = info->playerinfo[i].mobj.frame; - players[i].realtime = info->playerinfo[i].player.realtime; + player->realtime = info->playerinfo[i].player.realtime; for (j = 0; j < NUMKARTSTUFF; j++) - players[i].kartstuff[j] = info->playerinfo[i].player.kartstuff[j]; + player->kartstuff[j] = info->playerinfo[i].player.kartstuff[j]; } for (i = splitscreen; i >= 0; i--) @@ -1691,7 +1696,7 @@ void G_BeginRecording(void) return; } - memset(name,0,sizeof(name)); + memset(name, 0, sizeof(name)); demobuf.p = demobuf.buffer; demoflags = DF_GHOST|(multiplayer ? DF_MULTIPLAYER : (modeattacking<standings[count].skin = UINT8_MAX; @@ -2353,12 +2358,12 @@ void G_LoadDemoInfo(menudemo_t *pdemo) } // Color - memcpy(temp,extrainfo_p,16); + memcpy(temp, extrainfo_p, 16); extrainfo_p += 16; for (i = 0; i < MAXSKINCOLORS; i++) { - if (fasticmp(KartColor_Names[i],temp)) // SRB2kart + if (fasticmp(KartColor_Names[i], temp)) // SRB2kart { pdemo->standings[count].color = i; break; @@ -2827,15 +2832,15 @@ void G_DoPlayDemo(char *defdemoname) if (demo.version == 0x0001) { // Player name - memcpy(player_names[0],demobuf.p,16); + memcpy(player_names[0], demobuf.p, 16); demobuf.p += 16; // Skin - memcpy(skin,demobuf.p,16); + memcpy(skin, demobuf.p, 16); demobuf.p += 16; // Color - memcpy(color,demobuf.p,16); + memcpy(color, demobuf.p, 16); demobuf.p += 16; demobuf.p += 5; // Backwards compat - some stats @@ -2868,7 +2873,7 @@ void G_DoPlayDemo(char *defdemoname) // Set color for (i = 0; i < MAXSKINCOLORS; i++) { - if (fasticmp(KartColor_Names[i],color)) // SRB2kart + if (fasticmp(KartColor_Names[i], color)) // SRB2kart { players[0].skincolor = i; break; @@ -2888,9 +2893,9 @@ void G_DoPlayDemo(char *defdemoname) return; } - memset(&oldcmd,0,sizeof(oldcmd)); - memset(&oldghost,0,sizeof(oldghost)); - memset(&ghostext,0,sizeof(ghostext)); + memset(&oldcmd, 0, sizeof(oldcmd)); + memset(&oldghost, 0, sizeof(oldghost)); + memset(&ghostext, 0, sizeof(ghostext)); CONS_Alert(CONS_WARNING, M_GetText("Demo version does not match game version. Desyncs may occur.\n")); @@ -2994,16 +2999,16 @@ void G_DoPlayDemo(char *defdemoname) players[p].spectator = spectator; // Name - memcpy(player_names[p],demobuf.p,16); + memcpy(player_names[p], demobuf.p, 16); demobuf.p += 16; // Skin - memcpy(skin,demobuf.p,16); + memcpy(skin, demobuf.p, 16); demobuf.p += 16; SetPlayerSkin(p, skin); // Color - memcpy(color,demobuf.p,16); + memcpy(color, demobuf.p, 16); demobuf.p += 16; for (i = 0; i < MAXSKINCOLORS; i++) @@ -3221,15 +3226,15 @@ void G_AddGhost(char *defdemoname) if (ghostversion == 0x0001) { // Player name (TODO: Display this somehow if it doesn't match cv_playername!) - memcpy(name, p,16); + memcpy(name, p, 16); p += 16; // Skin - memcpy(skin, p,16); + memcpy(skin, p, 16); p += 16; // Color - memcpy(color, p,16); + memcpy(color, p, 16); p += 16; // Ghosts do not have a player structure to put this in. @@ -3381,7 +3386,7 @@ void G_AddGhost(char *defdemoname) for (i = 0; i < MAXSKINCOLORS; i++) { - if (fasticmp(KartColor_Names[i],color)) // SRB2kart + if (fasticmp(KartColor_Names[i], color)) // SRB2kart { gh->mo->color = (UINT8)i; break; @@ -3473,7 +3478,7 @@ void G_UpdateStaffGhostName(lumpnum_t l) if (ghostversion == 0x0001) { // Player name - memcpy(dummystaffname, p,16); + memcpy(dummystaffname, p, 16); dummystaffname[16] = '\0'; return; // Not really a failure but whatever } diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 2c509080b..82b0a74af 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -966,7 +966,7 @@ void HU_Ticker(void) size_t i = 0; // handle spam while we're at it: - for(; (i < MAXPLAYERS); i++) + for (; (i < MAXPLAYERS); i++) { if (stop_spamming[i] > 0) stop_spamming[i]--; diff --git a/src/k_kart.c b/src/k_kart.c index c27c8ad73..e30496716 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4629,7 +4629,7 @@ void K_DropRocketSneaker(player_t *player) while ((shoe = shoe->hnext) && !P_MobjWasRemoved(shoe)) { if (shoe->type != MT_ROCKETSNEAKER) - return; //woah, not a rocketsneaker, bail! safeguard in case this gets used when you're holding non-rocketsneakers + return; // woah, not a rocketsneaker, bail! safeguard in case this gets used when you're holding non-rocketsneakers shoe->flags2 &= ~MF2_DONTDRAW; shoe->flags &= ~MF_NOGRAVITY; diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 444733097..78a7a5e19 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -644,20 +644,22 @@ static int libd_drawScaled(lua_State *L) // KART: draw patch on minimap from x, y coordinates on the map static int libd_drawOnMinimap(lua_State *L) { - fixed_t x, y, scale; // coordinates of the object - patch_t *patch; // patch we want to draw - UINT8 *colormap = NULL; // do we want to colormap this patch? - boolean centered; // the patch is centered and doesn't need readjusting on x/y coordinates. + fixed_t x, y, scale; // coordinates of the object + patch_t *patch; // patch we want to draw + UINT8 *colormap = NULL; // do we want to colormap this patch? + boolean centered; // the patch is centered and doesn't need readjusting on x/y coordinates. huddrawlist_h list; - patch_t *AutomapPic = NULL; drawinfo_t info; + // variables used to replicate k_kart's mmap drawer: + patch_t *AutomapPic; + // variables used for actually drawing the icon: INT32 splitflags, minimaptrans; fixed_t amnumxpos, amnumypos; fixed_t amxpos, amypos; INT32 mm_x, mm_y; - fixed_t patchw = 0, patchh = 0; + fixed_t patchw, patchh; HUDONLY // only run this function in hud hooks @@ -722,8 +724,11 @@ static int libd_drawOnMinimap(lua_State *L) mm_y -= AutomapPic->topoffset; - // patch is supposedly already centered, don't butt in. - if (!centered) + if (centered) + { + patchw = patchh = 0; // patch is supposedly already centered, don't butt in. + } + else { // scale patch coords patchw = (patch->width * scale / 2); diff --git a/src/p_floor.c b/src/p_floor.c index 29f872745..5417029e4 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2338,7 +2338,7 @@ void T_RaiseSector(levelspecthink_t *raise) fixed_t origspeed = raise->vars[3]; // Slow down as you get closer to the bottom - raise->vars[3] = FixedMul(raise->vars[3],FixedDiv(raise->sector->ceilingheight - raise->vars[7], (raise->vars[5] - raise->vars[7])>>5)); + raise->vars[3] = FixedMul(raise->vars[3], FixedDiv(raise->sector->ceilingheight - raise->vars[7], (raise->vars[5] - raise->vars[7])>>5)); if (raise->vars[3] <= origspeed/16) raise->vars[3] = origspeed/16; @@ -2349,7 +2349,7 @@ void T_RaiseSector(levelspecthink_t *raise) { fixed_t origspeed = raise->vars[3]; // Slow down as you get closer to the top - raise->vars[3] = FixedMul(raise->vars[3],FixedDiv(raise->vars[5] - raise->sector->ceilingheight, (raise->vars[5] - raise->vars[7])>>5)); + raise->vars[3] = FixedMul(raise->vars[3], FixedDiv(raise->vars[5] - raise->sector->ceilingheight, (raise->vars[5] - raise->vars[7])>>5)); if (raise->vars[3] <= origspeed/16) raise->vars[3] = origspeed/16; diff --git a/src/p_inter.c b/src/p_inter.c index 48961c229..a2948d01b 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1701,7 +1701,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) else prandom = P_RandomKey(5); // No placable object, just use a random number. - switch(prandom) + switch (prandom) { default: item = MT_BUNNY; break; case 1: item = MT_BIRD; break; @@ -2245,16 +2245,26 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; // well no clue but this may happen ig - if (!target || (target->health <= 0)) +#ifndef COMPAT_VANILLA + if (P_MobjWasRemoved(target)) +#else + if (!target) +#endif + return false; + + if (target->health <= 0) return false; // Spectator handling if (netgame) { - if (damage == DMG_SPECTATOR && target->player && target->player->spectator) - damage = DMG_INSTAKILL; - else if (target->player && target->player->spectator) - return false; + if (target->player && target->player->spectator) + { + if (damage == DMG_SPECTATOR) + damage = DMG_INSTAKILL; + else + return false; + } if (source && source->player && source->player->spectator) return false; @@ -2360,6 +2370,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da { if (source == target) return false; // Don't hit yourself with your own paraloop, baka + if (source && source->player && !cv_friendlyfire.value && (gametype == GT_COOP || (G_GametypeHasTeams() && target->player->ctfteam == source->player->ctfteam))) @@ -2409,7 +2420,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da else if (player->kartstuff[k_invincibilitytimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->powers[pw_flashing]) { - if (!force) // shoulddamage bypasses all of that. + if (!force) // shoulddamage bypasses all of that. { K_DoInstashield(player); return false; diff --git a/src/p_map.c b/src/p_map.c index e4a7323ca..08444f4cd 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -719,11 +719,11 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->type != MT_PLAYER) return true; - if (thing->player && thing->player->powers[pw_flashing]) - return true; - - if (thing->type == MT_PLAYER && thing->player) + if (thing->player) { + if (thing->player->powers[pw_flashing]) + return true; + if (tmthing->state == &states[S_MINEEXPLOSION1]) K_ExplodePlayer(thing->player, tmthing->target, tmthing); else @@ -1077,6 +1077,7 @@ static boolean PIT_CheckThing(mobj_t *thing) thing->momy -= FixedMul(PUSHACCEL, thing->scale); tmthing->momy += FixedMul(PUSHACCEL, thing->scale); } + if (tmthing->momx > 0 && tmthing->momx > FixedMul(4*FRACUNIT, thing->scale) && tmthing->momx > thing->momx) { @@ -1094,6 +1095,7 @@ static boolean PIT_CheckThing(mobj_t *thing) thing->momx = FixedMul(thing->info->speed, thing->scale); else if (thing->momx < -FixedMul(thing->info->speed, thing->scale)) thing->momx = -FixedMul(thing->info->speed, thing->scale); + if (thing->momy > FixedMul(thing->info->speed, thing->scale)) thing->momy = FixedMul(thing->info->speed, thing->scale); else if (thing->momy < -FixedMul(thing->info->speed, thing->scale)) @@ -1105,6 +1107,7 @@ static boolean PIT_CheckThing(mobj_t *thing) tmthing->momx = FixedMul(4*FRACUNIT, thing->scale); else if (tmthing->momx < FixedMul(-4*FRACUNIT, thing->scale)) tmthing->momx = FixedMul(-4*FRACUNIT, thing->scale); + if (tmthing->momy > FixedMul(4*FRACUNIT, thing->scale)) tmthing->momy = FixedMul(4*FRACUNIT, thing->scale); else if (tmthing->momy < FixedMul(-4*FRACUNIT, thing->scale)) @@ -1126,6 +1129,7 @@ static boolean PIT_CheckThing(mobj_t *thing) P_TouchSpecialThing(thing, tmthing, true); // can remove thing return true; } + // check again for special pickup if (tmthing->flags & MF_SPECIAL && thing->player) { diff --git a/src/p_mobj.c b/src/p_mobj.c index b885e76dd..5d4a1bd6c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1249,7 +1249,6 @@ static void P_PushableCheckBustables(mobj_t *mo) if (rover->master->frontsector->crumblestate) continue; - topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); // Height checks @@ -1261,29 +1260,34 @@ static void P_PushableCheckBustables(mobj_t *mo) if (mo->z+mo->height > bottomheight) continue; } - else if (rover->flags & FF_SPINBUST) - { - if (mo->z+mo->momz > topheight) - continue; - - if (mo->z+mo->height < bottomheight) - continue; - } - else if (rover->flags & FF_SHATTER) - { - if (mo->z+mo->momz > topheight) - continue; - - if (mo->z+mo->momz + mo->height < bottomheight) - continue; - } else { - if (mo->z >= topheight) - continue; + topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); - if (mo->z+mo->height < bottomheight) - continue; + if (rover->flags & FF_SPINBUST) + { + if (mo->z+mo->momz > topheight) + continue; + + if (mo->z+mo->height < bottomheight) + continue; + } + else if (rover->flags & FF_SHATTER) + { + if (mo->z+mo->momz > topheight) + continue; + + if (mo->z+mo->momz + mo->height < bottomheight) + continue; + } + else + { + if (mo->z >= topheight) + continue; + + if (mo->z+mo->height < bottomheight) + continue; + } } EV_CrumbleChain(node->m_sector, rover); @@ -2950,7 +2954,8 @@ void P_MobjCheckWater(mobj_t *mobj) if ((mobj->eflags & MFE_VERTICALFLIP) && mobj->ceilingz-mobj->waterbottom <= FixedMul(mobj->info->height, mobj->scale)>>1) return; - if ((mobj->eflags & MFE_GOOWATER || wasingoo)) { // Decide what happens to your momentum when you enter/leave goopy water. + if ((mobj->eflags & MFE_GOOWATER || wasingoo)) // Decide what happens to your momentum when you enter/leave goopy water. + { if (P_MobjFlip(mobj)*mobj->momz < 0) // You are entering the goo? mobj->momz = FixedMul(mobj->momz, FixedDiv(2*FRACUNIT, 5*FRACUNIT)); // kill momentum significantly, to make the goo feel thick. } @@ -2964,6 +2969,7 @@ void P_MobjCheckWater(mobj_t *mobj) { // Spawn a splash mobj_t *splish; + if (mobj->eflags & MFE_VERTICALFLIP) { splish = P_SpawnMobj(mobj->x, mobj->y, mobj->waterbottom-FixedMul(mobjinfo[MT_SPLISH].height, mobj->scale), MT_SPLISH); @@ -2972,6 +2978,7 @@ void P_MobjCheckWater(mobj_t *mobj) } else splish = P_SpawnMobj(mobj->x, mobj->y, mobj->watertop, MT_SPLISH); + splish->destscale = mobj->scale; P_SetScale(splish, mobj->scale); } @@ -5165,9 +5172,9 @@ static void P_Boss9Thinker(mobj_t *mobj) { // Stunned after vector form if (mobj->movedir > ANGLE_180) - mobj->angle -= FixedAngle(FixedMul(AngleFixed(InvAngle(mobj->movedir)),FixedDiv(mobj->reactiontime<angle -= FixedAngle(FixedMul(AngleFixed(InvAngle(mobj->movedir)), FixedDiv(mobj->reactiontime<angle += FixedAngle(FixedMul(AngleFixed(mobj->movedir),FixedDiv(mobj->reactiontime<angle += FixedAngle(FixedMul(AngleFixed(mobj->movedir), FixedDiv(mobj->reactiontime<reactiontime--; @@ -5209,99 +5216,99 @@ static void P_Boss9Thinker(mobj_t *mobj) // It's time to attack! What are we gonna do?! switch(mobj->movecount) { - case 0: - default: - // Fly up and prepare for an attack! - // We have to charge up first, so let's go up into the air - P_SetMobjState(mobj, mobj->info->raisestate); - if (mobj->floorz >= mobj->target->floorz) - mobj->watertop = mobj->floorz + 256*FRACUNIT; - else - mobj->watertop = mobj->target->floorz + 256*FRACUNIT; - break; - - case 1: - { - // Okay, we're up? Good, time to gather energy... - if (mobj->health > mobj->info->damage) - { // No more bubble if we're broken (pinch phase) - mobj_t *shield = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_MSSHIELD_FRONT); - P_SetTarget(&mobj->tracer, shield); - P_SetTarget(&shield->target, mobj); - } - else - P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); - mobj->fuse = 4*TICRATE; - mobj->flags |= MF_PAIN; - if (mobj->info->attacksound) - S_StartSound(mobj, mobj->info->attacksound); - A_FaceTarget(mobj); - break; - } - - case 2: - // We're all charged and ready now! Unleash the fury!! - if (mobj->health > mobj->info->damage) - { - mobj_t *removemobj = mobj->tracer; - P_SetTarget(&mobj->tracer, mobj->hnext); - P_RemoveMobj(removemobj); - } - if (mobj->health <= mobj->info->damage) - { - // Attack 1: Pinball dash! - if (mobj->health == 1) - mobj->movedir = 0; + case 0: + default: + // Fly up and prepare for an attack! + // We have to charge up first, so let's go up into the air + P_SetMobjState(mobj, mobj->info->raisestate); + if (mobj->floorz >= mobj->target->floorz) + mobj->watertop = mobj->floorz + 256*FRACUNIT; else - mobj->movedir = 2; - if (mobj->info->seesound) - S_StartSound(mobj, mobj->info->seesound); - P_SetMobjState(mobj, mobj->info->seestate); - if (mobj->movedir == 2) - mobj->threshold = 16; // bounce 16 times - else - mobj->threshold = 32; // bounce 32 times - mobj->watertop = mobj->target->floorz + 16*FRACUNIT; - P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); - } - else + mobj->watertop = mobj->target->floorz + 256*FRACUNIT; + break; + + case 1: { - // Attack 2: Energy shot! - mobj->movedir = 1; - - if (mobj->health >= 8) - mobj->extravalue1 = 0; - else if (mobj->health >= 5) - mobj->extravalue1 = 2; - else if (mobj->health >= 4) - mobj->extravalue1 = 1; - else - mobj->extravalue1 = 3; - - switch(mobj->extravalue1) - { - case 0: // shoot once - case 2: // spread-shot - default: - mobj->threshold = 2; - break; - case 1: // shoot 3 times - mobj->threshold = 3*2; - break; - case 3: // shoot like a goddamn machinegun - mobj->threshold = 8*2; - break; + // Okay, we're up? Good, time to gather energy... + if (mobj->health > mobj->info->damage) + { // No more bubble if we're broken (pinch phase) + mobj_t *shield = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_MSSHIELD_FRONT); + P_SetTarget(&mobj->tracer, shield); + P_SetTarget(&shield->target, mobj); } + else + P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); + mobj->fuse = 4*TICRATE; + mobj->flags |= MF_PAIN; + if (mobj->info->attacksound) + S_StartSound(mobj, mobj->info->attacksound); + A_FaceTarget(mobj); + break; } - break; - case 3: - // Return to idle. - mobj->watertop = mobj->target->floorz + 32*FRACUNIT; - P_SetMobjState(mobj, mobj->info->spawnstate); - mobj->flags &= ~MF_PAIN; - mobj->fuse = 10*TICRATE; - break; + case 2: + // We're all charged and ready now! Unleash the fury!! + if (mobj->health > mobj->info->damage) + { + mobj_t *removemobj = mobj->tracer; + P_SetTarget(&mobj->tracer, mobj->hnext); + P_RemoveMobj(removemobj); + } + if (mobj->health <= mobj->info->damage) + { + // Attack 1: Pinball dash! + if (mobj->health == 1) + mobj->movedir = 0; + else + mobj->movedir = 2; + if (mobj->info->seesound) + S_StartSound(mobj, mobj->info->seesound); + P_SetMobjState(mobj, mobj->info->seestate); + if (mobj->movedir == 2) + mobj->threshold = 16; // bounce 16 times + else + mobj->threshold = 32; // bounce 32 times + mobj->watertop = mobj->target->floorz + 16*FRACUNIT; + P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); + } + else + { + // Attack 2: Energy shot! + mobj->movedir = 1; + + if (mobj->health >= 8) + mobj->extravalue1 = 0; + else if (mobj->health >= 5) + mobj->extravalue1 = 2; + else if (mobj->health >= 4) + mobj->extravalue1 = 1; + else + mobj->extravalue1 = 3; + + switch (mobj->extravalue1) + { + case 0: // shoot once + case 2: // spread-shot + default: + mobj->threshold = 2; + break; + case 1: // shoot 3 times + mobj->threshold = 3*2; + break; + case 3: // shoot like a goddamn machinegun + mobj->threshold = 8*2; + break; + } + } + break; + + case 3: + // Return to idle. + mobj->watertop = mobj->target->floorz + 32*FRACUNIT; + P_SetMobjState(mobj, mobj->info->spawnstate); + mobj->flags &= ~MF_PAIN; + mobj->fuse = 10*TICRATE; + break; } mobj->movecount++; mobj->movecount %= 4; @@ -5319,6 +5326,7 @@ static void P_Boss9Thinker(mobj_t *mobj) // Face your target angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); // absolute angle angle = (angle-mobj->angle); // relative angle + if (angle < ANGLE_180) mobj->angle += angle/8; else @@ -5330,18 +5338,19 @@ static void P_Boss9Thinker(mobj_t *mobj) || mobj->target->player->powers[pw_invulnerability] || mobj->target->player->powers[pw_super])) danger = false; - if (mobj->target->x+mobj->target->radius+abs(mobj->target->momx*2) < mobj->x-mobj->radius) + else if (mobj->target->x+mobj->target->radius+abs(mobj->target->momx*2) < mobj->x-mobj->radius) danger = false; - if (mobj->target->x-mobj->target->radius-abs(mobj->target->momx*2) > mobj->x+mobj->radius) + else if (mobj->target->x-mobj->target->radius-abs(mobj->target->momx*2) > mobj->x+mobj->radius) danger = false; - if (mobj->target->y+mobj->target->radius+abs(mobj->target->momy*2) < mobj->y-mobj->radius) + else if (mobj->target->y+mobj->target->radius+abs(mobj->target->momy*2) < mobj->y-mobj->radius) danger = false; - if (mobj->target->y-mobj->target->radius-abs(mobj->target->momy*2) > mobj->y+mobj->radius) + else if (mobj->target->y-mobj->target->radius-abs(mobj->target->momy*2) > mobj->y+mobj->radius) danger = false; - if (mobj->target->z+mobj->target->height+mobj->target->momz*2 < mobj->z) + else if (mobj->target->z+mobj->target->height+mobj->target->momz*2 < mobj->z) danger = false; - if (mobj->target->z+mobj->target->momz*2 > mobj->z+mobj->height) + else if (mobj->target->z+mobj->target->momz*2 > mobj->z+mobj->height) danger = false; + if (danger) { // An incoming attack is detected! What should we do?! @@ -5349,21 +5358,27 @@ static void P_Boss9Thinker(mobj_t *mobj) mobj->movedir = ANGLE_11hh - FixedAngle(FixedMul(AngleFixed(ANGLE_11hh), FixedDiv((mobj->info->spawnhealth - mobj->health)<info->spawnhealth-1)<movedir = InvAngle(mobj->movedir); + mobj->threshold = 6 + (FixedMul(24<info->spawnhealth - mobj->health)<info->spawnhealth-1)<>FRACBITS); + if (mobj->info->activesound) S_StartSound(mobj, mobj->info->activesound); if (mobj->info->painchance) P_SetMobjState(mobj, mobj->info->painchance); + return; } // Move normally: Approach the player using normal thrust and simulated friction. dist = P_AproxDistance(mobj->x-mobj->target->x, mobj->y-mobj->target->y); + P_Thrust(mobj, R_PointToAngle2(0, 0, mobj->momx, mobj->momy), -3*FRACUNIT/8); + if (dist < 64*FRACUNIT) P_Thrust(mobj, mobj->angle, -4*FRACUNIT); else if (dist > 180*FRACUNIT) P_Thrust(mobj, mobj->angle, FRACUNIT); + mobj->momz += P_AproxDistance(mobj->momx, mobj->momy)/12; // Move up higher the faster you're going. } } @@ -8671,14 +8686,15 @@ static boolean P_MobjRegularThink(mobj_t *mobj) { const angle_t fa = (i*FINEANGLES/16) & FINEMASK; ns = FixedMul(64 * FRACUNIT, mobj->scale); - x = mobj->x + FixedMul(FINESINE(fa),ns); - y = mobj->y + FixedMul(FINECOSINE(fa),ns); + x = mobj->x + FixedMul(FINESINE(fa), ns); + y = mobj->y + FixedMul(FINECOSINE(fa), ns); mo2 = P_SpawnMobj(x, y, z, MT_EXPLODE); ns = FixedMul(16 * FRACUNIT, mobj->scale); - mo2->momx = FixedMul(FINESINE(fa),ns); - mo2->momy = FixedMul(FINECOSINE(fa),ns); + mo2->momx = FixedMul(FINESINE(fa), ns); + mo2->momy = FixedMul(FINECOSINE(fa), ns); } + z -= FixedMul(32*FRACUNIT, mobj->scale); } P_SetMobjState(mobj, mobj->info->deathstate); @@ -8872,9 +8888,9 @@ static void P_IceBlockFuseThink(mobj_t *mobj) for (i = 0; i < 5; i++) { mobj_t *debris = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMK_ICEBLOCK_DEBRIS); - debris->angle = FixedAngle(P_RandomRange(0,360)<angle, P_RandomRange(3,18)*(FRACUNIT/4)); - debris->momz = P_RandomRange(4,8)<angle = FixedAngle(P_RandomRange(0, 360)<angle, P_RandomRange(3, 18)*(FRACUNIT/4)); + debris->momz = P_RandomRange(4, 8)< Date: Mon, 22 Jun 2026 23:10:28 +0200 Subject: [PATCH 412/589] add missing null terminator for player name on server info screen --- src/d_clisrv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8ad162f6e..7fb65d4d3 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1449,6 +1449,7 @@ static void CL_DrawConnectionStatus(void) if (playerinfo[i].node < 255) { strncpy(player_name, playerinfo[i].name, MAXPLAYERNAME); + player_name[MAXPLAYERNAME] = '\0'; // if we get a skin color // try to colourize the player name From 7ea95b44952841561e1136615ab060489bf61057 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 8 Jun 2020 00:08:07 -0400 Subject: [PATCH 413/589] Fix OSX null-pointer-arithmetic error --- src/hardware/r_opengl/r_opengl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index d3136cbfc..071e67f03 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2915,7 +2915,7 @@ void GL_CreateModelVBOs(model_t *model) } } -#define BUFFER_OFFSET(i) ((char*)(i)) +#define BUFFER_OFFSET(i) ((void*)(i)) void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface) { From fbae43f61ad30f297723edfc2d69ca6d280a3436 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jun 2026 00:10:25 +0200 Subject: [PATCH 414/589] move spinoutroll to k_hud hud thing for minimap so should be in there --- src/d_netcmd.h | 1 + src/g_game.h | 1 - src/k_hud.c | 3 +++ src/k_kart.c | 1 - src/r_main.cpp | 1 - 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index d16d2331f..46ec396ec 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -149,6 +149,7 @@ extern consvar_t cv_showminimapnames; extern consvar_t cv_showminimapfinished; extern consvar_t cv_minihead; extern consvar_t cv_showminimapangle; +extern consvar_t cv_spinoutroll; extern consvar_t cv_showlapemblem; diff --git a/src/g_game.h b/src/g_game.h index f1ed7834e..34496534e 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -121,7 +121,6 @@ extern consvar_t cv_sliptideroll; extern consvar_t cv_slamsound; extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; -extern consvar_t cv_spinoutroll; extern consvar_t cv_squishdance, cv_squishdancespeed; diff --git a/src/k_hud.c b/src/k_hud.c index 335e97340..0ad2d3b3f 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -98,6 +98,8 @@ consvar_t cv_showminimapfinished = {"showminimapfinished", "On", CV_SAVE, CV_OnO CV_PossibleValue_t minimapdot_cons_t[NUMMINIMAPDOTSTUFF]; consvar_t cv_showminimapangle = {"showminimapangle", "Off", CV_SAVE, minimapdot_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_spinoutroll = {"spinoutroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + static CV_PossibleValue_t posanim_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}}; consvar_t cv_posanim = {"postitionanimation", "On", CV_SAVE, posanim_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_smallposnum = {"smallpositionnumber", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -231,6 +233,7 @@ void K_RegisterKartHudStuff(void) CV_RegisterVar(&cv_showminimapnames); CV_RegisterVar(&cv_showminimapfinished); CV_RegisterVar(&cv_showminimapangle); + CV_RegisterVar(&cv_spinoutroll); CV_RegisterVar(&cv_showlapemblem); diff --git a/src/k_kart.c b/src/k_kart.c index e30496716..f7a3bdf9e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -67,7 +67,6 @@ static CV_PossibleValue_t sloperoll_cons_t[] = {{0, "Off"}, {1, "Players"}, {2, consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, sloperoll_cons_t, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_sparkroll = {"sparkroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_spinoutroll = {"spinoutroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //hardcode saltyhop mhhm static void saltyhop_onchange(void); diff --git a/src/r_main.cpp b/src/r_main.cpp index cf7df9088..5a7a1d23f 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1598,7 +1598,6 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_sliptideroll); CV_RegisterVar(&cv_sloperolldist); CV_RegisterVar(&cv_sparkroll); - CV_RegisterVar(&cv_spinoutroll); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); From cb8df4c3d005aaefa18bf72621ac38a13366272a Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jun 2026 18:21:04 +0200 Subject: [PATCH 415/589] change how banana rotation throw stuff works noticed sloperoll does not properly work from certain angles so just reset rollangle if needed in K_RollMobjBySlopes since couldnt find a better place tbh --- src/k_kart.c | 31 ++++++++++++++++++++++++++----- src/p_mobj.c | 28 +++++++++++++++------------- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f7a3bdf9e..ad91b76c3 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3510,6 +3510,26 @@ boolean K_ShouldSlopeRoll(mobj_t *mobj) return K_CheckSlopeRollDist(mobj); } +// reset banan and eggbox rollangle when they´re on the ground +// if not cv_bananthrowroll option "+Onground" +static void K_ResetBananaRollangle(mobj_t* mo) +{ + if (cv_bananthrowroll.value != 1) + return; + + if (!mo->rollangle) + return; + + if (mo->type != MT_BANANA && mo->type != MT_EGGMANITEM) + return; + + // only reset if on ground + if (!P_IsObjectOnGround(mo)) + return; + + mo->rollangle = 0; +} + #define SLOPEROLL_DIV 3 void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) { @@ -3523,6 +3543,9 @@ void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) I_Assert(mo->subsector != NULL); I_Assert(mo->subsector->sector != NULL); + // kinda stupid but idk where else to put this + K_ResetBananaRollangle(mo); + if (!K_ShouldSlopeRoll(mo)) { mo->pitch_sprite = mo->roll_sprite = 0; @@ -3944,11 +3967,9 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map if (cv_bananthrowroll.value && (mapthing == MT_BANANA)) { - //mo->angle = FixedAngle(M_RandomRange(-180, 180) << FRACBITS); - if (cv_bananthrowroll.value == 1 && K_CheckSlopeRollDist(mo)) - mo->sloperoll = (angle_t)FixedAngle(M_RandomRange(-180, 180) << FRACBITS); // im lazy but this makes sure the banan goes back to upright when it lands lmao - else if (cv_bananthrowroll.value == 2) - mo->rollangle = (angle_t)FixedAngle(M_RandomRange(-180, 180) << FRACBITS); + const angle_t speen = (angle_t)FixedAngle(M_RandomRange(-180, 180) << FRACBITS); + //mo->angle = speen; + mo->rollangle = speen; } } diff --git a/src/p_mobj.c b/src/p_mobj.c index 5d4a1bd6c..12574c031 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6876,11 +6876,9 @@ static boolean P_MobjDeadThink(mobj_t *mobj) case MT_BANANA: if (cv_bananthrowroll.value) { - //mobj->angle -= spin; - if (cv_bananthrowroll.value == 1 && K_CheckSlopeRollDist(mobj)) - mobj->sloperoll += (angle_t)FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); // im lazy but this makes sure the banan goes back to upright when it lands lmao - else if (cv_bananthrowroll.value == 2) - mobj->rollangle += (angle_t)FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); + const angle_t speen = (angle_t)FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); + //mobj->angle -= speen; + mobj->rollangle += speen; } /* FALLTHRU */ case MT_ORBINAUT: @@ -7190,21 +7188,23 @@ static boolean P_MobjRegularThink(mobj_t *mobj) } case MT_BANANA: case MT_EGGMANITEM: - if (cv_bananthrowroll.value && !P_IsObjectOnGround(mobj)) + { + boolean grounded = P_IsObjectOnGround(mobj); + + if (cv_bananthrowroll.value && !grounded) { // tilt n tumble - //mobj->angle += spin; - - if (cv_bananthrowroll.value == 1 && K_CheckSlopeRollDist(mobj)) - mobj->sloperoll -= (angle_t)FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h); // im lazy but this makes sure the banan goes back to upright when it lands lmao - else if (cv_bananthrowroll.value == 2) - mobj->rollangle -= (angle_t)FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h); + const angle_t speen = (angle_t)FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); + //mobj->angle += speen; + mobj->rollangle -= speen; } mobj->friction = ORIG_FRICTION/4; + if (mobj->momx || mobj->momy) P_SpawnGhostMobj(mobj); - if (P_IsObjectOnGround(mobj) && mobj->health > 1) + + if (grounded && mobj->health > 1) { S_StartSound(mobj, mobj->info->activesound); mobj->momx = mobj->momy = 0; @@ -7215,7 +7215,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (mobj->threshold > 0) mobj->threshold--; + break; + } case MT_SPB: indirectitemcooldown = 20*TICRATE; /* FALLTHRU */ From b1100d6215cd638fc922bdd9bd74f966ba050d19 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jun 2026 18:24:16 +0200 Subject: [PATCH 416/589] add mobj "temprollangle" field same as rollangle but resets at beginning on each tic i dont feel like exposing this to lua atm, so if someone wants to or if even needed at all --- src/hardware/hw_main.cpp | 4 ++-- src/hardware/hw_md2.c | 7 +++---- src/p_mobj.h | 1 + src/p_user.c | 1 + src/r_fps.cpp | 1 + src/r_things.cpp | 10 ++++++---- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index cf5d0fda7..455503cc3 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -4630,7 +4630,7 @@ static void HWR_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE // determine here if sprite should rotate for optimization const boolean sliprollrotate = (cv_sliptideroll.value && (thing->player && thing->player->sliproll)); - const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || sliprollrotate); + const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || thing->temprollangle || sliprollrotate); #endif if (sprframe->rotate != SRF_SINGLE || papersprite @@ -4688,7 +4688,7 @@ static void HWR_ProjectSprite(mobj_t *thing) // this is very messy, but it on-the-fly calculates rotations for all the // pitch and roll variables pitchnroll = R_RotationAngle(ang, camang, &interp); - rollangle = thing->rollangle; + rollangle = (thing->rollangle - thing->temprollangle); if (rollangle || pitchnroll || sliprollrotate) { diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 2aefecea1..4cb8a0a51 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1400,12 +1400,11 @@ void HWR_DrawMD2(gl_vissprite_t *spr) const angle_t sliptideroll = ((cv_sliptideroll.value && spr->mobj->player) ? spr->mobj->player->sliproll : 0); const SINT8 flipfactor = flip ? -1 : 1; + const angle_t thingrollangle = (spr->mobj->rollangle - spr->mobj->temprollangle); - if (spr->mobj->rollangle || sliptideroll) + if (thingrollangle || sliptideroll) { - angle_t rollang = sliptideroll - ? (spr->mobj->rollangle) + (sliptideroll * spr->mobj->player->kartstuff[k_aizdriftstrat]) - : (spr->mobj->rollangle); + angle_t rollang = sliptideroll ? (thingrollangle + (sliptideroll * spr->mobj->player->kartstuff[k_aizdriftstrat])) : thingrollangle; rollang *= flipfactor; diff --git a/src/p_mobj.h b/src/p_mobj.h index 682b2fb1b..c348c925c 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -298,6 +298,7 @@ typedef struct mobj_s angle_t angle, pitch, roll; // orientation angle_t old_angle, old_pitch, old_roll; // orientation interpolation angle_t rollangle; + angle_t temprollangle; // same as rollangle but resets each tic, idk either man. // cba exposing this to lua either spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h UINT16 anim_duration; // for FF_ANIMATE states diff --git a/src/p_user.c b/src/p_user.c index d952e296d..5f13fa018 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1206,6 +1206,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost->pitch = mobj->pitch; ghost->roll = mobj->roll; ghost->rollangle = mobj->rollangle; + ghost->temprollangle = mobj->temprollangle; ghost->sloperoll = mobj->sloperoll; ghost->slopepitch = mobj->slopepitch; diff --git a/src/r_fps.cpp b/src/r_fps.cpp index 8372fa30f..121a0df5f 100644 --- a/src/r_fps.cpp +++ b/src/r_fps.cpp @@ -807,6 +807,7 @@ void R_ResetMobjInterpolationState(mobj_t *mobj) mobj->spriteyscale = mobj->realyscale; mobj->spritexoffset = mobj->realxoffset; mobj->spriteyoffset = mobj->realyoffset; + mobj->temprollangle = 0; mobj->resetinterp = false; } diff --git a/src/r_things.cpp b/src/r_things.cpp index b4707db6f..d891d40ce 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1276,7 +1276,7 @@ static void R_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE // determine here if sprite should rotate for optimization const boolean sliprollrotate = (cv_sliptideroll.value && (thing->player && thing->player->sliproll)); - const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || sliprollrotate); + const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || thing->temprollangle || sliprollrotate); #endif sprskin = K_GetMobjSkin(thing); @@ -1376,16 +1376,18 @@ static void R_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE if (shouldrotate) { + const fixed_t thingrollangle = (thing->rollangle - thing->temprollangle); + if (papersprite) { if (ang >= ANGLE_180) { // Makes Software act much more sane like OpenGL - rollangle = InvAngle(thing->rollangle); + rollangle = InvAngle(thingrollangle); } else { - rollangle = thing->rollangle; + rollangle = thingrollangle; } } else @@ -1393,7 +1395,7 @@ static void R_ProjectSprite(mobj_t *thing) // this is very messy, but it on-the-fly calculates rotations for all the // pitch and roll variables pitchnroll = R_RotationAngle(ang, camang, &interp); - rollangle = thing->rollangle; + rollangle = thingrollangle; } if (rollangle || pitchnroll || sliprollrotate) From ec047151e33eba61d483785846bffaee0196d03d Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jun 2026 19:38:14 +0200 Subject: [PATCH 417/589] toggable stair "jank" visuals akin to RR, just toned down for smaller kart chars also toggable ofc theres not that many stairs in kart but this looks cute with smol bumps in the road wish this would work on slopes but theyre kinda messed up lol --- src/d_player.h | 2 ++ src/g_game.h | 1 + src/g_input.c | 6 ++++++ src/k_kart.c | 17 +++++++++++++++++ src/p_map.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- src/p_slopes.c | 5 +++++ src/p_user.c | 5 +++++ src/r_main.cpp | 1 + 8 files changed, 82 insertions(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index bcecb66a5..e4aded95b 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -566,6 +566,8 @@ typedef struct player_s fixed_t fovadd; // adjust FOV for hw rendering SINT8 driftlevel; // just for controller rumble for now + + UINT8 stairjank; } player_t; #endif diff --git a/src/g_game.h b/src/g_game.h index 34496534e..4f46ef89d 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -118,6 +118,7 @@ extern consvar_t cv_driftsparkpulse; extern consvar_t cv_gravstretch; extern consvar_t cv_sloperoll; extern consvar_t cv_sliptideroll; +extern consvar_t cv_stairjank; extern consvar_t cv_slamsound; extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; diff --git a/src/g_input.c b/src/g_input.c index c72ed6308..fa18272b8 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1139,6 +1139,12 @@ void G_DeviceRumbleTick(void) if (leveltime & 1) // this is actually funny lel high = RUMBLE_MODERATE; } + /*else if ((player->stairjank > 8) // this is kinda cool but prob gets annoying after a while + && player->speed != 0 + && P_IsObjectOnGround(player->mo)) + { + low = high = RUMBLE_WEAK; + }*/ if (player->kartstuff[k_brakedrift]) { diff --git a/src/k_kart.c b/src/k_kart.c index ad91b76c3..e3306c629 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -67,6 +67,7 @@ static CV_PossibleValue_t sloperoll_cons_t[] = {{0, "Off"}, {1, "Players"}, {2, consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, sloperoll_cons_t, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_sparkroll = {"sparkroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_stairjank = {"stairjank", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //hardcode saltyhop mhhm static void saltyhop_onchange(void); @@ -3510,6 +3511,16 @@ boolean K_ShouldSlopeRoll(mobj_t *mobj) return K_CheckSlopeRollDist(mobj); } +static INT32 K_AltFlip(INT32 n, tic_t tics) +{ + return leveltime % (2 * tics) < tics ? n : -(n); +} + +static INT32 K_StairJankFlip(INT32 value) +{ + return K_AltFlip(value, 2); +} + // reset banan and eggbox rollangle when they´re on the ground // if not cv_bananthrowroll option "+Onground" static void K_ResetBananaRollangle(mobj_t* mo) @@ -7053,6 +7064,12 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_RollMobjBySlopes(player->mo, player->mo->standingslope); + // "Stair jank" visuals akin to RR + if (cv_stairjank.value && player->stairjank > 0) + { + player->mo->temprollangle += K_StairJankFlip(ANGLE_11hh / 2 / (17 / player->stairjank)); // TODO: make strength adjustable? + } + //// // Quick Turning diff --git a/src/p_map.c b/src/p_map.c index 08444f4cd..06e666a28 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2375,8 +2375,10 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) fixed_t tryx = thing->x; fixed_t tryy = thing->y; fixed_t radius = thing->radius; - fixed_t thingtop ;//= thing->z + thing->height; + fixed_t thingtop;//= thing->z + thing->height; fixed_t startingonground = P_IsObjectOnGround(thing); + fixed_t stairjank = 0; + pslope_t *oldslope = thing->standingslope; INT32 special = -1; floatok = false; @@ -2450,11 +2452,19 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thingtop = thing->z + thing->height; + const boolean flipped = + (thing->eflags & MFE_VERTICALFLIP) != 0; + // Step up if (thing->z < tmfloorz) { if (tmfloorz - thing->z <= maxstep) { + if (maxstep > 0 && !flipped) + { + stairjank = (tmfloorz - thing->z); + } + thing->z = thing->floorz = tmfloorz; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } @@ -2467,6 +2477,11 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) { if (thingtop - tmceilingz <= maxstep) { + if (maxstep > 0 && flipped) + { + stairjank = (thingtop - tmceilingz); + } + thing->z = ( thing->ceilingz = tmceilingz ) - thing->height; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } @@ -2483,11 +2498,21 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) { + if (flipped) + { + stairjank = (tmceilingz - thingtop); + } + thing->z = (thing->ceilingz = tmceilingz) - thing->height; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep) { + if (!flipped) + { + stairjank = (thing->z - tmfloorz); + } + thing->z = thing->floorz = tmfloorz; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } @@ -2563,6 +2588,25 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else // don't set standingslope if you're not going to clip against it thing->standingslope = NULL; + /* FIXME: slope step down (even up) has some false + positives, so just ignore them entirely. */ + if (stairjank && !oldslope && !thing->standingslope && thing->player && !thing->player->spectator) + { + // TODO: maybe spawn smol dust effect similar to RR? + /*if (!thing->player->stairjank) + { + mobj_t * spark = P_SpawnMobjFromMobj(thing, 0, 0, 0, MT_JANKSPARK); + spark->fuse = 9; + spark->cusval = K_StairJankFlip(ANGLE_90); + P_SetTarget(&spark->target, thing); + P_SetTarget(&spark->owner, thing); + spark->renderflags |= RF_REDUCEVFX; + }*/ + + thing->player->stairjank = 9; + //thing->player->stairjank = 17; + } + thing->x = x; thing->y = y; diff --git a/src/p_slopes.c b/src/p_slopes.c index 6334b2e45..52a262785 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -901,6 +901,11 @@ void P_SlopeLaunch(mobj_t *mo) //CONS_Printf("Launched off of slope.\n"); mo->standingslope = NULL; + + if (mo->player) + { + mo->player->stairjank = 0; // fuck you + } } // Function to help handle landing on slopes diff --git a/src/p_user.c b/src/p_user.c index 5f13fa018..90bca6cff 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5090,6 +5090,11 @@ void P_PlayerThink(player_t *player) player->squishdance.time = 0; } + if (player->stairjank > 0) + { + player->stairjank--; + } + // Flash player after being hit. if (!(player->kartstuff[k_hyudorotimer] // SRB2kart - fixes Hyudoro not flashing when it should. || player->kartstuff[k_growshrinktimer] > 0 // Grow doesn't flash either. diff --git a/src/r_main.cpp b/src/r_main.cpp index 5a7a1d23f..962ccc0a7 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1598,6 +1598,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_sliptideroll); CV_RegisterVar(&cv_sloperolldist); CV_RegisterVar(&cv_sparkroll); + CV_RegisterVar(&cv_stairjank); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); From 6efe56808a8d9f26bb42d55c77985664d4da3b67 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jun 2026 17:43:27 +0200 Subject: [PATCH 418/589] make sky "dome/barreling" toggable per "skydome" cvar using karts old sky code for gl since it appears to differ a bit from srb2 and id want to keep this "authentic" to old kart --- src/hardware/hw_main.cpp | 132 +++++++++++++++++++++++++++++++++++++-- src/r_main.cpp | 2 + src/r_main.h | 1 + src/r_plane.cpp | 9 ++- 4 files changed, 135 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 455503cc3..b9319a63a 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5186,15 +5186,10 @@ void HWR_BuildSkyDome(void) // precompute to save a bit of division static constexpr float FINEDEGREE = (360.0f/static_cast(FINEANGLES)); -static void HWR_DrawSkyBackground(void) +static void HWR_DrawSkyDome(void) { FTransform dometransform; - if (HWR_IsWireframeMode()) - return; - - GL_SetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated); - memcpy(&dometransform, &atransform, sizeof(FTransform)); dometransform.x = dometransform.y = dometransform.z = 0.0; @@ -5219,6 +5214,131 @@ static void HWR_DrawSkyBackground(void) GL_RenderSkyDome(&gl_sky); } +// the following is karts old sky code from before the skydome stuff +// this appears to differ a bit from srb2´s old sky code +static void HWR_DrawSkyTexture(void) +{ + FOutVector v[4]; + angle_t angle; + float dimensionmultiply; + float aspectratio; + float angleturn; + + HWR_GetTexture(texturetranslation[skytexture], false); + + aspectratio = (float)vid.width/(float)vid.height; + + //Hurdler: the sky is the only texture who need 4.0f instead of 1.0 + // because it's called just after clearing the screen + // and thus, the near clipping plane is set to 3.99 + // Sryder: Just use the near clipping plane value then + + // 3--2 + // | /| + // |/ | + // 0--1 + v[0].x = v[3].x = -ZCLIP_PLANE-1; + v[1].x = v[2].x = ZCLIP_PLANE+1; + v[0].y = v[1].y = -ZCLIP_PLANE-1; + v[2].y = v[3].y = ZCLIP_PLANE+1; + + v[0].z = v[1].z = v[2].z = v[3].z = ZCLIP_PLANE+1; + + // X + + // NOTE: This doesn't work right with texture widths greater than 1024 + // software doesn't draw any further than 1024 for skies anyway, but this doesn't overlap properly + // The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture + + //angle = (viewangle + ANGLE_45); + angle = (viewangle + xtoviewangle[0]); + dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->width/256.0f); + + if (atransform.fliptype == TRANSFORM_MIRROR || + atransform.fliptype == TRANSFORM_MIRRORFLIP) + { + angle = InvAngle(angle); + dimensionmultiply *= -1; + } + + v[0].s = v[3].s = ((float)angle / ((float)(ANGLE_90-1)*dimensionmultiply)); + v[2].s = v[1].s = (-1.0f/dimensionmultiply)+((float) angle / ((float)(ANGLE_90-1)*dimensionmultiply)); + + // Y + angle = aimingangle; + dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->height/(128.0f*aspectratio)); + + if (splitscreen == 1) + { + dimensionmultiply *= 2; + angle *= 2; + } + + // Middle of the sky should always be at angle 0 + // need to keep correct aspect ratio with X + if (atransform.fliptype == TRANSFORM_FLIP || + atransform.fliptype == TRANSFORM_MIRRORFLIP) + { + // During vertical flip the sky should be flipped and it's y movement should also be flipped obviously + v[3].t = v[2].t = -(0.5f-(0.5f/dimensionmultiply)); + v[0].t = v[1].t = (-1.0f/dimensionmultiply)-(0.5f-(0.5f/dimensionmultiply)); + } + else + { + v[3].t = v[2].t = (-1.0f/dimensionmultiply)-(0.5f-(0.5f/dimensionmultiply)); + v[0].t = v[1].t = -(0.5f-(0.5f/dimensionmultiply)); + } + + angleturn = (((float)ANGLE_45-1.0f)*aspectratio)*dimensionmultiply; + + if (cv_glshearing.value) + { + // Doesn't really make sense, but what can I do? + angle_t dy = FixedAngle(FixedMul(360*FRACUNIT, FixedDiv(AIMINGTODY(aimingangle), 900*FRACUNIT))); + v[3].t = v[2].t -= ((float) dy / angleturn); + v[0].t = v[1].t -= ((float) dy / angleturn); + } + else + { + if (angle > ANGLE_180) // Do this because we don't want the sky to suddenly teleport when crossing over 0 to 360 and vice versa + { + angle = InvAngle(angle); + v[3].t = v[2].t += ((float) angle / angleturn); + v[0].t = v[1].t += ((float) angle / angleturn); + } + else + { + v[3].t = v[2].t -= ((float) angle / angleturn); + v[0].t = v[1].t -= ((float) angle / angleturn); + } + } + + // since sky is drawn as a "flat quad" this way, we have to unset any view transformations for it to work + GL_SetTransform(NULL); + if (HWR_UseShader()) + { + GL_SetShader(HWR_GetShaderFromTarget(SHADER_SKY)); // not sure if this is needed? + GL_DrawPolygon(NULL, v, 4, 0); + GL_UnSetShader(); + } + else + { + GL_UnSetShader(); + GL_DrawPolygon(NULL, v, 4, 0); + } +} + +static void HWR_DrawSkyBackground(void) +{ + if (HWR_IsWireframeMode()) + return; + + if (cv_skydome.value) + HWR_DrawSkyDome(); + else + HWR_DrawSkyTexture(); +} + // -----------------+ // HWR_ClearView : clear the viewwindow, with maximum z value. also clears stencil buffer. // -----------------+ diff --git a/src/r_main.cpp b/src/r_main.cpp index 962ccc0a7..c4719e2e5 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -188,6 +188,7 @@ consvar_t cv_flipcammode = {"flipcammode", "Displayplayer", CV_SAVE, flipcammod consvar_t cv_shadow = {"shadow", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_shadowoffs = {"offsetshadows", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_skybox = {"skybox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_skydome = {"skydome", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_ffloorclip = {"r_ffloorclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_spriteclip = {"r_spriteclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_softcyancut = {"softwarecyancut", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1564,6 +1565,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_shadow); CV_RegisterVar(&cv_shadowoffs); CV_RegisterVar(&cv_skybox); + CV_RegisterVar(&cv_skydome); CV_RegisterVar(&cv_ffloorclip); CV_RegisterVar(&cv_spriteclip); CV_RegisterVar(&cv_secbright); diff --git a/src/r_main.h b/src/r_main.h index e8b7393e3..3699822a3 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -213,6 +213,7 @@ extern consvar_t cv_translucency; extern consvar_t cv_drawdist, cv_drawdist_precip, cv_lessprecip; extern consvar_t cv_fov, cv_fovchange; extern consvar_t cv_skybox; +extern consvar_t cv_skydome; extern consvar_t cv_tailspickup; extern consvar_t cv_maxinterpdist; extern consvar_t cv_playerfade; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index a6a52fe83..df289faa0 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -785,6 +785,8 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*), drawcolumndata_t dc = {}; const INT32 texture = texturetranslation[skytexture]; + const boolean skydome = cv_skydome.value != 0; + // Reset column drawer function (note: couldn't we just call colfuncs[BASEDRAWFUNC] directly?) // (that is, unless we'll need to switch drawers in future for some reason) R_SetColumnFunc(BASEDRAWFUNC); @@ -830,8 +832,8 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*), INT32 angle = (pl->viewangle + xtoviewangle[x + i])>>ANGLETOSKYSHIFT; angle -= (skytextureoffset >> FRACBITS); - - dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x + i]>>ANGLETOFINESHIFT)); + if (skydome) + dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x + i]>>ANGLETOFINESHIFT)); dc.x = x + i; dc.source = R_GetColumn(texture, -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18 @@ -866,7 +868,8 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*skycolfunc)(drawcolumndata_t*), INT32 angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT; angle -= (skytextureoffset >> FRACBITS); - dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT)); + if (skydome) + dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT)); dc.x = x; dc.source = R_GetColumn(texturetranslation[skytexture], -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18 From f12d5a246d0c49a58819012366dc182e7d74fd3f Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jun 2026 19:54:12 +0200 Subject: [PATCH 419/589] just dont set shader for this ig otherwise this breaks when you disable the hud for whatever reason looks the same so whatever --- src/hardware/hw_main.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index b9319a63a..de48ba6ee 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5315,17 +5315,8 @@ static void HWR_DrawSkyTexture(void) // since sky is drawn as a "flat quad" this way, we have to unset any view transformations for it to work GL_SetTransform(NULL); - if (HWR_UseShader()) - { - GL_SetShader(HWR_GetShaderFromTarget(SHADER_SKY)); // not sure if this is needed? - GL_DrawPolygon(NULL, v, 4, 0); - GL_UnSetShader(); - } - else - { - GL_UnSetShader(); - GL_DrawPolygon(NULL, v, 4, 0); - } + GL_UnSetShader(); + GL_DrawPolygon(NULL, v, 4, 0); } static void HWR_DrawSkyBackground(void) From db4aedf49880d342103e844228b154deb18ce501 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 14:05:32 +0200 Subject: [PATCH 420/589] readd missing setblend for sky bg oopsie forgor to copy this back --- src/hardware/hw_main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index de48ba6ee..485013345 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5324,6 +5324,8 @@ static void HWR_DrawSkyBackground(void) if (HWR_IsWireframeMode()) return; + GL_SetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated); + if (cv_skydome.value) HWR_DrawSkyDome(); else From 948c9399deca0a9a67d7efb37ea0e19bb9a651cc Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 14:08:38 +0200 Subject: [PATCH 421/589] fix HWR_SplitWall again.. theres guards just above this which should just skip shit but for some reason the clamps still do stuff, idk man fixes the weird grass fof in green hill --- src/hardware/hw_main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 485013345..c47fa7d68 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1071,11 +1071,11 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, else solid = false; - height = FixedToFloat(P_GetLightZAt(&list[i], v1x, v1y)); - endheight = FixedToFloat(P_GetLightZAt(&list[i], v2x, v2y)); - if (solid) { + height = FixedToFloat(P_GetLightZAt(&list[i], v1x, v1y)); + endheight = FixedToFloat(P_GetLightZAt(&list[i], v2x, v2y)); + bheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v1x, v1y)); endbheight = FixedToFloat(P_GetFFloorBottomZAt(list[i].caster, v2x, v2y)); @@ -1105,8 +1105,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, // Found a break // The heights are clamped to ensure the polygon doesn't cross itself. - bot = std::max(bheight, realbot); - endbot = std::max(endbheight, endrealbot); + bot = std::clamp(bheight, realbot, top); + endbot = std::clamp(endbheight, endrealbot, endtop); Surf->PolyColor.s.alpha = alpha; @@ -3671,8 +3671,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) // Found a break // The heights are clamped to ensure the polygon doesn't cross itself. - bot = std::max(bheight, realbot); - endbot = std::max(endbheight, endrealbot); + bot = std::clamp(bheight, realbot, top); + endbot = std::clamp(endbheight, endrealbot, endtop); wallVerts[3].t = towtop + ((realtop - top) * towmult); wallVerts[2].t = towtop + ((endrealtop - endtop) * towmult); From 266a4effb77343bb9e2ad3431745fa177a3ca015 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 14:10:25 +0200 Subject: [PATCH 422/589] fix fogblock not accounting for fake contrast super old oopsie lulul --- src/hardware/hw_main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index c47fa7d68..642fdfec7 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1001,8 +1001,9 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, const fixed_t v2y = FloatToFixed(wallVerts[1].z); const UINT8 alpha = Surf->PolyColor.s.alpha; - FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, gl_curline, NULL); + FUINT lightnum = sector->lightlevel; extracolormap_t *colormap = NULL; + lightnum = HWR_CalcWallLight(lightnum, gl_curline, NULL); realtop = top = wallVerts[3].y; realbot = bot = wallVerts[0].y; @@ -2050,11 +2051,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = rover->master->frontsector->lightlevel; colormap = rover->master->frontsector->extra_colormap; + lightnum = HWR_CalcWallLight(lightnum, gl_curline, colormap); Surf.PolyColor.s.alpha = HWR_FogBlockAlpha(lightnum, colormap); - lightnum = HWR_CalcWallLight(lightnum, gl_curline, colormap); - if (other_sector->numlights) HWR_SplitWall(other_sector, wallVerts, 0, false, &Surf, roverflags, rover, blendmode); else From 8aafde4c9d27a74d7038fba61dbfbe821187eff8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 20:05:43 +0200 Subject: [PATCH 423/589] "less" --- src/m_menudefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 0f7b5736d..d56637b7a 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1631,7 +1631,7 @@ static menuitem_t OP_AccessibilityMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Video Color Settings...", &OP_ColorOptionsDef, 30}, {IT_STRING|IT_CVAR, NULL, "Reduce Effects", &cv_reducevfx, 35}, - {IT_STRING|IT_CVAR, NULL, "Midnight Channel Flicker", &cv_lessflicker, 40}, // obsolete now? or still better be a seperate toggle? + {IT_STRING|IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 40}, // obsolete now? or still better be a seperate toggle? {IT_STRING|IT_CVAR, NULL, "Minimum Sector Brightness", &cv_secbright, 45}, From 13dc0db9a997294550225c10010c9da7723d401d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 20:25:06 +0200 Subject: [PATCH 424/589] add stairjank and skydome stuff to menu pls someone gib a better description for skydome idk ingles --- src/m_menudefs.c | 108 ++++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 52 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index d56637b7a..80c87066e 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -555,10 +555,10 @@ static menuitem_t MP_PlayerSetupMenu[] = static menuitem_t MP_ConnectMenu[] = { - {IT_STRING | IT_CVAR, NULL, "Sort By", &cv_serversort, 0}, - {IT_STRING | IT_KEYHANDLER, NULL, "Page", M_HandleServerPage, 8}, - {IT_STRING | IT_CALL, NULL, "Refresh", M_Refresh, 16}, - {IT_STRING | IT_KEYHANDLER, NULL, "", M_HandleServerSearch,25}, + {IT_STRING | IT_CVAR, NULL, "Sort By", &cv_serversort, 0}, + {IT_STRING | IT_KEYHANDLER, NULL, "Page", M_HandleServerPage, 8}, + {IT_STRING | IT_CALL, NULL, "Refresh", M_Refresh, 16}, + {IT_STRING | IT_KEYHANDLER, NULL, "", M_HandleServerSearch, 25}, {IT_STRING | IT_SPACE, NULL, "", M_Connect, 48}, {IT_STRING | IT_SPACE, NULL, "", M_Connect, 60}, @@ -725,29 +725,29 @@ static const char* OP_AllControlsTooltips[sizeof(OP_AllControlsMenu)/sizeof(OP_A // The rest is null, for now }; -#define OP_JOYMENU(pnum) \ - {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, \ - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[pnum] , 15}, \ - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[pnum] , 20}, \ - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[pnum] , 25}, \ - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[pnum] , 30}, \ - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[pnum] , 35}, \ - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[pnum] , 40}, \ - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[pnum] , 45}, \ - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[pnum] , 50}, \ - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[pnum] , 55}, \ - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[pnum] , 60}, \ - {IT_HEADER, NULL, "Camera Controls", NULL, 67}, \ - {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[pnum] , 75}, \ - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[pnum] , 80}, \ - {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[pnum] , 85}, \ - {IT_HEADER, NULL, "Deadzones", NULL, 92}, \ - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[pnum] , 100}, \ - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[pnum] , 105}, \ - {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, \ - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[pnum] , 120}, \ - {IT_STRING | IT_CVAR, NULL, "Controller Rumble Strength" , &cv_rumblestrength[pnum] , 125}, \ - {IT_STRING | IT_CVAR, NULL, "Set LED to Player color" , &cv_gamepadled[pnum] , 130}, +#define OP_JOYMENU(pnum) \ + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, \ + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[pnum] , 15}, \ + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[pnum] , 20}, \ + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[pnum] , 25}, \ + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[pnum] , 30}, \ + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[pnum] , 35}, \ + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[pnum] , 40}, \ + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[pnum] , 45}, \ + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[pnum] , 50}, \ + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[pnum] , 55}, \ + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[pnum] , 60}, \ + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, \ + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[pnum] , 75}, \ + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[pnum] , 80}, \ + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[pnum] , 85}, \ + {IT_HEADER, NULL, "Deadzones", NULL, 92}, \ + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[pnum] , 100}, \ + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[pnum] , 105}, \ + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, \ + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[pnum] , 120}, \ + {IT_STRING | IT_CVAR, NULL, "Controller Rumble Strength" , &cv_rumblestrength[pnum] , 125}, \ + {IT_STRING | IT_CVAR, NULL, "Set LED to Player color" , &cv_gamepadled[pnum] , 130}, static menuitem_t OP_Joystick1Menu[] = { @@ -789,10 +789,9 @@ static menuitem_t OP_JoystickSetMenu[] = static menuitem_t OP_MouseOptionsMenu[] = { {IT_STRING | IT_CVAR, NULL, "Use Mouse", &cv_usemouse, 10}, - {IT_STRING | IT_CVAR, NULL, "Mouse Turning", &cv_mouseturn, 20}, {IT_STRING | IT_CVAR, NULL, "Invert Mouse", &cv_invertmouse, 30}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Mouse X Speed", &cv_mousexsens, 40}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Mouse X Speed", &cv_mousexsens, 40}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Mouse Y Speed", &cv_mouseysens, 50}, }; @@ -861,7 +860,6 @@ static const char* OP_VideoTooltips[] = "Advanced graphical options.", }; - enum { op_video_res = 0, @@ -945,24 +943,25 @@ static menuitem_t OP_ExpOptionsMenu[] = //{IT_STRING | IT_CVAR, NULL, "Randomized Directional Light", &cv_randomdirlight, 45}, // should this ever come back {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 40}, + {IT_STRING | IT_CVAR, NULL, "Skydome", &cv_skydome, 45}, - {IT_STRING | IT_CVAR, NULL, "Precache Level Textures", &cv_precachetextures, 50}, + {IT_STRING | IT_CVAR, NULL, "Precache Level Textures", &cv_precachetextures, 55}, - {IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 60}, + {IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 65}, - {IT_STRING | IT_CVAR, NULL, "Frameskip", &cv_frameskip, 70}, + {IT_STRING | IT_CVAR, NULL, "Frameskip", &cv_frameskip, 75}, - {IT_STRING | IT_CVAR, NULL, "Votescreen Scaling", &cv_votebgscaling, 80}, + {IT_STRING | IT_CVAR, NULL, "Votescreen Scaling", &cv_votebgscaling, 85}, #ifdef HWRENDER - {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 90}, + {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 95}, #ifdef USE_FBO_OGL - {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 95}, - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 105}, - {IT_DISABLED, NULL, "", NULL, 115}, // dummy text + {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 100}, + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 110}, + {IT_DISABLED, NULL, "", NULL, 120}, // dummy text #else - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 100}, - {IT_DISABLED, NULL, "", NULL, 110}, // dummy text + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 110}, + {IT_DISABLED, NULL, "", NULL, 120}, // dummy text #endif #endif }; @@ -975,6 +974,7 @@ static const char* OP_ExpTooltips[] = "Sets minimum sector brightness, useful for dark areas.", //"Should the directional lightning be randomized each map?\nTakes effect on next map load.", "Toggle being able to see the sky.", + "Toggle skydome.", // idk man someone give a better description of this "Preload all level textures on level load.\nMassively reduces texture related stuttering during gameplay\nat the cost of longer level loading times.\nDisable this if you experience timeouts during level switches.", "Change the FPS counter sampling method\nInaccurate updates slower\nand might miss sudden framerate changes and drops,\nproviding a more averaged result.\nAccurate updates faster, but might be less readable.", // how to ingles?? "Skips rendering frames if game logic takes too long\npreventing gameplay issues during performance drops.", // idk im shit as describing things @@ -996,6 +996,7 @@ enum op_exp_secbright, //op_exp_dirlight, op_exp_skybox, + op_exp_skydome, op_exp_texcache, op_exp_accuratefps, op_exp_frameskip, @@ -1767,20 +1768,21 @@ static menuitem_t OP_PlayerDistortMenu[] = {IT_STRING | IT_CVAR, NULL, "Slope Rotation Distance", &cv_sloperolldist, 15}, {IT_STRING | IT_CVAR, NULL, "Rotate Players when Sliptiding", &cv_sliptideroll, 25}, - {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 30}, - {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 35}, + {IT_STRING | IT_CVAR, NULL, "Stair Janking Effect", &cv_stairjank, 30}, + {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 35}, + {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 40}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 45}, - {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 50}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 50}, + {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 55}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 60}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 65}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 70}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 75}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 80}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 65}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 70}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 75}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 80}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 85}, - {IT_STRING | IT_CVAR, NULL, "Squishdance", &cv_squishdance, 90}, - {IT_STRING | IT_CVAR, NULL, "Squishdance Speed", &cv_squishdancespeed, 96}, + {IT_STRING | IT_CVAR, NULL, "Squishdance", &cv_squishdance, 95}, + {IT_STRING | IT_CVAR, NULL, "Squishdance Speed", &cv_squishdancespeed, 101}, // why is this offset by 6? idk cant remember lulul }; static const char* OP_PlayerDistortTooltips[] = @@ -1789,6 +1791,7 @@ static const char* OP_PlayerDistortTooltips[] = "Sprite rotation on slopes. Can either be just players or all objects.", "Distance object rotation should be visable.", "Player rotation when sliptiding.", + "Slightly tilt the player when driving over stairs or small bumps.", "Rotation of a player's boost trails and drift sparks.", "Should banans rotate when thrown?\nAnd should they stay rotated when on the ground?", "Player squash and stretch.", @@ -1799,7 +1802,7 @@ static const char* OP_PlayerDistortTooltips[] = "Player hop squash and stretch.", "Should the player rotation be kept during player hop.", "Do a funny squishy dance when holding CUSTOM 3.", - "Speed of the Squishy dance in BPM.", + "Speed of the Squishy dance in SPM (Squishes Per Minute).", }; enum @@ -1808,6 +1811,7 @@ enum sloperotate, slrotatedist, sliptide, + stairjank, sparkrotate, bananrotat, stretchyplayer, From 91927e324b3e5c42cd98b15159360438b8190f6e Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 20:40:20 +0200 Subject: [PATCH 425/589] , this menu been broken since 4 months lol --- src/m_menudefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 80c87066e..0ee6af395 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -980,7 +980,7 @@ static const char* OP_ExpTooltips[] = "Skips rendering frames if game logic takes too long\npreventing gameplay issues during performance drops.", // idk im shit as describing things "Different methods of scaling the votescreen backgrounds.", #ifdef HWRENDER - "Disabling Screen Textures may result in a performance boost\nbut will break certain effects.\nScreen textures are required at resolutions lower than your desktop resolution!" + "Disabling Screen Textures may result in a performance boost\nbut will break certain effects.\nScreen textures are required at resolutions lower than your desktop resolution!", #ifdef USE_FBO_OGL "Allows the game to downsample from a higher resolution\nthan your display in OpenGL renderer mode.\nRequires a GPU with atleast OpenGL 2.1 support.", #endif From c4ed75fbc6b0379a50b395157d68b64d12b71453 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 22:42:20 +0200 Subject: [PATCH 426/589] port over some chat stuff from SRB2-Banpyura per https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2784 chat offsets and character count offsets are added to the base offset like we do for hud stuff, the og pr will directly use the cvar values for this, but wanna keep consistent with our rest needs to be added in the menu somewhere but idk where --- src/d_netcmd.c | 3 ++ src/hu_stuff.c | 107 ++++++++++++++++++++++++++++++++++++------------- src/hu_stuff.h | 4 ++ 3 files changed, 86 insertions(+), 28 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ecb90f224..9d7d697cd 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -942,6 +942,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_chatspamprotection); CV_RegisterVar(&cv_consolechat); CV_RegisterVar(&cv_chatnotifications); + CV_RegisterVar(&cv_chat_xoffset); + CV_RegisterVar(&cv_chat_yoffset); + CV_RegisterVar(&cv_chat_showlimit); CV_RegisterVar(&cv_chatbacktint); CV_RegisterVar(&cv_chatcentertext); CV_RegisterVar(&cv_songcredits); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 82b0a74af..0013900f6 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -117,6 +117,11 @@ static void HU_DrawRankings(void); consvar_t cv_showspecstuff = {"showspecstuff", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +// stuff from SRB2-Banpyura thx alot! :3 +consvar_t cv_chat_xoffset = {"chat_xoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_chat_yoffset = {"chat_yoffset", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_chat_showlimit = {"chat_showlimit", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + static char cechotext[1024]; static tic_t cechotimer = 0; static tic_t cechoduration = 5*TICRATE; @@ -1370,7 +1375,12 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string) // 30/7/18: chaty is now the distance at which the lowest point of the chat will be drawn if that makes any sense. -INT16 chatx = 13, chaty = 169; // let's use this as our coordinates, shh +// let's use this as our coordinates, shh +// :chao: guess this just works lol +#define chatx ((INT16)(13 + (cv_chat_xoffset.value))) +#define chaty ((INT16)(169 + (cv_chat_yoffset.value))) + +#define CHATSNAP (V_SNAPTOBOTTOM|V_SNAPTOLEFT) // chat stuff by VincyTM LOL XD! @@ -1397,7 +1407,7 @@ static void HU_drawMiniChat(void) for (; i > 0; i--) { - char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i-1]); + char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), CHATSNAP|V_ALLOWLOWERCASE, chat_mini[i-1]); size_t j = 0; INT32 linescount = 0; emote_t *emote = NULL; @@ -1457,6 +1467,7 @@ static void HU_drawMiniChat(void) if (splitscreen) { y -= BASEVIDHEIGHT/2; + if (splitscreen > 1) y += 16; } @@ -1474,7 +1485,7 @@ static void HU_drawMiniChat(void) INT32 timer = ((cv_chattime.value*TICRATE)-chat_timers[i]) - cv_chattime.value*TICRATE+9; // see below... INT32 transflag = (timer >= 0 && timer <= 9) ? (timer*V_10TRANS) : 0; // you can make bad jokes out of this one. size_t j = 0; - char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i]); // get the current message, and word wrap it. + char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), CHATSNAP|V_ALLOWLOWERCASE, chat_mini[i]); // get the current message, and word wrap it. UINT8 *colormap = NULL; emote_t *emote = NULL; int emotelen = 0; @@ -1507,9 +1518,9 @@ static void HU_drawMiniChat(void) else if ((emote = M_VerifyEmote(msg+j, &emotelen))) { if (cv_chatbacktint.value) // on request of wolfy - V_DrawFillConsoleMap(x + dx + 2, y+dy, EMOTEWIDTH, charheight, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); + V_DrawFillConsoleMap(x + dx + 2, y+dy, EMOTEWIDTH, charheight, 239|CHATSNAP); - M_DrawEmote(x+dx+2, y+dy, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag); + M_DrawEmote(x+dx+2, y+dy, emote, CHATSNAP|transflag); dx += EMOTEWIDTH - charwidth; j += emotelen; @@ -1517,9 +1528,9 @@ static void HU_drawMiniChat(void) else { if (cv_chatbacktint.value) // on request of wolfy - V_DrawFillConsoleMap(x + dx + 2, y+dy, charwidth, charheight, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); + V_DrawFillConsoleMap(x + dx + 2, y+dy, charwidth, charheight, 239|CHATSNAP); - V_DrawChatCharacter(x + dx + 2, y+dy+cv_chatcentertext.value, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag, !cv_allcaps.value, colormap); + V_DrawChatCharacter(x + dx + 2, y+dy+cv_chatcentertext.value, msg[j++] |CHATSNAP|transflag, !cv_allcaps.value, colormap); } dx += charwidth; @@ -1580,13 +1591,13 @@ static void HU_drawChatLog(INT32 offset) chat_topy = y + chat_scroll*charheight; chat_bottomy = chat_topy + boxh*charheight; - V_DrawFillConsoleMap(chatx, chat_topy, boxw, boxh*charheight +2, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); // log box + V_DrawFillConsoleMap(chatx, chat_topy, boxw, boxh*charheight +2, 239|CHATSNAP); // log box for (i = 0; i < chat_nummsg_log; i++) // iterate through our chatlog { INT32 clrflag = 0; INT32 j = 0; - char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_log[i]); // get the current message, and word wrap it. + char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), CHATSNAP|V_ALLOWLOWERCASE, chat_log[i]); // get the current message, and word wrap it. UINT8 *colormap = NULL; emote_t *emote = NULL; int emotelen = 0; @@ -1616,7 +1627,7 @@ static void HU_drawChatLog(INT32 offset) { if ((y+dy+2 >= chat_topy) && (y+dy < (chat_bottomy))) { - M_DrawEmote(x+dx+2, y+dy+1, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT); + M_DrawEmote(x+dx+2, y+dy+1, emote, CHATSNAP); dx += EMOTEWIDTH - charwidth; } j += emotelen; @@ -1624,7 +1635,7 @@ static void HU_drawChatLog(INT32 offset) else { if ((y+dy+2 >= chat_topy) && (y+dy < (chat_bottomy))) - V_DrawChatCharacter(x + dx + 2, y+dy+2, msg[j++] |V_SNAPTOBOTTOM|V_SNAPTOLEFT, !cv_allcaps.value, colormap); + V_DrawChatCharacter(x + dx + 2, y+dy+2, msg[j++] |CHATSNAP, !cv_allcaps.value, colormap); else j++; // don't forget to increment this or we'll get stuck in the limbo. } @@ -1661,9 +1672,9 @@ static void HU_drawChatLog(INT32 offset) // draw arrows to indicate that we can (or not) scroll. if (chat_scroll > 0) - V_DrawCharacter(chatx-9, ((justscrolledup) ? (chat_topy-1) : (chat_topy)), V_SNAPTOBOTTOM | V_SNAPTOLEFT | highlight | '\x1A', false); // up arrow + V_DrawCharacter(chatx-9, ((justscrolledup) ? (chat_topy-1) : (chat_topy)), CHATSNAP | highlight | '\x1A', false); // up arrow if (chat_scroll < chat_maxscroll) - V_DrawCharacter(chatx-9, chat_bottomy-((justscrolleddown) ? 5 : 6), V_SNAPTOBOTTOM | V_SNAPTOLEFT | highlight | '\x1B', false); // down arrow + V_DrawCharacter(chatx-9, chat_bottomy-((justscrolleddown) ? 5 : 6), CHATSNAP | highlight | '\x1B', false); // down arrow justscrolleddown = false; justscrolledup = false; @@ -1681,6 +1692,7 @@ static void HU_DrawChat(void) INT32 boxw = cv_chatwidth.value; INT32 t = 0, c = 0, y = chaty - (typelines*charheight); UINT32 i = 0, saylen = strlen(w_chat_buf); // You learn new things everyday! + UINT32 charcount = 0; INT32 cflag = 0; INT32 pm_offset = 0; // for cases when you type emote while also doing /pm size_t select_start = 0, select_end = 0; @@ -1712,7 +1724,7 @@ static void HU_DrawChat(void) cflag = V_GRAYMAP; // set text in gray if chat is muted. } - V_DrawFillConsoleMap(chatx, y-1, boxw, (typelines*charheight), 239 | V_SNAPTOBOTTOM | V_SNAPTOLEFT); + V_DrawFillConsoleMap(chatx, y-1, boxw, (typelines*charheight), 239 | CHATSNAP); while (talk[i]) { @@ -1720,7 +1732,7 @@ static void HU_DrawChat(void) ++i; else { - V_DrawChatCharacter(chatx + c + 2, y, talk[i] |V_SNAPTOBOTTOM|V_SNAPTOLEFT|cflag, !cv_allcaps.value, V_GetStringColormap(talk[i]|cflag)); + V_DrawChatCharacter(chatx + c + 2, y, talk[i] |CHATSNAP|cflag, !cv_allcaps.value, V_GetStringColormap(talk[i]|cflag)); i++; } @@ -1738,7 +1750,7 @@ static void HU_DrawChat(void) typelines = 1; if ((w_chat.cursor == 0 || w_chat.length == 0) && hu_tick < 4) - V_DrawChatCharacter(chatx+2+c, y+1, '_'|V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, !cv_allcaps.value, NULL); + V_DrawChatCharacter(chatx+2+c, y+1, '_'|CHATSNAP|t, !cv_allcaps.value, NULL); if (w_chat.select != w_chat.cursor) { @@ -1755,17 +1767,23 @@ static void HU_DrawChat(void) if ((emote = M_VerifyEmote(w_chat_buf+i, &emotelen))) { - M_DrawEmote(chatx + c + 2, y-1, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT|t); + M_DrawEmote(chatx + c + 2, y-1, emote, CHATSNAP|t); c += EMOTEWIDTH - charwidth; i += emotelen-1; drawwidth = EMOTEWIDTH; + if (cv_chat_showlimit.value) + charcount += emotelen; } else if (w_chat_buf[i] >= HU_FONTSTART) //Hurdler: isn't it better like that? - V_DrawChatCharacter(chatx + c + 2, y, w_chat_buf[i] | V_SNAPTOBOTTOM|V_SNAPTOLEFT | t, !cv_allcaps.value, NULL); + { + V_DrawChatCharacter(chatx + c + 2, y, w_chat_buf[i] | CHATSNAP | t, !cv_allcaps.value, NULL); + if (cv_chat_showlimit.value) + charcount++; + } // Draw selection if (i >= select_start && i < select_end) - V_DrawFill(chatx + c + 2 - (drawwidth-charwidth), y-1, drawwidth, charheight, 103|V_TRANSLUCENT|V_SNAPTOBOTTOM|V_SNAPTOLEFT|t); + V_DrawFill(chatx + c + 2 - (drawwidth-charwidth), y-1, drawwidth, charheight, 103|V_TRANSLUCENT|CHATSNAP|t); ++i; @@ -1774,7 +1792,7 @@ static void HU_DrawChat(void) INT32 cursorx = (c+charwidth < boxw-charwidth) ? (chatx + 2 + c+charwidth) : (chatx+1); // we may have to go down. INT32 cursory = (cursorx != chatx+1) ? (y) : (y+charheight); if (hu_tick < 4) - V_DrawChatCharacter(cursorx, cursory+1, '_' |V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, !cv_allcaps.value, NULL); + V_DrawChatCharacter(cursorx, cursory+1, '_' |CHATSNAP|t, !cv_allcaps.value, NULL); if (cursorx == chatx+1 && saylen == i-1) // a weirdo hack { @@ -1792,6 +1810,13 @@ static void HU_DrawChat(void) } } + if (cv_chat_showlimit.value) + { + // Limit + const INT32 clr = ((HU_MAXMSGLEN - charcount) > 64 ? V_TRANSLUCENT : (charcount == HU_MAXMSGLEN ? V_REDMAP : V_YELLOWMAP)); + V_DrawSmallString(chatx, y+7, CHATSNAP|clr, va("%d/%d", charcount, HU_MAXMSGLEN)); + } + // handle /pm list. It's messy, horrible and I don't care. if (strnicmp(w_chat_buf, "/pm", 3) == 0 && vid.width >= 400 && !teamtalk) // 320x200 unsupported kthxbai { @@ -1827,6 +1852,7 @@ static void HU_DrawChat(void) { char nodenum[3]; UINT32 n; + // right, that's half important: (w_chat_buf[4] may be a space since /pm0 msg is perfectly acceptable!) if (!isdigit(w_chat_buf[3]) || !(isdigit(w_chat_buf[4]) || (w_chat_buf[4] == ' ') || (w_chat_buf[4] == 0))) break; @@ -1864,17 +1890,17 @@ static void HU_DrawChat(void) } // fill it like the chat so the text doesn't become hard to read because of the hud. - V_DrawFillConsoleMap(chatx + boxw + 2, p_dispy - (6*count), (longest_name_length+4)*4, 6, 239 | V_SNAPTOBOTTOM | V_SNAPTOLEFT); + V_DrawFillConsoleMap(chatx + boxw + 2, p_dispy - (6*count), (longest_name_length+4)*4, 6, 239 | CHATSNAP); - V_DrawSmallString(chatx + boxw + 4, p_dispy - (6*count), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, va("\x82%d\x80 - %s", i, player_names[i])); + V_DrawSmallString(chatx + boxw + 4, p_dispy - (6*count), CHATSNAP|V_ALLOWLOWERCASE, va("\x82%d\x80 - %s", i, player_names[i])); count++; } if (count == 0) // no results. { pm_offset = 48 + 2; - V_DrawFillConsoleMap(chatx + boxw + 2, p_dispy - (6*count), 48, 6, 239 | V_SNAPTOBOTTOM | V_SNAPTOLEFT); // fill it like the chat so the text doesn't become hard to read because of the hud. - V_DrawSmallString(chatx + boxw + 4, p_dispy - (6*count), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, "NO RESULT."); + V_DrawFillConsoleMap(chatx + boxw + 2, p_dispy - (6*count), 48, 6, 239 | CHATSNAP); // fill it like the chat so the text doesn't become hard to read because of the hud. + V_DrawSmallString(chatx + boxw + 4, p_dispy - (6*count), CHATSNAP|V_ALLOWLOWERCASE, "NO RESULT."); } else { @@ -1926,15 +1952,15 @@ static void HU_DrawChat(void) while ((suggest = M_FindEmote(complete, complete_len, skip)) != NULL) { - V_DrawFillConsoleMap(chatx + boxw + pm_offset + 2, suggesty - (7*skip), emote_suggest_boxw, 6, V_SNAPTOBOTTOM|V_SNAPTOLEFT); + V_DrawFillConsoleMap(chatx + boxw + pm_offset + 2, suggesty - (7*skip), emote_suggest_boxw, 6, CHATSNAP); // Highlight currently suggested emote int hlflag = 0; if (skip == emote_autocomplete.skip && emote_autocomplete.complete[0]) hlflag = V_YELLOWMAP; - V_DrawSmallString(chatx + boxw + pm_offset + 4 + EMOTEWIDTH, suggesty - (7*skip), hlflag|V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, va(":%s:", suggest->name)); - M_DrawEmote(chatx + boxw + pm_offset + 2, suggesty - skip*7, suggest, V_SNAPTOBOTTOM|V_SNAPTOLEFT); + V_DrawSmallString(chatx + boxw + pm_offset + 4 + EMOTEWIDTH, suggesty - (7*skip), hlflag|CHATSNAP|V_ALLOWLOWERCASE, va(":%s:", suggest->name)); + M_DrawEmote(chatx + boxw + pm_offset + 2, suggesty - skip*7, suggest, CHATSNAP); ++skip; } @@ -1948,6 +1974,7 @@ static void HU_DrawChat(void) static void HU_DrawChat_Old(void) { INT32 t = 0, c = 0, y = HU_INPUTY; + UINT32 charcount = 0; size_t i = 0; const char *ntalk = "Say: ", *ttalk = "Say-Team: "; const char *talk = ntalk; @@ -1993,11 +2020,17 @@ static void HU_DrawChat_Old(void) { M_DrawScaledEmote((HU_INPUTX + c)<= HU_FONTSTART) //Hurdler: isn't it better like that? { //charwidth = hu_font[w_chat[i]-HU_FONTSTART]->width * con_scalefactor; V_DrawCharacter(HU_INPUTX + c, y, w_chat_buf[i] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value); + + if (cv_chat_showlimit.value) + charcount++; } // Draw selection @@ -2010,7 +2043,7 @@ static void HU_DrawChat_Old(void) { INT32 cursorx = (HU_INPUTX+c+charwidth < vid.width) ? (HU_INPUTX + c + charwidth) : (HU_INPUTX); // we may have to go down. INT32 cursory = (cursorx != HU_INPUTX) ? (y) : (y+charheight); - V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value); + V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' | cv_constextsize.value | V_NOSCALESTART |t, !cv_allcaps.value); } c += charwidth; @@ -2020,6 +2053,24 @@ static void HU_DrawChat_Old(void) y += charheight; } } + + // console chat users are FINALLY being fed! + if (cv_chat_showlimit.value) + { + const char *lim = va(" (%i/%i)", charcount, HU_MAXMSGLEN); + for (i = 0; lim[i]; i++) + { + V_DrawCharacter(HU_INPUTX + c, y, lim[i] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value); + + c += charwidth; + if (c >= vid.width) // text wrapping + { + c = 0; + y += charheight; + } + } + } + } static void HU_DrawCEcho(void) diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 30dfddc0c..8cfd650cb 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -88,6 +88,10 @@ extern patch_t *tallminus; // set true whenever the tab rankings are being shown for any reason extern boolean hu_showscores; +extern consvar_t cv_chat_xoffset; +extern consvar_t cv_chat_yoffset; +extern consvar_t cv_chat_showlimit; + // init heads up data at game startup. void HU_Init(void); From d99c272a7933b721bc6231c409ff7d3ba5ec63cf Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 23:14:32 +0200 Subject: [PATCH 427/589] have textboxes "reserve" space for cursor so it wont draw outside the textbox but rather scrolls --- src/m_textinput.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_textinput.h b/src/m_textinput.h index ce296ffde..f5846059e 100644 --- a/src/m_textinput.h +++ b/src/m_textinput.h @@ -44,7 +44,7 @@ boolean M_TextInputHandle(textinput_t *input, INT32 key); // If currently typing something that looks like an existing emote, return suggestions for it boolean M_TextInputHandleEmotes(textinput_t *input, INT32 key, emote_autocomplete_t *autocomplete); -#define M_DrawTextInput(x, y, input, flags) M_DrawTextInputScroll((x), (y), (input), (flags), ((input)->buffer_size-1)*8) +#define M_DrawTextInput(x, y, input, flags) M_DrawTextInputScroll((x), (y), (input), (flags), ((input)->buffer_size-2)*8) void M_DrawTextInputScroll(INT32 x, INT32 y, textinput_t *input, INT32 flags, INT32 MAXINPUTWIDTH); #endif From 4f036c93129182b2c4065a08a274f5a5b066e6b6 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 28 Jun 2026 00:14:35 +0300 Subject: [PATCH 428/589] Fix setupm_ip going out of textbox when its not being edited --- src/m_menu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 499e5b9c4..e80fbf47e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7608,7 +7608,11 @@ Update the maxplayers label... // draw name string if (itemOn != 9) - V_DrawString(x+8,y+12, V_ALLOWLOWERCASE, setupm_ip); + { + char buf[28]; + strlcpy(buf, setupm_ip, sizeof(buf)); + V_DrawString(x+8,y+12, V_ALLOWLOWERCASE, buf); + } else M_DrawTextInputScroll(x+8, y+12, &setupm_input_ip, 0, SETUPM_IP_MAXSIZE); From 5fb5af05be6bd692a49c28d45cdb8fe9c6cfa7cc Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 23:39:23 +0200 Subject: [PATCH 429/589] this is P_NetUnArchiveThinkers lululul --- src/p_saveg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 37fcf4c3e..2264a2be5 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3059,7 +3059,7 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) break; default: - I_Error("P_UnarchiveSpecials: Unknown tclass %d in savegame", tclass); + I_Error("P_NetUnArchiveThinkers: Unknown tclass %d in savegame", tclass); } } From 71640202edd44290b697810c6224c4968608cf86 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jun 2026 23:42:01 +0200 Subject: [PATCH 430/589] better polyobj count error for savegame from Banpyura gonna look into their return to menu instead of i_error stuff sometime --- src/p_saveg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index 2264a2be5..1b7f21c47 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3170,7 +3170,7 @@ FUNCINLINE static ATTRINLINE void P_UnArchivePolyObjects(savebuffer_t *save) numSavedPolys = READINT32(save->p); if (numSavedPolys != numPolyObjects) - I_Error("P_UnArchivePolyObjects: polyobj count inconsistency\n"); + I_Error("P_UnArchivePolyObjects: polyobj count inconsistency (expected %d, got %d)\n", numPolyObjects, numSavedPolys); for (i = 0; i < numSavedPolys; ++i) P_UnArchivePolyObj(save, &PolyObjects[i]); From ba75523d485d2c58b7116547643181c764f6c34f Mon Sep 17 00:00:00 2001 From: romoney5 Date: Mon, 8 Jun 2026 17:45:28 -0400 Subject: [PATCH 431/589] Print a warning when archiving an invalid Lua value --- src/lua_script.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lua_script.c b/src/lua_script.c index 2649a57c7..4e1cfc995 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -713,9 +713,12 @@ static UINT8 GetUserdataArchType(int index) static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) { + int type = lua_type(gL, myindex); + if (myindex < 0) myindex = lua_gettop(gL)+1+myindex; - switch (lua_type(gL, myindex)) + + switch (type) { case LUA_TNONE: case LUA_TNIL: @@ -725,8 +728,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) case LUA_TLIGHTUSERDATA: case LUA_TTHREAD: case LUA_TFUNCTION: + { + const char *typestr = (type == LUA_TLIGHTUSERDATA ? "light userdata" : (type == LUA_TTHREAD ? "thread" : (type == LUA_TFUNCTION ? "function" : "??"))); + CONS_Alert(CONS_ERROR, M_GetText("Archived an invalid value! (%s)\n"), typestr); WRITEUINT8(*p, ARCH_NULL); return 2; + } case LUA_TBOOLEAN: WRITEUINT8(*p, ARCH_BOOLEAN); WRITEUINT8(*p, lua_toboolean(gL, myindex)); From 3606b0ae6641ade941de992fe946f6413874d9f7 Mon Sep 17 00:00:00 2001 From: romoney5 Date: Fri, 24 Apr 2026 19:34:46 -0400 Subject: [PATCH 432/589] Don't disable console on resync --- src/d_clisrv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7fb65d4d3..492dd0ac4 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2181,7 +2181,8 @@ static void CL_LoadReceivedSavegame(boolean reloading) if (unlink(tmpsave) == -1) CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave); consistancy[gametic%BACKUPTICS] = Consistancy(); - CON_ToggleOff(); + if (!reloading) + CON_ToggleOff(); #ifdef SATURNPAK // Tell the server we have received and reloaded the gamestate From 2ba4757c6acde230b5731c4b4ac74ae746a208ac Mon Sep 17 00:00:00 2001 From: GLide KS <84994993+GLideKS@users.noreply.github.com> Date: Thu, 11 Jun 2026 21:09:59 -0400 Subject: [PATCH 433/589] Hopefully a cleaner implementation of Local Addon switch --- src/m_menu.c | 64 +++++++++++++++++++++++++++++++----------------- src/m_menudefs.c | 4 +-- 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index e80fbf47e..ac571d6f1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -151,8 +151,6 @@ const char *quitmsg[NUM_QUITMESSAGES] = {}; INT32 mapwads[NUMMAPS] = {}; -boolean browselocalskins = false; - boolean menuactive = false; boolean fromlevelselect = false; @@ -221,6 +219,11 @@ static boolean setupm_skinlockedselect; static UINT8 setupm_playernum; //brap +// Addons Menu: Local mode +static void M_LocalAddons(INT32 choice); +#define LOCALMODE_KEY (KEY_RALT) +static boolean addons_localmode = false; + // // PROTOTYPES // @@ -325,7 +328,6 @@ static void M_EraseData(INT32 choice); static void M_AddonsInternal(); static void M_Addons(INT32 choice); -static void M_LocalSkins(INT32 choice); static void M_AddonsOptions(INT32 choice); #define addonmenusize 9 // number of items actually displayed in the addons menu view, formerly (2*numaddonsshown + 1) #define numaddonsshown 4 // number of items to each side of the currently selected item, unless at top/bottom ends of directory @@ -1014,6 +1016,24 @@ boolean M_Responder(event_t *ev) case KEY_HAT1 + 3: ch = KEY_RIGHTARROW; break; + //Local Addon Mode + case LOCALMODE_KEY: + { + if (!(server || IsPlayerAdmin(consoleplayer))) + break; + + if (!addons_localmode) + { + S_StartSound(NULL, sfx_ding); + addons_localmode = true; + } + else + { + S_StartSound(NULL, sfx_jshard); + addons_localmode = false; + } + } + break; } } else if (menuactive) @@ -1718,19 +1738,16 @@ void M_StartControlPanel(void) MPauseMenu[mpause_switchteam].status = IT_DISABLED; MPauseMenu[mpause_switchspectate].status = IT_DISABLED; MPauseMenu[mpause_psetup].status = IT_DISABLED; + MPauseMenu[mpause_localaddons].status = IT_STRING | IT_CALL; + MISC_ChangeTeamMenu[0].status = IT_DISABLED; MISC_ChangeSpectateMenu[0].status = IT_DISABLED; - MPauseMenu[mpause_addlocalskins].status = IT_STRING | IT_CALL; MPauseMenu[mpause_localskin].status = IT_STRING | IT_CALL; // Reset these in case splitscreen messes things up MPauseMenu[mpause_addons].alphaKey = 8; - - if (IsPlayerAdmin(consoleplayer)) - MPauseMenu[mpause_addlocalskins].alphaKey = 16; - else - MPauseMenu[mpause_addlocalskins].alphaKey = 24; + MPauseMenu[mpause_localaddons].alphaKey = 24; MPauseMenu[mpause_scramble].alphaKey = 8; MPauseMenu[mpause_switchmap].alphaKey = 24; @@ -1748,14 +1765,13 @@ void M_StartControlPanel(void) { MPauseMenu[mpause_switchmap].status = IT_STRING | IT_CALL; MPauseMenu[mpause_addons].status = IT_STRING | IT_CALL; - + MPauseMenu[mpause_localaddons].status = IT_DISABLED; if (G_GametypeHasTeams()) MPauseMenu[mpause_scramble].status = IT_STRING | IT_SUBMENU; } if (server || (!cv_showlocalskinmenus.value)) { - MPauseMenu[mpause_addlocalskins].status = IT_DISABLED; MPauseMenu[mpause_localskin].status = IT_DISABLED; MPauseMenu[mpause_options].alphaKey = 64; @@ -1763,7 +1779,6 @@ void M_StartControlPanel(void) MPauseMenu[mpause_quit].alphaKey = 88; } - if (splitscreen) { MPauseMenu[mpause_psetupsplit].status = MPauseMenu[mpause_psetupsplit2].status = IT_STRING | IT_CALL; @@ -3308,14 +3323,14 @@ static void M_AddonsInternal(void) static void M_Addons(INT32 choice) { (void)choice; - browselocalskins = false; + addons_localmode = false; M_AddonsInternal(); } -static void M_LocalSkins(INT32 choice) +static void M_LocalAddons(INT32 choice) { (void)choice; - browselocalskins = true; + addons_localmode = true; M_AddonsInternal(); } @@ -3484,8 +3499,8 @@ static void M_DrawAddons(void) if (Playing()) { - if (browselocalskins) - V_DrawCenteredString(BASEVIDWIDTH/2, 5, V_ALLOWLOWERCASE, "Load \x83local skins\x80 from addons!"); + if (addons_localmode) // Draw notice that you're adding locally + V_DrawCenteredString(BASEVIDWIDTH/2, 5, V_ALLOWLOWERCASE, "Load addons or \x83local skins\x80 locally!"); else V_DrawCenteredString(BASEVIDWIDTH/2, 5, warningflags, "Adding files mid-game may cause problems."); } @@ -3649,6 +3664,9 @@ static void M_DrawAddons(void) //V_DrawCenteredString(BASEVIDWIDTH/2, y+24, (majormods ? highlightflags : V_TRANSLUCENT), va("%d ADD-ON%s LOADED", (int)m, (m == 1) ? "" : "S")); //+2 for music, sounds, +1 for main.kart V_DrawThinString(0, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("END Key - Add addon to autoload")); + + if (Playing() && (server || IsPlayerAdmin(consoleplayer))) + V_DrawThinString(0, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("Right ALT Key - Switch to local addon mode")); } static void M_AddonExec(INT32 ch) @@ -3838,14 +3856,14 @@ static void M_HandleAddons(INT32 choice) case EXT_KART: #endif case EXT_PK3: - if (browselocalskins) + if (addons_localmode) { - if (DumbStartsWith("KC_", dirmenu[dir_on[menudepthleft]]+DIR_STRING) || DumbStartsWith("kc_", dirmenu[dir_on[menudepthleft]]+DIR_STRING)) { + 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("addfilelocal \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); } - else - S_StartSound(NULL, sfx_s26d); + + COM_BufAddText(va("addfilelocal \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); } else { @@ -3928,6 +3946,8 @@ static void M_HandleAddons(INT32 choice) M_SetupNextMenu(currentMenu->prevMenu); else M_ClearMenus(true); + + addons_localmode = false; //Exiting this menu, disable addons_localmode already. } } diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 0ee6af395..7966d5173 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -208,7 +208,7 @@ typedef enum static menuitem_t MPauseMenu[] = { {IT_STRING | IT_CALL, NULL, "Addons...", M_Addons, 8}, - {IT_STRING | IT_CALL, NULL, "Add local skins...", M_LocalSkins, 16}, + {IT_STRING | IT_CALL, NULL, "Local Add-ons...", M_LocalAddons, 8}, {IT_STRING | IT_SUBMENU, NULL, "Scramble Teams...", &MISC_ScrambleTeamDef, 24}, {IT_STRING | IT_CALL, NULL, "Switch Map..." , M_MapChange, 32}, @@ -238,7 +238,7 @@ static menuitem_t MPauseMenu[] = typedef enum { mpause_addons = 0, - mpause_addlocalskins, + mpause_localaddons, mpause_scramble, mpause_switchmap, #ifdef HAVE_DISCORDRPC From 49d637450555d6ba3278ceba1eae0b1860393660 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 00:24:19 +0200 Subject: [PATCH 434/589] have local skin message account for "KCL" prefix for skins with lua --- src/m_menu.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index ac571d6f1..6fc11d681 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3843,7 +3843,7 @@ static void M_HandleAddons(INT32 choice) } break; case EXT_TXT: - M_StartMessage(va("%c%s\x80\nThis file may not be a console script.\nAttempt to run anyways? \n\n(Press 'Y' to confirm)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),M_AddonExec,MM_YESNO); + M_StartMessage(va("%c%s\x80\nThis file may not be a console script.\nAttempt to run anyways? \n\n(Press 'Y' to confirm)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING), M_AddonExec, MM_YESNO); break; case EXT_CFG: M_AddonExec(KEY_ENTER); @@ -3856,20 +3856,26 @@ static void M_HandleAddons(INT32 choice) case EXT_KART: #endif case EXT_PK3: + { + const char *addonname = dirmenu[dir_on[menudepthleft]]+DIR_STRING; + if (addons_localmode) { - if (DumbStartsWith("KC_", dirmenu[dir_on[menudepthleft]]+DIR_STRING) || DumbStartsWith("kc_", dirmenu[dir_on[menudepthleft]]+DIR_STRING)) + if (DumbStartsWith("KC_", addonname) || DumbStartsWith("kc_", addonname) || + DumbStartsWith("KCL_", addonname) || DumbStartsWith("kcl_", addonname)) // skins with lua { - 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); + 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)), addonname), NULL, MM_NOTHING); } - COM_BufAddText(va("addfilelocal \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); + COM_BufAddText(va("addfilelocal \"%s%s\"", menupath, addonname)); } else { - COM_BufAddText(va("addfile \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); + COM_BufAddText(va("addfile \"%s%s\"", menupath, addonname)); } + break; + } default: S_StartSound(NULL, sfx_s26d); } From 73c7a5a0c4bf685e5c7ff5e636d943e1831e4bce Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 00:40:46 +0200 Subject: [PATCH 435/589] add better description for skip intro music stuff --- src/m_menudefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 7966d5173..9ede49b2e 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1175,7 +1175,7 @@ static const char* OP_SoundAdvancedTooltips[] = "Should the Grow music be on or off?", "Should the Invulnerability music be on or off?", "Should music be kept when restarting the map?", - "Should the Intro fanfare be skipped\nand map music be played on map start?", + "Should the Intro fanfare be skipped\nand map music be played on map start?\nNote that this WILL skip sounds played by the map before round start aswell!", "Controls Sound effects caching.\nKeep will retain previously played sound effects in cache." // man idk how to describe this in a non awful way lmao "\nOn will preload all sound effects.\nEliminates sound-related lag and stutters but increases memory usage.", "Size of the Audio Buffer\nreducing it will result in less sound latency\nbut may cause issues such as crackling or distorted Sound.", From 24bac9c13399fc8f21dbd92c9f7b6ac9f310a87a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 15:09:06 +0200 Subject: [PATCH 436/589] actually print a different message for localskins with lua tell ppl that this may cause issues --- src/m_menu.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 6fc11d681..9e7a7b1c1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -3856,30 +3856,34 @@ static void M_HandleAddons(INT32 choice) case EXT_KART: #endif case EXT_PK3: - { - const char *addonname = dirmenu[dir_on[menudepthleft]]+DIR_STRING; - - if (addons_localmode) { - if (DumbStartsWith("KC_", addonname) || DumbStartsWith("kc_", addonname) || - DumbStartsWith("KCL_", addonname) || DumbStartsWith("kcl_", addonname)) // skins with lua + const char *addonname = dirmenu[dir_on[menudepthleft]]+DIR_STRING; + + if (addons_localmode) { - 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)), addonname), NULL, MM_NOTHING); + if (DumbStartsWith("KC_", addonname) || DumbStartsWith("kc_", addonname)) + { + 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)), addonname), NULL, MM_NOTHING); + } + else if (DumbStartsWith("KCL_", addonname) || DumbStartsWith("kcl_", addonname)) // skins with lua + { + M_StartMessage(va("%c%s\x80\nYou are loading a local skin with lua.\nBeware that this may cause issues like crashes or desyncs in some cases!\nLocal skins will not be usable\nafter going back from\nthe title screen.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), addonname), NULL, MM_NOTHING); + } + // no need to account for KRC cases + + COM_BufAddText(va("addfilelocal \"%s%s\"", menupath, addonname)); + } + else + { + COM_BufAddText(va("addfile \"%s%s\"", menupath, addonname)); } - - COM_BufAddText(va("addfilelocal \"%s%s\"", menupath, addonname)); } - else - { - COM_BufAddText(va("addfile \"%s%s\"", menupath, addonname)); - } - break; - } default: S_StartSound(NULL, sfx_s26d); } } + if (refresh) refreshdirmenu |= REFRESHDIR_NORMAL; } @@ -7770,7 +7774,7 @@ static void M_SetupMultiHandler(INT32 choice) if (exitmenu) { if (currentMenu->prevMenu) - M_SetupNextMenu (currentMenu->prevMenu); + M_SetupNextMenu(currentMenu->prevMenu); else M_ClearMenus(true); } From 5c373b6251c98aae5b83a8883b8fdf3c1d81aba8 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 16:04:58 +0200 Subject: [PATCH 437/589] demote those to asserts never seen srb2, saturn, RR or blan or anything else have this return null there is a possibility but whatever just continuing in such cases was wrong eitherways as it wouldve just corrupted the vres thing --- src/w_wad.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 1099667e0..c8a1dbba8 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -123,6 +123,9 @@ static const char pat_end[] = {0x50, 0x4b, 0x05, 0x06, 0x00}; UINT16 numwadfiles = 0; // number of active wadfiles wadfile_t *wadfiles[MAX_WADFILES] = {}; // 0 to numwadfiles-1 are valid +// use strnlen as some lump names may not be null terminated +#define CHECKMAPMARKER(name) (memcmp(name, "MAP", 3) == 0 && strnlen(name, 8) == 5) + // W_Shutdown // Closes all of the WAD files before quitting // If not done on a Mac then open wad files @@ -2676,8 +2679,9 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) vlumps[i].size = vsizecache[realentry]; const char *name = (fileinfo + realentry)->name; + I_Assert(name != NULL); - if (strnlen(name, 8) == 5 && memcmp(name, "MAP", 3) == 0) + if (CHECKMAPMARKER(name)) { numlumps--; // We skip map marker, so 1 of entries becomes empty continue; // This will skip i++ so we will write to same entry @@ -2686,9 +2690,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) // Play it safe with the name in this case. memcpy(vlumps[i].name, name, 8); vlumps[i].name[8] = '\0'; - vlumps[i].data = (UINT8 *)( - Z_Malloc(vlumps[i].size, PU_LEVEL, NULL) // This is memory inefficient, sorry about that. - ); + vlumps[i].data = (UINT8 *)(Z_Malloc(vlumps[i].size, PU_LEVEL, NULL)); // This is memory inefficient, sorry about that. memcpy(vlumps[i].data, wadData + LONG((fileinfo + realentry)->filepos), vlumps[i].size); i++; } @@ -2698,15 +2700,19 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) } else { - // Count number of lumps until the end of resource OR up until next "MAPXX" lump. + // Count number of lumps until the end of resource OR up until next 0-length lump OR up until next "MAPXX" lump. lumpnum_t lumppos = lumpnum + 1; for (i = LUMPNUM(lumppos); i < wadfiles[WADFILENUM(lumpnum)]->numlumps; i++, lumppos++, numlumps++) { - const char *name = W_CheckNameForNum(lumppos); - if (name == NULL) - continue; + if (W_LumpLength(lumppos) == 0) + { + break; + } - if (memcmp(name, "MAP", 3) == 0 || W_LumpLength(lumppos) == 0) + const char *name = W_CheckNameForNum(lumppos); + I_Assert(name != NULL); + + if (CHECKMAPMARKER(name)) { break; } @@ -2721,10 +2727,9 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) { // Check if it is map marker. It is not always first lump sadly, so we need to expect it anywhere const char *name = W_CheckNameForNum(lumpnum); - if (name == NULL) - continue; + I_Assert(name != NULL); - if (strlen(name) == 5 && memcmp(name, "MAP", 3) == 0) + if (CHECKMAPMARKER(name)) { --i; // Decrement so on next iteration we write on same i, so we don't leave corrupted vlumps entry numlumps--; // Just so we don't try to access the leftover vlumps entry From af6abb54589e594b0a591008647c10e884fef36d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 16:14:42 +0200 Subject: [PATCH 438/589] better check for map data within autoloaded files before this flagged every file with lumps that contained the MAP as string somewhere, like palettes and such this is kinda messy but i really do not want to dupe this huge block of code, neither do i want to convert this to ceepeepee again to mess about with templates oh well --- src/w_wad.c | 86 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 17 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index c8a1dbba8..06af7a127 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2395,7 +2395,7 @@ static int W_NameStartsWith(const char *name, lumpchecklist_t *checklist) } // Checks if file contains at least one lump which name starts with one of strings in checklist -static int W_CheckWADContains(FILE *fp, lumpchecklist_t *checklist) +static int W_CheckWADContainsEx(FILE *fp, lumpchecklist_t *checklist, boolean checkmap) { size_t i, j; // if we're here it's a WAD file @@ -2436,13 +2436,29 @@ static int W_CheckWADContains(FILE *fp, lumpchecklist_t *checklist) if (!strncmp(lumpinfo.name, sprnames[j], 4)) // Sprites continue; - if (W_NameStartsWith(lumpinfo.name, checklist)) + if (checkmap) + { + if (CHECKMAPMARKER(lumpinfo.name)) + return true; + } + else if (W_NameStartsWith(lumpinfo.name, checklist)) return true; } + return false; } -static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) +static int W_CheckWADContains(FILE *fp, lumpchecklist_t *checklist) +{ + return W_CheckWADContainsEx(fp, checklist, false); +} + +static int W_CheckWADContainsMap(FILE *fp) +{ + return W_CheckWADContainsEx(fp, NULL, true); +} + +static int W_CheckPK3ContainsEx(FILE *fp, lumpchecklist_t *checklist, boolean checkmap) { zend_t zend; zlentry_t zlentry; @@ -2516,13 +2532,23 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? strncpy(lumpname, trimname, min(8, dotpos - trimname)); - if (W_NameStartsWith(lumpname, checklist)) + if (checkmap) + { + if (CHECKMAPMARKER(lumpname)) + return true; + } + else if (W_NameStartsWith(lumpname, checklist)) { return true; } } - if (W_NameStartsWith(fullname, checklist)) + if (checkmap) + { + if (CHECKMAPMARKER(fullname)) + return true; + } + else if (W_NameStartsWith(fullname, checklist)) { return true; } @@ -2564,12 +2590,24 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) } } -static int W_CheckFileContains(const char *filename, lumpchecklist_t *checklist) +static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) +{ + return W_CheckPK3ContainsEx(fp, checklist, false); +} + +static int W_CheckPK3ContainsMap(FILE *fp) +{ + return W_CheckPK3ContainsEx(fp, NULL, true); +} + +static int W_CheckFileContainsEx(const char *filename, lumpchecklist_t *checklist, boolean checkmap) { FILE *handle; int contains = false; - if (!checklist) + // if we just check for maps this will be NULL + // hacky but i dont care + if (!checklist && !checkmap) I_Error("No checklist for %s\n", filename); // open wad file @@ -2580,27 +2618,41 @@ static int W_CheckFileContains(const char *filename, lumpchecklist_t *checklist) if (type == RET_PK3) { - contains = W_CheckPK3Contains(handle, checklist); + if (checkmap) + contains = W_CheckPK3ContainsMap(handle); + else + contains = W_CheckPK3Contains(handle, checklist); } else if (type == RET_WAD) { - contains = W_CheckWADContains(handle, checklist); + if (checkmap) + contains = W_CheckWADContainsMap(handle); + else + contains = W_CheckWADContains(handle, checklist); } fclose(handle); return contains; } +static int W_CheckFileContains(const char *filename, lumpchecklist_t *checklist) +{ + return W_CheckFileContainsEx(filename, checklist, false); +} + +static int W_CheckFileContainsMap(const char *filename) +{ + return W_CheckFileContainsEx(filename, NULL, true); +} + +// kinda stupid but we cant just check for any lump containing "MAP" +// we have to explicitly check if its MAP and 5 characters long +// the more correct way would be checking inside wad files nested within pk3´s +// and check the presence of actual map data like SSECTORS or something +// but man i cannot be assed to rework shit for that int W_CheckAutoLoadContainsMap(const char *filename) { - // for now this checks for map marker - static lumpchecklist_t autoloadblacklist[] = - { - {"MAP", 3}, - {NULL, 0}, - }; - - return W_CheckFileContains(filename, autoloadblacklist); + return W_CheckFileContainsMap(filename); } int W_CheckPostLoadList(const char *filename) From 820ab4b2bc8738d879c1153f0cad147e82bc08e9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 16:23:16 +0200 Subject: [PATCH 439/589] block "addfilelocal" from adding files that contains maps now we have a more accessible menu for addfile local i really dont want to risk stuff --- src/d_main.c | 2 +- src/p_setup.c | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index e821de566..85e1242ac 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1159,7 +1159,7 @@ static void D_FindAddonsToAutoload(void) // you can probably imagine how that goes in a netgame.... if (W_CheckAutoLoadContainsMap(wadsToAutoload)) { - CONS_Printf("Autoload: file %s contains map data! skipping...", wadsToAutoload); + CONS_Alert(CONS_WARNING, "Autoload: file %s contains map data, this WILL cause crashes and desynchs! skipping...\n", wadsToAutoload); continue; } diff --git a/src/p_setup.c b/src/p_setup.c index c781761fc..fe583b406 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3334,6 +3334,17 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) sreplaces = mreplaces = digmreplaces = 0; + if (local) + { + // check if someone tries to load maps locally lol + // do this here so we can skip loading the file anyways + if (W_CheckAutoLoadContainsMap(wadfilename)) + { + CONS_Alert(CONS_WARNING, "addilelocal: locally added file %s contains map data, this WILL cause crashes and desynchs! not added.\n", wadfilename); + return UINT16_MAX; + } + } + if ((numlumps = W_InitFile(wadfilename, local, false)) == INT16_MAX) { refreshdirmenu |= REFRESHDIR_NOTLOADED; @@ -3364,12 +3375,15 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) allvotereplaced = true; } - if (!devparm && sreplaces) - CONS_Printf(M_GetText("%s sounds replaced\n"), sizeu1(sreplaces)); - if (!devparm && mreplaces) - CONS_Printf(M_GetText("%s midi musics ignored\n"), sizeu1(mreplaces)); - if (!devparm && digmreplaces) - CONS_Printf(M_GetText("%s digital musics replaced\n"), sizeu1(digmreplaces)); + if (!devparm) + { + if (sreplaces) + CONS_Printf(M_GetText("%s sounds replaced\n"), sizeu1(sreplaces)); + if (mreplaces) + CONS_Printf(M_GetText("%s midi musics ignored\n"), sizeu1(mreplaces)); + if (digmreplaces) + CONS_Printf(M_GetText("%s digital musics replaced\n"), sizeu1(digmreplaces)); + } if (!mapsadded) CONS_Printf(M_GetText("No maps added\n")); From 8bb04a68a80b82a4addfde7a01929f3446fca306 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 17:52:44 +0200 Subject: [PATCH 440/589] ass well --- src/m_menudefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 9ede49b2e..eb364bbb9 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1175,7 +1175,7 @@ static const char* OP_SoundAdvancedTooltips[] = "Should the Grow music be on or off?", "Should the Invulnerability music be on or off?", "Should music be kept when restarting the map?", - "Should the Intro fanfare be skipped\nand map music be played on map start?\nNote that this WILL skip sounds played by the map before round start aswell!", + "Should the Intro fanfare be skipped\nand map music be played on map start?\nNote that this WILL skip sounds played by the map before round start as well!", "Controls Sound effects caching.\nKeep will retain previously played sound effects in cache." // man idk how to describe this in a non awful way lmao "\nOn will preload all sound effects.\nEliminates sound-related lag and stutters but increases memory usage.", "Size of the Audio Buffer\nreducing it will result in less sound latency\nbut may cause issues such as crackling or distorted Sound.", From 530bb50709b6c793a14c83c3a8c23049d31aae72 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 17:53:47 +0200 Subject: [PATCH 441/589] ig "style" is the better word here lulul --- src/m_menudefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index eb364bbb9..afd365946 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1441,7 +1441,7 @@ static const char* OP_ChatOptionsTooltips[] = "Spam protection for in-game chat.", "Maxiumum amount of chat messages to look back at.", "Show player ping.", - "Choose the looks of the ping display.", // this is ass idk english lmao + "Choose the style of the ping display.", "Measurement used for ping.", "Visibility of ping icon.", "Should Player IP addresses be printed when using\nthe nodes or listplayers command?", From 496477fa9a70f50f7ba0ffec521ef1604a955c6d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 18:37:02 +0200 Subject: [PATCH 442/589] chatbgtint does actually not apply to the chatbox but only to the also confusingly named "mini chat" --- src/m_menudefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index afd365946..c06df7a26 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1436,7 +1436,7 @@ static const char* OP_ChatOptionsTooltips[] = "Width of chat box.", "Height of chat box.", "Center text in the chat message pop ups.", - "Chatbox background.", + "Background for the chat message pop ups.", "Fadeout time for new chat message.", "Spam protection for in-game chat.", "Maxiumum amount of chat messages to look back at.", From 7f9d70285d619290deb2c61e4910407a5c834d8d Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 18:53:14 +0200 Subject: [PATCH 443/589] add new chat stuff to menus + show chat box when hovering over some things very ugly but i dont care, the hud stuff is done similar just hoping this doesent explode or whatever --- src/hu_stuff.c | 29 ++++++++++++----- src/m_menu.c | 6 ++++ src/m_menu.h | 2 +- src/m_menudefs.c | 83 +++++++++++++++++++++++++++++------------------- 4 files changed, 79 insertions(+), 41 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 0013900f6..77931550d 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2291,7 +2291,22 @@ void HU_DrawSongCredits(void) } } +static void HU_ForceShowChat(void) +{ + // only matters for non console chat + // see m_menu for how forceshowchat is set + if (!chat_on && forceshowchat) + { + // only print this if theres nothing in chat already + if (chat_nummsg_log == 0) + { + HU_AddChatText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", false); + } + HU_DrawChat(); + } +} + // Heads up displays drawer, call each frame // void HU_Drawer(void) @@ -2299,6 +2314,8 @@ void HU_Drawer(void) if (cv_vhseffect.value && ((paused && !camera[R_GetViewNumber()].freecam) || (demo.playback && cv_playbackspeed.value > 1))) V_DrawVhsEffect(demo.rewinding); + HU_ForceShowChat(); + // draw chat string plus cursor if (chat_on) { @@ -2378,8 +2395,7 @@ void HU_Drawer(void) // IN-LEVEL MULTIPLAYER RANKINGS //====================================================================== -static int -Ping_gfx_num (int lag) +static int Ping_gfx_num(int lag) { if (lag < 2) return 0; @@ -2393,8 +2409,7 @@ Ping_gfx_num (int lag) return 4; } -static int -Ping_gfx_color (UINT32 lag) +static int Ping_gfx_color(UINT32 lag) { if (lag < 2) return SKINCOLOR_JAWZ; @@ -2417,8 +2432,7 @@ Ping_gfx_color (UINT32 lag) return SKINCOLOR_WHITE; // to make the flashing work } -static const UINT8 * -Ping_gfx_colormap (UINT32 lag, boolean gentleman) +static const UINT8 *Ping_gfx_colormap(UINT32 lag, boolean gentleman) { const UINT8 *colormap = NULL; @@ -2438,8 +2452,7 @@ Ping_gfx_colormap (UINT32 lag, boolean gentleman) return colormap; } -static UINT32 -Ping_conversion (UINT32 lag) +static UINT32 Ping_conversion(UINT32 lag) { if (cv_pingmeasurement.value) { diff --git a/src/m_menu.c b/src/m_menu.c index 9e7a7b1c1..f8742c35f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -411,6 +411,7 @@ static INT32 M_GetFirstLevelInList(void); // crap to force hud to show when in saturns hud options boolean forceshowhud = false; +boolean forceshowchat = false; // smol text indicating if game is modified // so ppl dont wonder where their ra times went and stuff @@ -1599,6 +1600,9 @@ static boolean ShouldDrawMenuBG(void) if (forceshowhud) return false; + if (forceshowchat) + return false; + // camera options stuff, only do when in level if (gamestate == GS_LEVEL && (currentMenu == &OP_CamOptionsDef || currentMenu == &OP_Player1CamOptionsDef @@ -1619,7 +1623,9 @@ void M_Drawer(void) if (currentMenu == &MessageDef) menuactive = true; + // pain and suffering forceshowhud = (gamestate == GS_LEVEL && menuactive && (currentMenu == &OP_SaturnHudDef || currentMenu == &OP_HudOffsetDef || currentMenu == &OP_NametagDef || currentMenu == &OP_DriftGaugeDef)); // holy fuick + forceshowchat = (gamestate == GS_LEVEL && menuactive && currentMenu == &OP_ChatOptionsDef && (!OLDCHAT) && (itemOn == op_chat_boxwidth || itemOn == op_chat_boxheight || itemOn == op_chat_xoffs || itemOn == op_chat_yoffs)); // man i dont gaf anymore lmao if (menuactive) { diff --git a/src/m_menu.h b/src/m_menu.h index b1070bdc5..c8fe7b4c2 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -26,7 +26,7 @@ extern "C" { #include "mserv.h" #include "r_things.h" // for SKINNAMESIZE -extern boolean forceshowhud; +extern boolean forceshowhud, forceshowchat; // // MENUS diff --git a/src/m_menudefs.c b/src/m_menudefs.c index c06df7a26..ffb47ded4 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -446,25 +446,25 @@ enum static menuitem_t SP_ReplayMenu[] = { - {IT_WHITESTRING|IT_CALL, NULL, "Replay Best Time", M_ReplayTimeAttack, 90}, - {IT_WHITESTRING|IT_CALL, NULL, "Replay Best Lap", M_ReplayTimeAttack, 98}, + {IT_WHITESTRING|IT_CALL, NULL, "Replay Best Time", M_ReplayTimeAttack, 90}, + {IT_WHITESTRING|IT_CALL, NULL, "Replay Best Lap", M_ReplayTimeAttack, 98}, - {IT_WHITESTRING|IT_CALL, NULL, "Replay Last", M_ReplayTimeAttack, 106}, - {IT_WHITESTRING|IT_CALL, NULL, "Replay Guest", M_ReplayTimeAttack, 114}, - {IT_WHITESTRING|IT_KEYHANDLER, NULL, "Replay Staff",M_HandleStaffReplay,122}, + {IT_WHITESTRING|IT_CALL, NULL, "Replay Last", M_ReplayTimeAttack, 106}, + {IT_WHITESTRING|IT_CALL, NULL, "Replay Guest", M_ReplayTimeAttack, 114}, + {IT_WHITESTRING|IT_KEYHANDLER, NULL, "Replay Staff",M_HandleStaffReplay, 122}, - {IT_WHITESTRING|IT_SUBMENU, NULL, "Back", &SP_TimeAttackDef, 130} + {IT_WHITESTRING|IT_SUBMENU, NULL, "Back", &SP_TimeAttackDef, 130} }; static menuitem_t SP_GuestReplayMenu[] = { - {IT_WHITESTRING|IT_CALL, NULL, "Save Best Time as Guest", M_SetGuestReplay, 94}, - {IT_WHITESTRING|IT_CALL, NULL, "Save Best Lap as Guest", M_SetGuestReplay,102}, - {IT_WHITESTRING|IT_CALL, NULL, "Save Last as Guest", M_SetGuestReplay,110}, + {IT_WHITESTRING|IT_CALL, NULL, "Save Best Time as Guest", M_SetGuestReplay, 94}, + {IT_WHITESTRING|IT_CALL, NULL, "Save Best Lap as Guest", M_SetGuestReplay, 102}, + {IT_WHITESTRING|IT_CALL, NULL, "Save Last as Guest", M_SetGuestReplay, 110}, - {IT_WHITESTRING|IT_CALL, NULL, "Delete Guest Replay", M_SetGuestReplay,120}, + {IT_WHITESTRING|IT_CALL, NULL, "Delete Guest Replay", M_SetGuestReplay, 120}, - {IT_WHITESTRING|IT_SUBMENU, NULL, "Back", &SP_TimeAttackDef, 130} + {IT_WHITESTRING|IT_SUBMENU, NULL, "Back", &SP_TimeAttackDef, 130} }; static menuitem_t SP_GhostMenu[] = @@ -1010,7 +1010,6 @@ enum #endif }; - #ifdef HWRENDER static menuitem_t OP_OpenGLOptionsMenu[] = { @@ -1067,7 +1066,6 @@ enum op_gl_shearing, op_gl_renderdist, }; - #endif static menuitem_t OP_SoundOptionsMenu[] = @@ -1078,8 +1076,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music", &cv_gamedigimusic, 30}, {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "Music Volume", &cv_digmusicvolume, 38}, -//#ifndef NO_MIDI -#if 0 +#if 0 //#ifndef NO_MIDI {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "MIDI Volume", &cv_midimusicvolume, 46}, {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, @@ -1114,8 +1111,7 @@ static const char* OP_SoundTooltips[] = "Volume of Sound effects.", "Turn Music on or off.", "Volume of Music.", -//#ifndef NO_MIDI -#if 0 +#if 0 //#ifndef NO_MIDI "Volume of Midi Music.", #endif "Reverse left and right channels of audio.", @@ -1409,32 +1405,36 @@ static const char* OP_PlayerCamOptionsTooltips[] = static menuitem_t OP_ChatOptionsMenu[] = { // will ANYONE who doesn't know how to use the console want to touch this one? - {IT_STRING | IT_CVAR, NULL, "Chat Mode", &cv_consolechat, 5}, // nonetheless... + {IT_STRING | IT_CVAR, NULL, "Chat Mode", &cv_consolechat, 5}, // nonetheless... {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Chat Box Width", &cv_chatwidth, 20}, + NULL, "Chat Box Width", &cv_chatwidth, 20}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Chat Box Height", &cv_chatheight, 30}, - {IT_STRING | IT_CVAR, NULL, "Center Text in Chat", &cv_chatcentertext, 40}, + NULL, "Chat Box Height", &cv_chatheight, 30}, + {IT_STRING | IT_CVAR, NULL, "Chat Horizontal Offset", &cv_chat_xoffset, 40}, + {IT_STRING | IT_CVAR, NULL, "Chat Vertical Offset", &cv_chat_yoffset, 50}, - {IT_STRING | IT_CVAR, NULL, "Chat Background Tint", &cv_chatbacktint, 55}, - {IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 65}, - {IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 75}, - {IT_STRING | IT_CVAR, NULL, "Max Chat Messages", &cv_chatlogsize, 85}, + {IT_STRING | IT_CVAR, NULL, "Center Text in Chat", &cv_chatcentertext, 70}, + {IT_STRING | IT_CVAR, NULL, "Chat Background Tint", &cv_chatbacktint, 80}, + {IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 90}, + {IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 100}, + {IT_STRING | IT_CVAR, NULL, "Max Chat Messages", &cv_chatlogsize, 110}, - {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 105}, // shows ping above the framerate if we want to. - {IT_STRING | IT_CVAR, NULL, "Ping display style", &cv_pingstyle, 115}, - {IT_STRING | IT_CVAR, NULL, "Ping measurement", &cv_pingmeasurement, 125}, - {IT_STRING | IT_CVAR, NULL, "Ping icon", &cv_pingicon, 135}, + {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 130}, // shows ping above the framerate if we want to. + {IT_STRING | IT_CVAR, NULL, "Ping display style", &cv_pingstyle, 140}, + {IT_STRING | IT_CVAR, NULL, "Ping measurement", &cv_pingmeasurement, 150}, + {IT_STRING | IT_CVAR, NULL, "Ping icon", &cv_pingicon, 160}, - {IT_STRING | IT_CVAR, NULL, "Show IP address in playerlist", &cv_shownodeip, 145}, + {IT_STRING | IT_CVAR, NULL, "Show IP address in playerlist", &cv_shownodeip, 170}, }; static const char* OP_ChatOptionsTooltips[] = { "Chat mode used for in-game chat.", - "Width of chat box.", - "Height of chat box.", + "Width of the chat box.", + "Height of the chat box.", + "Horizontal Offset of the chat box.", + "Vertical Offset of the chat box.", "Center text in the chat message pop ups.", "Background for the chat message pop ups.", "Fadeout time for new chat message.", @@ -1447,6 +1447,25 @@ static const char* OP_ChatOptionsTooltips[] = "Should Player IP addresses be printed when using\nthe nodes or listplayers command?", }; +enum +{ + op_chat_mode, + op_chat_boxwidth, + op_chat_boxheight, + op_chat_yoffs, + op_chat_xoffs, + op_chat_centertxt, + op_chat_bgtint, + op_chat_fadetime, + op_chat_spamprotect, + op_chat_maxmsg, + op_chat_showping, + op_chat_pingstyle, + op_chat_pingmeasr, + op_chat_pingico, + op_chat_nodeip, +}; + static menuitem_t OP_GameOptionsMenu[] = { {IT_STRING | IT_SUBMENU, NULL, "Random Item Toggles...", &OP_MonitorToggleDef, 10}, From 352d1faacfd058699c29d5cc7f33f48122f9c7dc Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 18:59:21 +0200 Subject: [PATCH 444/589] forgor cv_chat_showlimit :chaosleep: --- src/m_menu.c | 10 ++++++---- src/m_menudefs.c | 13 ++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index f8742c35f..dc4cbcc87 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1605,9 +1605,11 @@ static boolean ShouldDrawMenuBG(void) // camera options stuff, only do when in level if (gamestate == GS_LEVEL && - (currentMenu == &OP_CamOptionsDef || currentMenu == &OP_Player1CamOptionsDef - || currentMenu == &OP_Player2CamOptionsDef || currentMenu == &OP_Player3CamOptionsDef - || currentMenu == &OP_Player4CamOptionsDef)) + (currentMenu == &OP_CamOptionsDef || + currentMenu == &OP_Player1CamOptionsDef || + currentMenu == &OP_Player2CamOptionsDef || + currentMenu == &OP_Player3CamOptionsDef || + currentMenu == &OP_Player4CamOptionsDef)) return false; return true; @@ -1625,7 +1627,7 @@ void M_Drawer(void) // pain and suffering forceshowhud = (gamestate == GS_LEVEL && menuactive && (currentMenu == &OP_SaturnHudDef || currentMenu == &OP_HudOffsetDef || currentMenu == &OP_NametagDef || currentMenu == &OP_DriftGaugeDef)); // holy fuick - forceshowchat = (gamestate == GS_LEVEL && menuactive && currentMenu == &OP_ChatOptionsDef && (!OLDCHAT) && (itemOn == op_chat_boxwidth || itemOn == op_chat_boxheight || itemOn == op_chat_xoffs || itemOn == op_chat_yoffs)); // man i dont gaf anymore lmao + forceshowchat = (gamestate == GS_LEVEL && menuactive && currentMenu == &OP_ChatOptionsDef && (!OLDCHAT) && (itemOn == op_chat_boxwidth || itemOn == op_chat_boxheight || itemOn == op_chat_xoffs || itemOn == op_chat_yoffs || itemOn == op_chat_charlmt)); // man i dont gaf anymore lmao if (menuactive) { diff --git a/src/m_menudefs.c b/src/m_menudefs.c index ffb47ded4..7eecdb0f6 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1419,13 +1419,14 @@ static menuitem_t OP_ChatOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 90}, {IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 100}, {IT_STRING | IT_CVAR, NULL, "Max Chat Messages", &cv_chatlogsize, 110}, + {IT_STRING | IT_CVAR, NULL, "Display Character Limit", &cv_chat_showlimit, 120}, - {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 130}, // shows ping above the framerate if we want to. - {IT_STRING | IT_CVAR, NULL, "Ping display style", &cv_pingstyle, 140}, - {IT_STRING | IT_CVAR, NULL, "Ping measurement", &cv_pingmeasurement, 150}, - {IT_STRING | IT_CVAR, NULL, "Ping icon", &cv_pingicon, 160}, + {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 140}, // shows ping above the framerate if we want to. + {IT_STRING | IT_CVAR, NULL, "Ping display style", &cv_pingstyle, 150}, + {IT_STRING | IT_CVAR, NULL, "Ping measurement", &cv_pingmeasurement, 160}, + {IT_STRING | IT_CVAR, NULL, "Ping icon", &cv_pingicon, 170}, - {IT_STRING | IT_CVAR, NULL, "Show IP address in playerlist", &cv_shownodeip, 170}, + {IT_STRING | IT_CVAR, NULL, "Show IP address in playerlist", &cv_shownodeip, 180}, }; static const char* OP_ChatOptionsTooltips[] = @@ -1440,6 +1441,7 @@ static const char* OP_ChatOptionsTooltips[] = "Fadeout time for new chat message.", "Spam protection for in-game chat.", "Maxiumum amount of chat messages to look back at.", + "Show how many characters you have left to type in the chat.", "Show player ping.", "Choose the style of the ping display.", "Measurement used for ping.", @@ -1459,6 +1461,7 @@ enum op_chat_fadetime, op_chat_spamprotect, op_chat_maxmsg, + op_chat_charlmt, op_chat_showping, op_chat_pingstyle, op_chat_pingmeasr, From 80e4d02c51cd4a5a5bb60b554434a4d0869ba6a6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 21:02:10 +0200 Subject: [PATCH 445/589] dont skip intro sounds if music is disabled --- src/s_sound.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/s_sound.c b/src/s_sound.c index a95fc39c0..050b2c932 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2039,6 +2039,10 @@ static boolean S_SkipIntroMusic(void) if (!cv_skipintromusic.value) return false; + // dont skip if we disabled music, weird? but this would skip sounds that play on map start as well otherwise + if (music_disabled) + return false; + // check if menu music is playing, otherwise it may continue playing if (fasticmp(music.name, "titles")) return false; @@ -2050,6 +2054,11 @@ static boolean S_SkipIntroMusic(void) return false; } + // without sound there wont be any intro playing + if (sound_disabled) + return true; + // yes i sometimes play with only music but no sound + return true; } From 1bcadf3c46839d68ba1a4d3e5e3d701a559b1ff3 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 22:23:25 +0200 Subject: [PATCH 446/589] fix the lap emblem animation thingie --- src/k_hud.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 0ad2d3b3f..0e3afb67d 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4397,6 +4397,9 @@ static void K_drawChallengerScreen(void) static void K_drawLapStartAnim(void) { + if (!cv_showlapemblem.value) + return; + // This is an EVEN MORE insanely complicated animation. const UINT8 progress = 80-stplyr->kartstuff[k_lapanimation]; UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); @@ -4440,9 +4443,10 @@ static void K_drawLapStartAnim(void) V_DrawFixedPatch(leftx, y, FRACUNIT, vflags, kp_lapanim_lap[min(progress/2, 6)], NULL); char *lapnum = va("%02d", stplyr->laps + 1); - const size_t laplength = strlen(lapnum); - for (size_t i = 0; i < laplength; i++) + const int laplength = (int)strlen(lapnum); + + for (int i = 0; i < laplength; i++) { int digit = lapnum[i] - '0'; int frame = min(2, progress/2 - 8 - (i*2)); @@ -4824,7 +4828,7 @@ void K_drawKartHUD(void) { if (stplyr->exiting) K_drawKartFinish(); - else if (stplyr->kartstuff[k_lapanimation] && !splitscreen && cv_showlapemblem.value) + else if (stplyr->kartstuff[k_lapanimation] && !splitscreen) K_drawLapStartAnim(); } From d687be4997caca9ac5d6ccb568e3414b60671175 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 22:34:02 +0200 Subject: [PATCH 447/589] change K_GetSpeedometerStyle to unsinged does not need be signed most other things will cache this into an uint8 eitherway --- src/k_hud.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_hud.c b/src/k_hud.c index 0e3afb67d..0deb8f0f5 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1146,7 +1146,7 @@ enum SPEEDO_PMETERSMOL, }; -static SINT8 K_GetSpeedometerStyle(void) +static UINT8 K_GetSpeedometerStyle(void) { if (cv_newspeedometer.value == 2 && xtra_speedo) return SPEEDO_EXTRA; From 4b8f998c85a6899b0d5a9e12f47f17f98631ef7e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 28 Jun 2026 22:58:11 +0200 Subject: [PATCH 448/589] cast this crap --- src/p_setup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index fe583b406..6d790262e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -456,10 +456,10 @@ static void P_SetupDirectionalLight(void) if (gamemap != oldmap || encoremode != oldencore || reinitmaplight) { - lighting->light_contrast = M_RandomRange(0, 58); + lighting->light_contrast = (UINT8)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); + lighting->use_light_angle = (boolean)M_RandomRange(0, 1); // either on or off + lighting->light_angle = (angle_t)M_RandomRange(-382, 382); reinitmaplight = false; } From ea76af5a816ae7323a3fe328a3ce902024110467 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jun 2026 01:46:30 +0200 Subject: [PATCH 449/589] seenames is stupid keep that ashnal utils breaks without this crap --- src/doomdef.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/doomdef.h b/src/doomdef.h index d4c9d63fa..b57ab0bfb 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -678,7 +678,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #ifndef COMPAT_VANILLA #define SATURNJOIN #define SATURNPAK - #undef SEENAMES #endif #ifdef __cplusplus From 4eb108e0a699f4770aa4daa3579252257a2d524d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jun 2026 02:13:47 +0200 Subject: [PATCH 450/589] add sound thing for reference does nothing cause it sucks maybe someone else has a better idea what to do here --- src/p_map.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_map.c b/src/p_map.c index 06e666a28..c620fc292 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2592,6 +2592,12 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) positives, so just ignore them entirely. */ if (stairjank && !oldslope && !thing->standingslope && thing->player && !thing->player->spectator) { + /* use a shorter sound if not two tics have passed + * since the last step */ + //S_ReducedVFXSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268), NULL); + //S_StartSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268)); + // sound does not work out all that well for kart maps + // TODO: maybe spawn smol dust effect similar to RR? /*if (!thing->player->stairjank) { From f43a4a2eb619ce44555a6d7b0548adf565c5efa9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jun 2026 02:14:45 +0200 Subject: [PATCH 451/589] have gametype i_error actually print the invalid gametype bit more informative ig? --- src/d_clisrv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 492dd0ac4..8cb038251 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -841,11 +841,13 @@ static void resynch_write_ctf(resynchend_pak *rst) rst->flagplayer[i] = (SINT8)j; break; } + if (j == MAXPLAYERS) // fine, no I_Error { CONS_Alert(CONS_ERROR, "One of the flags has gone completely missing...\n"); rst->flagplayer[i] = -2; } + continue; } @@ -1135,6 +1137,7 @@ static void CV_SavePlayerNames(UINT8 **p) WRITEUINT8(*p, 0); continue; } + WRITESTRING(*p, player_names[i]); } } @@ -1148,10 +1151,13 @@ static void CV_LoadPlayerNames(UINT8 **p) for (; i < MAXPLAYERS; ++i) { READSTRING(*p, tmp_name); + if (tmp_name[0] == 0) continue; + if (tmp_name[MAXPLAYERNAME]) // overflow detected I_Error("Received bad server config packet when trying to join"); + memcpy(player_names[i], tmp_name, MAXPLAYERNAME+1); } } @@ -2029,6 +2035,7 @@ static void SV_SendSaveGame(INT32 node, boolean resending) P_SaveNetGame(&save, resending); length = save.p - save.buffer; + if (length > SAVEGAMESIZE) { Z_Free(save.buffer); @@ -5401,7 +5408,7 @@ static void PT_ServerCFG(SINT8 node) { maketic = gametic = neededtic = (tic_t)LONG(netbuffer->u.servercfg.gametic); if ((gametype = netbuffer->u.servercfg.gametype) >= NUMGAMETYPES) - I_Error("Bad gametype in cliserv!"); + I_Error("Bad gametype %d in cliserv!", gametype); modifiedgame = netbuffer->u.servercfg.modifiedgame; for (j = 0; j < MAXPLAYERS; j++) adminplayers[j] = netbuffer->u.servercfg.adminplayers[j]; From 00aa023e9eca184d2476a1294d85a943dde81193 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jun 2026 14:42:58 +0200 Subject: [PATCH 452/589] cleanup p_setup a bit again --- src/m_menu.c | 28 +++---- src/p_setup.c | 208 ++++++++++++++++++++++++++++++-------------------- src/p_spec.c | 10 ++- 3 files changed, 148 insertions(+), 98 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index dc4cbcc87..cf9f433e6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -212,12 +212,12 @@ static INT32 setupm_fakeskin; static INT32 setupm_fakecolor; static UINT8 setupm_pselect = 1; -//variables used for other skin select menus +// variables used for other skin select menus static UINT8 setupm_skinypos; static INT32 setupm_skinselect; static boolean setupm_skinlockedselect; -static UINT8 setupm_playernum; //brap +static UINT8 setupm_playernum; // brap // Addons Menu: Local mode static void M_LocalAddons(INT32 choice); @@ -450,13 +450,13 @@ consvar_t cv_showallmaps = {"showallmaps", "No", CV_SAVE, CV_YesNo, NULL, 0, NUL consvar_t cv_showmusicfilename = {"showmusicfilename", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t serversort_cons_t[] = { - {0,"Ping"}, - {1,"Modified State"}, - {2,"Most Players"}, - {3,"Least Players"}, - {4,"Max Player Slots"}, - {5,"Gametype"}, - {0,NULL} + {0, "Ping"}, + {1, "Modified State"}, + {2, "Most Players"}, + {3, "Least Players"}, + {4, "Max Player Slots"}, + {5, "Gametype"}, + {0, NULL} }; consvar_t cv_serversort = {"serversort", "Ping", CV_CALL, serversort_cons_t, M_SortServerList, 0, NULL, NULL, 0, 0, NULL}; @@ -705,7 +705,7 @@ static void Dummystaff_OnChange(void) dummystaffname[0] = '\0'; - if ((l = W_CheckNumForName(va("%sS01",G_BuildMapName(cv_nextmap.value)))) == LUMPERROR) + if ((l = W_CheckNumForName(va("%sS01", G_BuildMapName(cv_nextmap.value)))) == LUMPERROR) { CV_StealthSetValue(&cv_dummystaff, 0); return; @@ -714,7 +714,7 @@ static void Dummystaff_OnChange(void) { char *temp = dummystaffname; UINT8 numstaff = 1; - while (numstaff < 99 && (l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(cv_nextmap.value),numstaff+1))) != LUMPERROR) + while (numstaff < 99 && (l = W_CheckNumForName(va("%sS%02u", G_BuildMapName(cv_nextmap.value), numstaff+1))) != LUMPERROR) numstaff++; if (cv_dummystaff.value < 1) @@ -722,7 +722,7 @@ static void Dummystaff_OnChange(void) else if (cv_dummystaff.value > numstaff) CV_StealthSetValue(&cv_dummystaff, 1); - if ((l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(cv_nextmap.value), cv_dummystaff.value))) == LUMPERROR) + if ((l = W_CheckNumForName(va("%sS%02u", G_BuildMapName(cv_nextmap.value), cv_dummystaff.value))) == LUMPERROR) return; // shouldn't happen but might as well check... G_UpdateStaffGhostName(l); @@ -807,7 +807,8 @@ static void M_ChangeCvar(INT32 choice) CV_SetValue(cv,skins[skinno].prefcolor); return; } - CV_Set(cv,cv->defaultvalue); + + CV_Set(cv, cv->defaultvalue); return; } @@ -956,6 +957,7 @@ static void Command_Manual_f(void) { if (modeattacking) return; + M_StartControlPanel(); M_Manual(INT32_MAX); itemOn = 0; diff --git a/src/p_setup.c b/src/p_setup.c index 6d790262e..bd43174f3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2559,6 +2559,24 @@ static void P_LoadRecordGhosts(void) free(gpath); } +static void P_ResetSpawnpoints(void) +{ + UINT8 i; + + 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; + } +} + static void P_InitCamera(void) { INT32 i; @@ -2568,6 +2586,7 @@ static void P_InitCamera(void) for (i = 0; i <= splitscreen; i++) { + camera[i].postimg = 0; P_SetupCamera(&camera[i]); } @@ -2667,10 +2686,14 @@ static boolean P_RunSpecialWipe(boolean reloadinggamestate) { // Cancel all d_main.c fadeouts (keep fade in though). if (reloadinggamestate) + { wipegamestate = gamestate; // Don't fade if reloading the gamestate + return false; + } + // Encore mode fade to pink to white // This is handled BEFORE sounds are stopped. - else if (encoremode && !prevencoremode && !demo.rewinding) + if (encoremode && !prevencoremode && !demo.rewinding) { tic_t locstarttime, endtime, nowtime; @@ -2704,6 +2727,8 @@ static boolean P_RunSpecialWipe(boolean reloadinggamestate) // Hold on white for extra effect. while (nowtime < endtime) { + I_HandleInterrupt(); + // wait loop while (!((nowtime = I_GetTime()) - lastwipetic)) { @@ -2726,6 +2751,69 @@ static boolean P_RunSpecialWipe(boolean reloadinggamestate) return false; } +static void P_InitTagGametype(void) +{ + UINT8 i; + INT32 realnumplayers = 0; + INT32 playersactive[MAXPLAYERS]; + + //I just realized how problematic this code can be. + //D_NumPlayers() will not always cover the scope of the netgame. + //What if one player is node 0 and the other node 31? + //The solution? Make a temp array of all players that are currently playing and pick from them. + //Future todo? When a player leaves, shift all nodes down so D_NumPlayers() can be used as intended? + //Also, you'd never have to loop through all 32 players slots to find anything ever again. + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && !players[i].spectator) + { + playersactive[realnumplayers] = i; //stores the player's node in the array. + realnumplayers++; + } + } + + if (!realnumplayers) // this should also fix the dedicated crash bug. You only pick a player if one exists to be picked. + { + CONS_Printf(M_GetText("No player currently available to become IT. Awaiting available players.\n")); + return; + } + + i = P_RandomKey(realnumplayers); + players[playersactive[i]].pflags |= PF_TAGIT; //choose our initial tagger before map starts. + + // Taken and modified from G_DoReborn() + // Remove the player so he can respawn elsewhere. + // first dissasociate the corpse + if (players[playersactive[i]].mo) + P_RemoveMobj(players[playersactive[i]].mo); + + G_SpawnPlayer(playersactive[i], false); //respawn the lucky player in his dedicated spawn location. +} + +static void P_InitGametype(void) +{ + if (modeattacking == ATTACKING_RECORD && !demo.playback) + P_LoadRecordGhosts(); + + if (G_RaceGametype() && server) + { + INT32 numLaps; + const mapheader_t *mapheader = mapheaderinfo[gamemap - 1]; + + if ((netgame || multiplayer) && cv_basenumlaps.value && + (!(mapheader->levelflags & LF_SECTIONRACE) || (mapheader->numlaps > cv_basenumlaps.value))) + numLaps = cv_basenumlaps.value; + else + numLaps = mapheader->numlaps; + + CV_StealthSetValue(&cv_numlaps, numLaps); + } + else if (G_TagGametype()) + { + P_InitTagGametype(); + } +} + static void P_SetupPlayer(void) { INT32 i; @@ -2752,63 +2840,14 @@ static void P_SetupPlayer(void) } } - if (modeattacking == ATTACKING_RECORD && !demo.playback) - P_LoadRecordGhosts(); - - if (G_TagGametype()) - { - INT32 realnumplayers = 0; - INT32 playersactive[MAXPLAYERS]; - - //I just realized how problematic this code can be. - //D_NumPlayers() will not always cover the scope of the netgame. - //What if one player is node 0 and the other node 31? - //The solution? Make a temp array of all players that are currently playing and pick from them. - //Future todo? When a player leaves, shift all nodes down so D_NumPlayers() can be used as intended? - //Also, you'd never have to loop through all 32 players slots to find anything ever again. - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator) - { - playersactive[realnumplayers] = i; //stores the player's node in the array. - realnumplayers++; - } - } - - if (realnumplayers) // this should also fix the dedicated crash bug. You only pick a player if one exists to be picked. - { - i = P_RandomKey(realnumplayers); - players[playersactive[i]].pflags |= PF_TAGIT; //choose our initial tagger before map starts. - - // Taken and modified from G_DoReborn() - // Remove the player so he can respawn elsewhere. - // first dissasociate the corpse - if (players[playersactive[i]].mo) - P_RemoveMobj(players[playersactive[i]].mo); - - G_SpawnPlayer(playersactive[i], false); //respawn the lucky player in his dedicated spawn location. - } - else - CONS_Printf(M_GetText("No player currently available to become IT. Awaiting available players.\n")); - - } - else if (G_RaceGametype() && server) - { - INT32 numLaps = ((netgame || multiplayer) && cv_basenumlaps.value - && (!(mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE) - || (mapheaderinfo[gamemap - 1]->numlaps > cv_basenumlaps.value))) - ? cv_basenumlaps.value - : mapheaderinfo[gamemap - 1]->numlaps; - - CV_StealthSetValue(&cv_numlaps, numLaps); - } + P_InitGametype(); // Start recording replay in multiplayer with a temp filename // Ensure dedis only record a replay if there is a player at the start of the map, otherwise we get invalid replays! if (!demo.playback && multiplayer && D_NumPlayers()) { static char buf[256]; - sprintf(buf, "replay"PATHSEP"online"PATHSEP"%d-%s", (int) (time(NULL)), G_BuildMapName(gamemap)); + sprintf(buf, "replay"PATHSEP"online"PATHSEP"%d-%s", (int)(time(NULL)), G_BuildMapName(gamemap)); I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); I_mkdir(va("%s"PATHSEP"replay"PATHSEP"online", srb2home), 0755); @@ -2910,9 +2949,10 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // 99% of the things already did, so. // Map header should always be in place at this point INT32 i; + UINT8 levelfadecol; boolean ranspecialwipe = false; lumpnum_t encoreLump = LUMPERROR; - UINT8 levelfadecol; + const mapheader_t *mapheader = mapheaderinfo[gamemap - 1]; midgamejoin = fromnetsave; // makes dynslopes run in P_Ticker to avoid synch issues and other stuff @@ -2920,7 +2960,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) levelloading = true; // This is needed. Don't touch. - maptol = mapheaderinfo[gamemap-1]->typeoflevel; + maptol = mapheader->typeoflevel; CON_Drawer(); // let the user know what we are going to do I_FinishUpdate(); // page flip or blit buffer @@ -2931,17 +2971,17 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // Clear CECHO messages HU_ClearCEcho(); - if (mapheaderinfo[gamemap-1]->runsoc[0] != '#') - P_RunSOC(mapheaderinfo[gamemap-1]->runsoc); + if (mapheader->runsoc[0] != '#') + P_RunSOC(mapheader->runsoc); - if (cv_runscripts.value && mapheaderinfo[gamemap-1]->scriptname[0] != '#') - P_RunLevelScript(mapheaderinfo[gamemap-1]->scriptname); + if (cv_runscripts.value && mapheader->scriptname[0] != '#') + P_RunLevelScript(mapheader->scriptname); P_LevelInitStuff(reloadinggamestate); - if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0' - && atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255) - P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter); + if (mapheader->forcecharacter[0] != '\0' + && atoi(mapheader->forcecharacter) != 255) + P_ForceCharacter(mapheader->forcecharacter); // Initial height of PointOfView // will be set by player think. @@ -2991,10 +3031,10 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) char tx[64]; V_DrawSmallString(1, 191, V_ALLOWLOWERCASE, M_GetText("Speeding off to...")); snprintf(tx, 63, "%s%s%s", - mapheaderinfo[gamemap-1]->lvlttl, - (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart - ((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " Zone"), - (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) ? va(", Act %s",mapheaderinfo[gamemap-1]->actnum) : ""); + mapheader->lvlttl, + (strlen(mapheader->zonttl) > 0) ? va(" %s",mapheader->zonttl) : // SRB2kart + ((mapheader->levelflags & LF_NOZONE) ? "" : " Zone"), + (strlen(mapheader->actnum) > 0) ? va(", Act %s",mapheader->actnum) : ""); V_DrawSmallString(1, 195, V_ALLOWLOWERCASE, tx); I_UpdateNoVsync(); }*/ @@ -3013,20 +3053,16 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) curmapvirt = vres_GetMap(lastloadedmaplumpnum); encoreLump = W_CheckNumForName(va("%s%c", maplumpname, (encoremode ? 'E' : 'T'))); - R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, encoreLump); + R_ReInitColormaps(mapheader->palette, encoreLump); CON_SetupBackColormap(); // SRB2 determines the sky texture to be used depending on the map header. - P_SetupLevelSky(mapheaderinfo[gamemap-1]->skynum, true); + P_SetupLevelSky(mapheader->skynum, true); - numdmstarts = numredctfstarts = numbluectfstarts = 0; + P_ResetSpawnpoints(); - // reset the player starts - memset(playerstarts, 0, sizeof(playerstarts)); - memset(skyboxmo, 0, sizeof(skyboxmo)); - - P_MapStart(); + P_MapStart(); // tmthing can be used starting from this point P_LoadMapFromFile(); @@ -3046,7 +3082,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) if (!playerstarts[numcoopstarts]) break; - globalweather = mapheaderinfo[gamemap-1]->weather; + globalweather = mapheader->weather; // set up world state P_SpawnSpecials(fromnetsave, reloadinggamestate); @@ -3093,7 +3129,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // clear special respawning que iquehead = iquetail = 0; - P_MapEnd(); + P_MapEnd(); // tmthing is no longer needed from this point onwards // Remove the loading shit from the screen if (rendermode != render_none && !reloadinggamestate) @@ -3124,9 +3160,15 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) savedata.lives = 0; } - // assume the skybox is visible on level load. - skyVisible = true; - memset(skyVisiblePerPlayer, true, sizeof(skyVisiblePerPlayer)); + if (!reloadinggamestate) + { + // assume the skybox is visible on level load. + skyVisible = true; + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + skyVisiblePerPlayer[i] = true; + } + } if (!fromnetsave) // uglier hack { // to make a newly loaded level start on the second frame. @@ -3146,14 +3188,18 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) LUA_HookInt(gamemap, HOOK(MapLoad)); } - if (rendermode != render_none && !reloadinggamestate) + // reloading gamestate, stop here. + if (reloadinggamestate) + return true; + + G_AddMapToBuffer(gamemap-1); + + if (rendermode != render_none) { R_ResetViewInterpolation(0); R_UpdateMobjInterpolators(); } - G_AddMapToBuffer(gamemap-1); - G_ResetDeviceLED(); return true; diff --git a/src/p_spec.c b/src/p_spec.c index 1bcbebdf5..9aff26b3c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -538,6 +538,7 @@ static sector_t *getNextSector(line_t *line, sector_t *sec) else return NULL; } + return line->frontsector; } @@ -568,6 +569,7 @@ fixed_t P_FindLowestFloorSurrounding(sector_t *sec) if (other->floorheight < floorh) floorh = other->floorheight; } + return floorh; } @@ -1180,7 +1182,7 @@ INT32 P_FindMinSurroundingLight(sector_t *sector, INT32 max) for (i = 0; i < sector->linecount; i++) { line = sector->lines[i]; - check = getNextSector(line,sector); + check = getNextSector(line, sector); if (!check) continue; @@ -2098,7 +2100,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) ffloor_t *rover; boolean foundit = false; - for(rover = mo->subsector->sector->ffloors; rover; rover = rover->next) + for (rover = mo->subsector->sector->ffloors; rover; rover = rover->next) { if (rover->master->frontsector->tag != line->tag) continue; @@ -2988,10 +2990,10 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n { fixed_t topheight, bottomheight; - if (GETSECSPECIAL(rover->master->frontsector->special, section) != number) + if (!(rover->flags & FF_EXISTS)) continue; - if (!(rover->flags & FF_EXISTS)) + if (GETSECSPECIAL(rover->master->frontsector->special, section) != number) continue; topheight = P_GetSpecialTopZ(player->mo, sectors + rover->secnum, player->mo->subsector->sector); From 65c2d2733ddc6aaedc60d8f9606267951c38f3c2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jun 2026 14:40:43 +0200 Subject: [PATCH 453/589] clear deathmatch and ctf spawnpoints aswell prob wont matter much for us but still better to not leave those dangling after map change --- src/p_setup.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index bd43174f3..ec1320aa5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2569,6 +2569,13 @@ static void P_ResetSpawnpoints(void) for (i = 0; i < MAXPLAYERS; i++) { playerstarts[i] = NULL; + redctfstarts[i] = NULL; + bluectfstarts[i] = NULL; + } + + for (i = 0; i < MAX_DM_STARTS; i++) + { + deathmatchstarts[i] = NULL; } for (i = 0; i < 2; i++) From e12ecabcf0aab2284ce848192218576ee8c4fad8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jun 2026 15:35:37 +0200 Subject: [PATCH 454/589] revert some P_IsObjectOnGround pretty sure none of those cause issues currently, but rather not risk stuff as that condition might change from smth else in those cases its not an expensive call anyways really --- src/k_kart.c | 20 +++++++++----------- src/p_map.c | 2 +- src/p_mobj.c | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e3306c629..eb58a7b62 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5019,9 +5019,7 @@ static void K_MoveHeldObjects(player_t *player) mobj_t *cur = player->mo->hnext; mobj_t *targ = player->mo; - const boolean ponground = P_IsObjectOnGround(player->mo); - - if (ponground && player->speed > 0) + if (player->speed > 0 && P_IsObjectOnGround(player->mo)) player->kartstuff[k_bananadrag]++; while (!P_MobjWasRemoved(cur)) @@ -5070,7 +5068,8 @@ static void K_MoveHeldObjects(player_t *player) cur->angle = R_PointToAngle2(cur->x, cur->y, targx, targy); - /*if (P_IsObjectOnGround(player->mo) && player->speed > 0 && player->kartstuff[k_bananadrag] > TICRATE + /*if (player->speed > 0 && P_IsObjectOnGround(player->mo) + && player->kartstuff[k_bananadrag] > TICRATE && P_RandomChance(min(FRACUNIT/2, FixedDiv(player->speed, K_GetKartSpeed(player, false))/2))) { if (leveltime & 1) @@ -5079,8 +5078,9 @@ static void K_MoveHeldObjects(player_t *player) targz -= 8*(2*FRACUNIT)/7; }*/ - if (cv_bananajitter.value && ponground - && player->speed > 0 && player->kartstuff[k_bananadrag] > TICRATE) + // "jitter" dragged bananas around + if (cv_bananajitter.value && + player->speed > 0 && P_IsObjectOnGround(player->mo) && player->kartstuff[k_bananadrag] > TICRATE) { const fixed_t halfpspeed = FixedDiv(player->speed, K_GetKartSpeed(player, false))/2; @@ -5581,8 +5581,6 @@ FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, bool */ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) { - const boolean onground = P_IsObjectOnGround(player->mo); - K_UpdateOffroad(player); K_UpdateEngineSounds(player, cmd); // Thanks, VAda! @@ -5699,7 +5697,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->kartstuff[k_spinouttimer]) { - if ((onground || ((player->kartstuff[k_spinouttype]+1)/2 == 1)) // spinouttype 1 and 2 - explosion and spb + if ((P_IsObjectOnGround(player->mo) || ((player->kartstuff[k_spinouttype]+1)/2 == 1)) // spinouttype 1 and 2 - explosion and spb && (player->kartstuff[k_sneakertimer] == 0)) { player->kartstuff[k_spinouttimer]--; @@ -5798,7 +5796,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (G_BattleGametype() && player->kartstuff[k_bumper] > 0) player->kartstuff[k_wanted]++; - if (onground) + if (P_IsObjectOnGround(player->mo)) player->kartstuff[k_waterskip] = 0; if (player->kartstuff[k_instashield]) @@ -5842,7 +5840,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->kartstuff[k_comebacktimer]) player->kartstuff[k_comebackmode] = 0; - if (onground && player->kartstuff[k_pogospring]) + if (player->kartstuff[k_pogospring] && P_IsObjectOnGround(player->mo)) { if (P_MobjFlip(player->mo)*player->mo->momz <= 0) player->kartstuff[k_pogospring] = 0; diff --git a/src/p_map.c b/src/p_map.c index c620fc292..ef4997293 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2428,7 +2428,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (thing->player) { - if (special == -1) + if (special == -1) // this should use the target coords not the ones were started with, but cant fix that for compat reasons! special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1); // If using type Section1:13, double the maxstep. diff --git a/src/p_mobj.c b/src/p_mobj.c index 12574c031..49916eb50 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7068,7 +7068,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) } P_InstaThrust(mobj, mobj->angle, finalspeed); - + if (grounded) { sector_t *sec2 = P_ThingOnSpecial3DFloor(mobj); From 408db7a2eb627f51a70493e6075fea0966fe60ad Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jun 2026 15:42:29 +0200 Subject: [PATCH 455/589] use G_KeynumToString for local addon menu key info just in case we change them dont have to change them everywhere --- src/m_menu.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index cf9f433e6..38b5e2875 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -221,9 +221,11 @@ static UINT8 setupm_playernum; // brap // Addons Menu: Local mode static void M_LocalAddons(INT32 choice); -#define LOCALMODE_KEY (KEY_RALT) static boolean addons_localmode = false; +#define LOCALMODE_KEY (KEY_RALT) +#define AUTOLOAD_KEY (KEY_END) + // // PROTOTYPES // @@ -3673,10 +3675,10 @@ static void M_DrawAddons(void) //m = numwadfiles-(mainwads+2+1); //V_DrawCenteredString(BASEVIDWIDTH/2, y+24, (majormods ? highlightflags : V_TRANSLUCENT), va("%d ADD-ON%s LOADED", (int)m, (m == 1) ? "" : "S")); //+2 for music, sounds, +1 for main.kart - V_DrawThinString(0, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("END Key - Add addon to autoload")); + V_DrawThinString(0, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, va("%s Key - Add addon to autoload", G_KeynumToString(AUTOLOAD_KEY))); if (Playing() && (server || IsPlayerAdmin(consoleplayer))) - V_DrawThinString(0, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("Right ALT Key - Switch to local addon mode")); + V_DrawThinString(0, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, va("%s Key - Switch to local addon mode", G_KeynumToString(LOCALMODE_KEY))); } static void M_AddonExec(INT32 ch) @@ -3698,7 +3700,7 @@ static void M_AddonAutoLoad(INT32 ch) FILE *autoloadconfigfile; // check our controls // - if (ch != 'y' && ch != KEY_ENTER && ch != KEY_END) + if (ch != 'y' && ch != KEY_ENTER && ch != AUTOLOAD_KEY) { S_StartSound(NULL, sfx_s26d); return; @@ -3712,7 +3714,7 @@ static void M_AddonAutoLoad(INT32 ch) switch (dirmenu[dir_on[menudepthleft]][DIR_TYPE]) { case EXT_FOLDER: - M_StartMessage(va("%c%s\x80\nAutoloading folders is not supported as of yet. \n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING); + M_StartMessage(va("%c%s\x80\nAutoloading folders is not supported as of yet. \n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING), NULL, MM_NOTHING); break; case EXT_TXT: case EXT_CFG: @@ -3899,7 +3901,7 @@ static void M_HandleAddons(INT32 choice) } break; - case KEY_END: + case AUTOLOAD_KEY: { boolean refresh = true; if (!dirmenu[dir_on[menudepthleft]]) From d9e339cb5636b62b7a613805b305231010583250 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jun 2026 18:13:17 +0200 Subject: [PATCH 456/589] toggable sound effect for stair jank not the biggest fan of it but idk how to make this better on stairs with lots of steps so this will do for now --- src/g_game.h | 1 + src/k_kart.c | 3 ++- src/m_menudefs.c | 35 ++++++++++++++++++++++++----------- src/p_map.c | 8 ++++++-- src/r_main.cpp | 1 + 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/g_game.h b/src/g_game.h index 4f46ef89d..6b2fae46d 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -119,6 +119,7 @@ extern consvar_t cv_gravstretch; extern consvar_t cv_sloperoll; extern consvar_t cv_sliptideroll; extern consvar_t cv_stairjank; +extern consvar_t cv_stairjanksfx; extern consvar_t cv_slamsound; extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; diff --git a/src/k_kart.c b/src/k_kart.c index eb58a7b62..027572458 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -67,7 +67,8 @@ static CV_PossibleValue_t sloperoll_cons_t[] = {{0, "Off"}, {1, "Players"}, {2, consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, sloperoll_cons_t, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_sparkroll = {"sparkroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_stairjank = {"stairjank", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_stairjank = {"stairjank", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_stairjanksfx = {"stairjanksfx", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //hardcode saltyhop mhhm static void saltyhop_onchange(void); diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 7eecdb0f6..72d3ab2f5 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1791,20 +1791,22 @@ static menuitem_t OP_PlayerDistortMenu[] = {IT_STRING | IT_CVAR, NULL, "Rotate Players when Sliptiding", &cv_sliptideroll, 25}, {IT_STRING | IT_CVAR, NULL, "Stair Janking Effect", &cv_stairjank, 30}, - {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 35}, - {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 40}, + {IT_STRING | IT_CVAR, NULL, "Stair Janking Sound Effect", &cv_stairjanksfx, 35}, // idk if that should be here but i dont care atm - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 50}, - {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 55}, + {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 40}, + {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 45}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 65}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 70}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 75}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 80}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 85}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 55}, + {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 60}, - {IT_STRING | IT_CVAR, NULL, "Squishdance", &cv_squishdance, 95}, - {IT_STRING | IT_CVAR, NULL, "Squishdance Speed", &cv_squishdancespeed, 101}, // why is this offset by 6? idk cant remember lulul + {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 70}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 75}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 80}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 85}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 90}, + + {IT_STRING | IT_CVAR, NULL, "Squishdance", &cv_squishdance, 100}, + {IT_STRING | IT_CVAR, NULL, "Squishdance Speed", &cv_squishdancespeed, 106}, // why is this offset by 6? idk cant remember lulul }; static const char* OP_PlayerDistortTooltips[] = @@ -1814,6 +1816,7 @@ static const char* OP_PlayerDistortTooltips[] = "Distance object rotation should be visable.", "Player rotation when sliptiding.", "Slightly tilt the player when driving over stairs or small bumps.", + "Sound effect when driving over stairs or small bumps.", "Rotation of a player's boost trails and drift sparks.", "Should banans rotate when thrown?\nAnd should they stay rotated when on the ground?", "Player squash and stretch.", @@ -1834,6 +1837,7 @@ enum slrotatedist, sliptide, stairjank, + stairjanksfx, sparkrotate, bananrotat, stretchyplayer, @@ -2742,6 +2746,15 @@ void PDistort_menu_Onchange(void) OP_PlayerDistortMenu[slrotatedist].status = IT_GRAYEDOUT; OP_PlayerDistortMenu[saltroll].status = IT_GRAYEDOUT; } + + if (cv_stairjank.value) + { + OP_PlayerDistortMenu[stairjanksfx].status = IT_STRING | IT_CVAR; + } + else + { + OP_PlayerDistortMenu[stairjanksfx].status = IT_GRAYEDOUT; + } } void Bird_menu_Onchange(void) diff --git a/src/p_map.c b/src/p_map.c index ef4997293..ed4698f1b 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2594,10 +2594,14 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) { /* use a shorter sound if not two tics have passed * since the last step */ - //S_ReducedVFXSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268), NULL); - //S_StartSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268)); + //S_ReducedVFXSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268), NULL); + //S_StartSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268)); // sound does not work out all that well for kart maps + // best i can do... + if (cv_stairjanksfx.value) + S_StartSoundAtVolume(thing, (thing->player->stairjank >= 8 ? sfx_s23b : sfx_s268), 192); // dont blast this at full volume lul + // TODO: maybe spawn smol dust effect similar to RR? /*if (!thing->player->stairjank) { diff --git a/src/r_main.cpp b/src/r_main.cpp index c4719e2e5..038fa8a6a 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1601,6 +1601,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_sloperolldist); CV_RegisterVar(&cv_sparkroll); CV_RegisterVar(&cv_stairjank); + CV_RegisterVar(&cv_stairjanksfx); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); From 2413a3503c6436b9233a47e0d10157f401ea534a Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 29 Jun 2026 20:44:30 +0300 Subject: [PATCH 457/589] Add stairjank particle effect using drift dust --- src/p_map.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index ed4698f1b..3206b5c81 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2603,15 +2603,33 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) S_StartSoundAtVolume(thing, (thing->player->stairjank >= 8 ? sfx_s23b : sfx_s268), 192); // dont blast this at full volume lul // TODO: maybe spawn smol dust effect similar to RR? - /*if (!thing->player->stairjank) + //if (!thing->player->stairjank) { - mobj_t * spark = P_SpawnMobjFromMobj(thing, 0, 0, 0, MT_JANKSPARK); - spark->fuse = 9; - spark->cusval = K_StairJankFlip(ANGLE_90); + // 90 degrees to direction you're facing + fixed_t dirx = -FINESINE(thing->angle>>ANGLETOFINESHIFT); + fixed_t diry = FINECOSINE(thing->angle>>ANGLETOFINESHIFT); + fixed_t offset = thing->radius; + + if (leveltime % 8 < 4) + { + dirx = -dirx; + diry = -diry; + } + + mobj_t * spark = P_SpawnMobj(thing->x + FixedMul(dirx, offset), thing->y + FixedMul(diry, offset), thing->z, MT_DRIFTDUST); + spark->momx = FixedMul(dirx, FRACUNIT) + (6 + ((int)leveltime % 5))*(thing->momx)/10; + spark->momy = FixedMul(diry, FRACUNIT) + (6 + ((int)leveltime % 5))*(thing->momy)/10; + spark->momz = 5*FRACUNIT; + spark->scale = mapobjectscale/5; + spark->destscale = mapobjectscale/2; + spark->islocal = true; + //spark->fuse = 9; + spark->color = SKINCOLOR_WHITE; + //spark->cusval = K_StairJankFlip(ANGLE_90); P_SetTarget(&spark->target, thing); - P_SetTarget(&spark->owner, thing); - spark->renderflags |= RF_REDUCEVFX; - }*/ + //P_SetTarget(&spark->owner, thing); + //spark->renderflags |= RF_REDUCEVFX; + } thing->player->stairjank = 9; //thing->player->stairjank = 17; From ec0615043278f1c8c883c7c159393714a83b1253 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 29 Jun 2026 20:45:45 +0300 Subject: [PATCH 458/589] This todo is done :3 --- src/p_map.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 3206b5c81..5b78d9a3d 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2602,7 +2602,6 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (cv_stairjanksfx.value) S_StartSoundAtVolume(thing, (thing->player->stairjank >= 8 ? sfx_s23b : sfx_s268), 192); // dont blast this at full volume lul - // TODO: maybe spawn smol dust effect similar to RR? //if (!thing->player->stairjank) { // 90 degrees to direction you're facing From e2a39927876cebe7b73fc5563ff1d097fbd48bb4 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 29 Jun 2026 22:01:54 +0200 Subject: [PATCH 459/589] make online hud / chat menu scrollable yes i checked green res.... it barely fits like this........ --- src/m_menudefs.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 72d3ab2f5..4da3c7ea7 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1408,25 +1408,25 @@ static menuitem_t OP_ChatOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Chat Mode", &cv_consolechat, 5}, // nonetheless... {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Chat Box Width", &cv_chatwidth, 20}, + NULL, "Chat Box Width", &cv_chatwidth, 10}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Chat Box Height", &cv_chatheight, 30}, - {IT_STRING | IT_CVAR, NULL, "Chat Horizontal Offset", &cv_chat_xoffset, 40}, - {IT_STRING | IT_CVAR, NULL, "Chat Vertical Offset", &cv_chat_yoffset, 50}, + NULL, "Chat Box Height", &cv_chatheight, 15}, + {IT_STRING | IT_CVAR, NULL, "Chat Horizontal Offset", &cv_chat_xoffset, 20}, + {IT_STRING | IT_CVAR, NULL, "Chat Vertical Offset", &cv_chat_yoffset, 25}, - {IT_STRING | IT_CVAR, NULL, "Center Text in Chat", &cv_chatcentertext, 70}, - {IT_STRING | IT_CVAR, NULL, "Chat Background Tint", &cv_chatbacktint, 80}, - {IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 90}, - {IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 100}, - {IT_STRING | IT_CVAR, NULL, "Max Chat Messages", &cv_chatlogsize, 110}, - {IT_STRING | IT_CVAR, NULL, "Display Character Limit", &cv_chat_showlimit, 120}, + {IT_STRING | IT_CVAR, NULL, "Center Text in Chat", &cv_chatcentertext, 35}, + {IT_STRING | IT_CVAR, NULL, "Chat Background Tint", &cv_chatbacktint, 40}, + {IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 45}, + {IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 50}, + {IT_STRING | IT_CVAR, NULL, "Max Chat Messages", &cv_chatlogsize, 55}, + {IT_STRING | IT_CVAR, NULL, "Display Character Limit", &cv_chat_showlimit, 60}, - {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 140}, // shows ping above the framerate if we want to. - {IT_STRING | IT_CVAR, NULL, "Ping display style", &cv_pingstyle, 150}, - {IT_STRING | IT_CVAR, NULL, "Ping measurement", &cv_pingmeasurement, 160}, - {IT_STRING | IT_CVAR, NULL, "Ping icon", &cv_pingicon, 170}, + {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 70}, // shows ping above the framerate if we want to. + {IT_STRING | IT_CVAR, NULL, "Ping display style", &cv_pingstyle, 75}, + {IT_STRING | IT_CVAR, NULL, "Ping measurement", &cv_pingmeasurement, 80}, + {IT_STRING | IT_CVAR, NULL, "Ping icon", &cv_pingicon, 85}, - {IT_STRING | IT_CVAR, NULL, "Show IP address in playerlist", &cv_shownodeip, 180}, + {IT_STRING | IT_CVAR, NULL, "Show IP address in playerlist", &cv_shownodeip, 90}, }; static const char* OP_ChatOptionsTooltips[] = @@ -2621,7 +2621,7 @@ menu_t OP_Player2CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player2CamOptionsMenu menu_t OP_Player3CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player3CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); menu_t OP_Player4CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player4CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); -menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 30, OP_ChatOptionsTooltips); +menu_t OP_ChatOptionsDef = DEFAULTSCROLLSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 25, OP_ChatOptionsTooltips); menu_t OP_SoundAdvancedDef = DEFAULTSCROLLSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30, OP_SoundAdvancedTooltips); From 4a06e8a6d172871bd2441b1588d765097d6da79c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 30 Jun 2026 18:36:56 +0200 Subject: [PATCH 460/589] fix map replacement checks for pwads added on startup stuff added per -file or whatever this incorrectly rechecked the iwads again instead of the pwads themselves, which let to the game flagging vanilla maps as replaced, setting the game to be modified --- src/d_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 85e1242ac..2150b1e72 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1353,20 +1353,24 @@ static void IdentifyVersion(void) // // search for maps // -static void D_CheckMapReplacements(boolean checkreplaced) +static void D_CheckMapReplacements(boolean pwad) { INT32 i; char *name; UINT16 wadnum; lumpinfo_t *lumpinfo; + size_t numfiles; - for (wadnum = 0; wadnum < mainwads; wadnum++) + wadnum = pwad ? (mainwads+1) : 0; + numfiles = pwad ? numwadfiles : mainwads; + + for (; wadnum < numfiles; wadnum++) { lumpinfo = wadfiles[wadnum]->lumpinfo; for (i = 0; i < wadfiles[wadnum]->numlumps; i++, lumpinfo++) { name = lumpinfo->name; - P_CheckMapReplacements(name, checkreplaced); + P_CheckMapReplacements(name, pwad); } } } From d638baeda60ea19c325d82e171bea3a9215eef1f Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jul 2026 18:08:50 +0200 Subject: [PATCH 461/589] change mobj hook detection again so we can restore the actual correct behavior for the HurtMsg hook, which nothing even uses lol --- src/lua_hooklib.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 6294a5ab7..90d8ec367 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -65,6 +65,8 @@ static stringhook_t stringHooks[STRING_HOOK(MAX)]; bool hook_important = true; +#define NONMOHOOK ((mobjtype_t)-1) + // This will be indexed by hook id, the value of which fetches the registry. static int * hookRefs; static int nextid; @@ -296,7 +298,7 @@ struct Hook_State { INT32 status; /* return status to calling function */ void * userdata; int hook_type; - mobjtype_t mobj_type; /* < NUMMOBJTYPES if mobj hook */ + mobjtype_t mobj_type; /* != NONMOHOOK if mobj hook */ const char * string; /* used to fetch table, ran first if set */ int top; /* index of last argument passed to hook */ int id; /* id to fetch ref */ @@ -364,7 +366,7 @@ FUNCINLINE static ATTRINLINE boolean prepare_hook int hook_type ){ return init_hook_type(hook, default_status, - hook_type, NUMMOBJTYPES, NULL, + hook_type, NONMOHOOK, NULL, hookIds[hook_type].numHooks); } @@ -391,7 +393,7 @@ FUNCINLINE static ATTRINLINE boolean prepare_string_hook const char * string ){ if (init_hook_type(hook, default_status, - hook_type, NUMMOBJTYPES, string, + hook_type, NONMOHOOK, string, stringHooks[hook_type].ref)) { lua_pushstring(gL, string); @@ -407,7 +409,7 @@ FUNCINLINE static ATTRINLINE boolean prepare_hud_hook int hook_type ){ return init_hook_type(hook, 0, - hook_type, NUMMOBJTYPES, NULL, + hook_type, NONMOHOOK, NULL, hudHookIds[hook_type].numHooks); } @@ -547,11 +549,13 @@ static int call_hooks { calls += call_string_hooks(hook); } - else if (hook->mobj_type < NUMMOBJTYPES) + //else if (hook->mobj_type > 0) + else if (hook->mobj_type != NONMOHOOK) { /* call generic mobj hooks first */ calls += call_mobj_type_hooks(hook, MT_NULL); - calls += call_mobj_type_hooks(hook, hook->mobj_type); + if (hook->mobj_type < NUMMOBJTYPES) + calls += call_mobj_type_hooks(hook, hook->mobj_type); ps_lua_mobjhooks.value.i += calls; } else From a2184d2bef7c8d04d13e1ea013939e0b9664d0dd Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jul 2026 18:08:06 +0200 Subject: [PATCH 462/589] move cv_audbuffersize register this stuff kinda grouped some cvars together, makes more sense there --- src/d_netcmd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9d7d697cd..fd08830f0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -930,8 +930,6 @@ void D_RegisterClientCommands(void) COM_AddCommand("displayplayer", Command_Displayplayer_f); - CV_RegisterVar(&cv_audbuffersize); - CV_RegisterVar(&cv_palette); CV_RegisterVar(&cv_palettenum); @@ -1032,6 +1030,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_midimusicvolume); #endif CV_RegisterVar(&cv_numChannels); + CV_RegisterVar(&cv_audbuffersize); #ifdef HAVE_OPENMPT CV_RegisterVar(&cv_modfilter); From 551d7d4d89e070381b974d930b52aef0ca1084d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jul 2026 18:07:31 +0200 Subject: [PATCH 463/589] add V_DrawRightAlignedSmallStringAtFixed idk but might be useful --- src/v_video.c | 14 +++++++++++++- src/v_video.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/v_video.c b/src/v_video.c index 0f4540216..2ac659ba6 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2718,6 +2718,7 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st INT32 charflags = 0; const UINT8 *colormap = NULL; INT32 spacewidth = 2, charwidth = 0; + INT32 lowercase = (option & V_ALLOWLOWERCASE); option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE... @@ -2738,6 +2739,7 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st scrwidth *= vid.dup; charflags = (option & V_CHARCOLORMASK); + colormap = V_GetStringColormap(charflags); switch (option & V_SPACINGMASK) { @@ -2762,7 +2764,11 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st { // manually set flags override color codes if (!(option & V_CHARCOLORMASK)) + { charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; + colormap = V_GetStringColormap(charflags); + } + continue; } @@ -2806,7 +2812,6 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st continue; } - colormap = V_GetStringColormap(charflags); V_DrawFixedPatch(cx + (center< Date: Sat, 11 Nov 2023 02:27:39 -0800 Subject: [PATCH 464/589] Add basic profiling for Lua hooks (except HUD hooks) - Add lua_profile cheat: calculate average time spent in hooks over a period - Show hook times in a sorted table, along with lump name, script line number and hook type - Show cumulative time spent in game logic hooks and percentage of overhead to game logic --- src/CMakeLists.txt | 2 + src/Makefile | 2 +- src/Sourcefile | 1 + src/d_clisrv.c | 3 + src/d_main.c | 6 ++ src/d_netcmd.c | 6 ++ src/d_netcmd.h | 2 + src/lua_hooklib.c | 46 ++++++++- src/lua_infolib.c | 6 +- src/lua_profile.cpp | 246 ++++++++++++++++++++++++++++++++++++++++++++ src/lua_profile.h | 38 +++++++ src/m_perfstats.c | 1 + src/m_perfstats.h | 1 + src/p_tick.c | 8 +- 14 files changed, 364 insertions(+), 4 deletions(-) create mode 100644 src/lua_profile.cpp create mode 100644 src/lua_profile.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dc456905a..864a5870c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -275,6 +275,7 @@ if(${SRB2_CONFIG_HAVE_BLUA}) lua_hooklib.c lua_hudlib.c lua_hudlib_drawlist.c + lua_profile.cpp lua_infolib.c lua_maplib.c lua_mathlib.c @@ -290,6 +291,7 @@ if(${SRB2_CONFIG_HAVE_BLUA}) lua_hook.h lua_hud.h lua_hudlib_drawlist.h + lua_profile.ch lua_libs.h lua_script.h lua_udatalib.h diff --git a/src/Makefile b/src/Makefile index 4ee7cf1a9..77c9f7129 100644 --- a/src/Makefile +++ b/src/Makefile @@ -307,7 +307,7 @@ opts+=$(WFLAGS) $(CFLAGS) cxxopts:=$(opts) $(CXXFLAGS) opts+=$(CWFLAGS) # warning flags that shouldnt be passed to c++ compiler -libs+=$(LDFLAGS) -lstdc++ -lpthread +libs+=$(LDFLAGS) -lstdc++ -lpthread -lfmt asflags:=$(ASFLAGS) -x assembler-with-cpp diff --git a/src/Sourcefile b/src/Sourcefile index 08c18ebf0..f09a143bd 100644 --- a/src/Sourcefile +++ b/src/Sourcefile @@ -99,3 +99,4 @@ lua_skinlib.c lua_thinkerlib.c lua_udatalib.c lua_glib.c +lua_profile.cpp diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8cb038251..8f93bc9e7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6848,7 +6848,10 @@ boolean TryRunTics(tic_t realtics) DEBFILE(va("============ Running tic %d (local %d)\n", gametic, leveltime)); if (update_stats) + { + ps_prevtictime = ps_tictime; PS_START_TIMING(ps_tictime); + } G_Ticker((gametic % NEWTICRATERATIO) == 0); ExtraDataTicker(); diff --git a/src/d_main.c b/src/d_main.c index 2150b1e72..0e095d9a4 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -79,6 +79,7 @@ #include "core/memory.h" #include "lua_script.h" +#include "lua_profile.h" /* Manually defined asset hashes for non-CMake builds * Last updated 2015 / 05 / 03 - SRB2 v2.1.15 - srb2.srb @@ -658,6 +659,11 @@ static boolean D_Display(void) CON_Drawer(); // Ha, i LIED! + if (cv_lua_profile.value > 0) + { + LUA_RenderTimers(); + } + PS_START_TIMING(ps_swaptime); I_FinishUpdate(); // page flip or blit buffer PS_STOP_TIMING(ps_swaptime); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index fd08830f0..42e5dec19 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -47,6 +47,7 @@ #include "z_zone.h" #include "lua_script.h" #include "lua_hook.h" +#include "lua_profile.h" #include "m_cond.h" #include "m_anigif.h" #include "k_kart.h" // SRB2kart @@ -506,6 +507,9 @@ static CV_PossibleValue_t ps_descriptor_cons_t[] = { {1, "Average"}, {2, "SD"}, {3, "Minimum"}, {4, "Maximum"}, {0, NULL}}; consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +//consvar_t cv_lua_profile = {"lua_profile", "0").values(CV_Unsigned).onchange(lua_profile_OnChange).description("Show hook timings over an average of N tics"); +consvar_t cv_lua_profile = {"lua_profile", "0", CV_CALL, CV_Unsigned, lua_profile_OnChange, 0, NULL, NULL, 0, 0, NULL}; + // only there to better keep track of it globally consvar_t cv_director = {"director", "Off", CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -933,6 +937,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_palette); CV_RegisterVar(&cv_palettenum); + CV_RegisterVar(&cv_lua_profile); + // m_menu.c CV_RegisterVar(&cv_chatheight); CV_RegisterVar(&cv_chatwidth); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 46ec396ec..25e050a13 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -189,6 +189,8 @@ extern consvar_t cv_ps_thinkframe_page; extern consvar_t cv_ps_samplesize; extern consvar_t cv_ps_descriptor; +extern consvar_t cv_lua_profile; + extern consvar_t cv_director, cv_kartdebugdirector, cv_showdirectorhud; extern consvar_t cv_showtrackaddon; diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 90d8ec367..bed23cf36 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -25,6 +25,7 @@ #include "lua_libs.h" #include "lua_hook.h" #include "lua_hud.h" // hud_running errors +#include "lua_profile.h" /* ========================================================================= ABSTRACTION @@ -445,11 +446,54 @@ FUNCINLINE static ATTRINLINE void get_hook_from_table(Hook_State *hook, int n) lua_getref(gL, hookRefs[hook->id]); } +static int pcall(Hook_State *hook) +{ + return lua_pcall(gL, hook->values, hook->results, EINDEX); +} + +static const char *hook_name(Hook_State *hook) +{ + if (hud_running) + { + return hudHookNames[hook->hook_type]; + } + else if (hook->string) + { + return stringHookNames[hook->hook_type]; + } + //else if (hook->mobj_type > 0) + else if (hook->mobj_type != NONMOHOOK) + { + return mobjHookNames[hook->hook_type]; + } + else + { + return hookNames[hook->hook_type]; + } +} + +static int pcall_timed_or_untimed(Hook_State *hook) +{ + if (!hud_running && cv_lua_profile.value > 0) + { + lua_timer_t *timer = LUA_BeginFunctionTimer(gL, -1 - hook->values, hook_name(hook)); + int k = pcall(hook); + LUA_EndFunctionTimer(timer); + + return k; + } + else + { + return pcall(hook); + } +} + static int call_single_hook_no_copy(Hook_State *hook) { hook_important = hook->important; - if (lua_pcall(gL, hook->values, hook->results, EINDEX) == 0) + //if (lua_pcall(gL, hook->values, hook->results, EINDEX) == 0) + if (pcall_timed_or_untimed(hook) == 0) { if (hook->results > 0) { diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 4c84c48d5..5f2f4f80c 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -22,7 +22,8 @@ #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors -#include "lua_hook.h" // cmd errors +#include "lua_hook.h" // hook_cmd_running errors +#include "lua_profile.h" boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor); state_t *astate = NULL; @@ -110,7 +111,10 @@ static void A_Lua(mobj_t *actor) LUA_PushUserdata(gL, actor, META_MOBJ); lua_pushinteger(gL, var1); lua_pushinteger(gL, var2); + + lua_timer_t *timer = LUA_BeginFunctionTimer(gL, -4, "A_Lua"); LUA_Call(gL, 3, 0, 1); + LUA_EndFunctionTimer(timer); lua_pop(gL, 1); // pop error handler diff --git a/src/lua_profile.cpp b/src/lua_profile.cpp new file mode 100644 index 000000000..db13dde70 --- /dev/null +++ b/src/lua_profile.cpp @@ -0,0 +1,246 @@ +// DR. ROBOTNIK'S RING RACERS +//----------------------------------------------------------------------------- +// Copyright (C) 2025 by James Robert Roman +// Copyright (C) 2025 by Kart Krew +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- + +#include "screen.h" +#include +#include +#include +#include +#include +#include + +#include +#include + +extern "C" { +#include "blua/lua.h" +}; + +#include "v_video.h" + +#include "command.h" +#include "doomtype.h" +#include "i_system.h" +#include "lua_profile.h" +#include "m_perfstats.h" + +extern "C" consvar_t cv_lua_profile; + +namespace +{ + +precise_t g_time_reference; +int g_tics_counted; + +double g_running_tic_time; +double g_avg_tic_time; + +bool g_invalid; + +}; // namespace + +struct lua_timer_t +{ + struct Stat + { + double calls = 0; + double time = 0.0; + }; + + Stat running, avg; +}; + +namespace +{ + +std::unordered_map g_tic_timers; + +}; // namespace + +lua_timer_t* LUA_BeginFunctionTimer(lua_State* L, int fn_idx, const char* name) +{ + lua_Debug ar; + + lua_pushvalue(L, fn_idx); + lua_getinfo(L, ">S", &ar); + + auto label = [&] + { + using sv = std::string_view; + sv view{ar.source}; + + switch (view.front()) + { + case '@': // file + if (std::size_t p = view.rfind('/'); p != sv::npos) // lump or base + { + return view.substr(p + 1); + } + break; + + case '=': // ?? + view.remove_prefix(1); + break; + } + + return view; + }; + + auto [it, ins] = g_tic_timers.try_emplace(fmt::format("{}:{} ({})", label(), ar.linedefined, name)); + auto& [key, timer] = *it; + + g_time_reference = I_GetPreciseTime(); + + return &timer; +} + +void LUA_EndFunctionTimer(lua_timer_t* timer) +{ + precise_t t = I_GetPreciseTime() - g_time_reference; + double precision = I_GetPrecisePrecision(); + + timer->running.time += t / precision; + timer->running.calls += 1.0; +} + +void LUA_ResetTicTimers(void) +{ + if (cv_lua_profile.value <= 0) + { + return; + } + + if (g_tics_counted < cv_lua_profile.value) + { + g_tics_counted++; + + double precision = I_GetPrecisePrecision(); + g_running_tic_time += ps_prevtictime.value.p / precision; + } + else + { + double counted = g_tics_counted; + + for (auto& [key, timer] : g_tic_timers) + { + timer.avg = {timer.running.calls / counted, timer.running.time / counted}; + timer.running = {}; + } + + g_avg_tic_time = g_running_tic_time / counted; + g_running_tic_time = 0.0; + + g_tics_counted = 1; + + g_invalid = false; + } +} + +void LUA_RenderTimers(void) +{ + using srb2::Draw; + + constexpr int kRowHeight = 4; + constexpr float kScale = 0.5f; + + Draw row = Draw(0, kRowHeight).font(Draw::Font::kConsole).align(Draw::Align::kLeft).scale(0.5).flags(V_MONOSPACE); + row.y(-kRowHeight).text("-- AVERAGES PER TIC (over {} tics) --", cv_lua_profile.value); + + if (g_invalid) + { + row.flags(V_GRAYMAP).text(" "); + return; + } + + std::vector view; + view.reserve(g_tic_timers.size()); + + auto color_flag = [](double t) + { + if (t < 10.0) + { + return V_GRAYMAP; + } + else if (t >= 100.0) + { + return V_YELLOWMAP; + } + else + { + return 0; + } + }; + + { + double cum = 0.0; + + for (auto it = g_tic_timers.begin(); it != g_tic_timers.end(); ++it) + { + auto& [key, timer] = *it; + + cum += timer.avg.time; + + if (timer.avg.time > 0.0) + { + view.push_back(it); + } + } + + Draw tally = row.flags(color_flag(cum * 1'000'000.0)); + + tally.text("{:8.2f} us - TOTAL", cum * 1'000'000.0); + tally.y(kRowHeight).text("{:8.2f} ms", cum * 1000.0); + tally.y(kRowHeight * 2).text( + "{:8.2f}% overhead ({:.2f} / {:.2f}) <-- not counting rendering time", + (cum / g_avg_tic_time) * 100.0, + cum * TICRATE, + g_avg_tic_time * TICRATE + ); + + row = row.y(kRowHeight * 4); + } + + std::sort( + view.rbegin(), + view.rend(), + [](auto a, auto b) + { + auto& [k1, t1] = *a; + auto& [k2, t2] = *b; + return t1.avg.time < t2.avg.time; + } + ); + + for (auto it : view) + { + auto& [key, timer] = *it; + + double t = timer.avg.time * 1'000'000.0; + + row.flags(color_flag(t)).text( + "{:>8.2f} us {:>8.2f} calls - {}", + t, + timer.avg.calls, + key + ); + + row = row.y(kRowHeight); + } +} + +extern "C" void lua_profile_OnChange(void) +{ + g_invalid = true; + + if (cv_lua_profile.value == 0) + { + g_tic_timers = {}; + } +} diff --git a/src/lua_profile.h b/src/lua_profile.h new file mode 100644 index 000000000..80475613d --- /dev/null +++ b/src/lua_profile.h @@ -0,0 +1,38 @@ +// DR. ROBOTNIK'S RING RACERS +//----------------------------------------------------------------------------- +// Copyright (C) 2025 by James Robert Roman +// Copyright (C) 2025 by Kart Krew +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- + +#ifndef lua_profile_h +#define lua_profile_h + +#include "blua/lua.h" +#include "doomtype.h" +//#include "typedef.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct lua_timer_t; +typedef struct lua_timer_t lua_timer_t; + +void LUA_ResetTicTimers(void); + +lua_timer_t *LUA_BeginFunctionTimer(lua_State *L, int fn_idx, const char *name); +void LUA_EndFunctionTimer(lua_timer_t *timer); + +void LUA_RenderTimers(void); + +void lua_profile_OnChange(void); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif/*lua_profile_h*/ diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 49a855686..90bde47e9 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -47,6 +47,7 @@ struct perfstatrow { static ps_metric_t ps_frametime = {0}; ps_metric_t ps_tictime = {0}; +ps_metric_t ps_prevtictime = {0}; ps_metric_t ps_playerthink_time = {0}; ps_metric_t ps_thinkertime = {0}; diff --git a/src/m_perfstats.h b/src/m_perfstats.h index 083656d61..474c6c841 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -36,6 +36,7 @@ typedef struct #define PS_STOP_TIMING(metric) metric.value.p = I_GetPreciseTime() - metric.value.p extern ps_metric_t ps_tictime; +extern ps_metric_t ps_prevtictime; extern ps_metric_t ps_playerthink_time; extern ps_metric_t ps_thinkertime; diff --git a/src/p_tick.c b/src/p_tick.c index d0d25be69..455a8d5ac 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -38,6 +38,8 @@ #include "i_video.h" // rendermode #include "m_perfstats.h" +#include "lua_profile.h" + // Object place #include "m_cheat.h" @@ -622,6 +624,8 @@ void P_Ticker(boolean run) } } + LUA_ResetTicTimers(); + ps_lua_mobjhooks.value.i = 0; ps_checkposition_calls.value.i = 0; @@ -629,6 +633,7 @@ void P_Ticker(boolean run) LUA_HookPreThinkFrame(); PS_STOP_TIMING(ps_lua_prethinkframe_time); + // OK! Now that we got all of that sorted, players can think! PS_START_TIMING(ps_playerthink_time); for (i = 0; i < MAXPLAYERS; i++) { @@ -675,6 +680,7 @@ void P_Ticker(boolean run) PS_STOP_TIMING(ps_lua_thinkframe_time); } + // Run shield positioning P_RunOverlays(); P_RunShadows(); @@ -796,7 +802,7 @@ void P_Ticker(boolean run) if (!player->mo) continue; - const boolean skybox = (skyboxmo[0] && cv_skybox.value); + const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on if (skyVisiblePerPlayer[i] && skybox) { From 38a248193e6344ba1a480c67ad4f18f9b285ae48 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jul 2026 18:14:54 +0200 Subject: [PATCH 465/589] make lua hook profiler kinda work very scuffed up since we dont have the srb2::Draw lib so it may display stuff out of screen bounds i also rather not use fmt here but va since i dont want another dependency needs to be fixed up sometime --- src/lua_profile.cpp | 59 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/src/lua_profile.cpp b/src/lua_profile.cpp index db13dde70..a25646a74 100644 --- a/src/lua_profile.cpp +++ b/src/lua_profile.cpp @@ -145,17 +145,33 @@ void LUA_ResetTicTimers(void) void LUA_RenderTimers(void) { - using srb2::Draw; + ///using srb2::Draw; constexpr int kRowHeight = 4; - constexpr float kScale = 0.5f; + //constexpr float kScale = 0.5f; - Draw row = Draw(0, kRowHeight).font(Draw::Font::kConsole).align(Draw::Align::kLeft).scale(0.5).flags(V_MONOSPACE); - row.y(-kRowHeight).text("-- AVERAGES PER TIC (over {} tics) --", cv_lua_profile.value); + // pretty much what the whole srb2::Draw does lol + auto draw_row = [](float x, float y, INT32 flags, const std::string& str) + { + V_DrawSmallStringAtFixed( + FloatToFixed(x), + FloatToFixed(y), + V_MONOSPACE|V_ALLOWLOWERCASE|flags, + str.c_str() + ); + }; + + float row_y = kRowHeight - 60; + draw_row(0.f, row_y - kRowHeight, 0, fmt::format("-- AVERAGES PER TIC (over {} tics) --", cv_lua_profile.value)); + + //Draw row = Draw(0, kRowHeight).font(Draw::Font::kConsole).align(Draw::Align::kLeft).scale(0.5).flags(V_MONOSPACE); + //row.y(-kRowHeight).text("-- AVERAGES PER TIC (over {} tics) --", cv_lua_profile.value); if (g_invalid) { - row.flags(V_GRAYMAP).text(" "); + row_y += kRowHeight; + //row.flags(V_GRAYMAP).text(" "); + draw_row(0.f, row_y - kRowHeight, V_GRAYMAP, " "); return; } @@ -193,6 +209,7 @@ void LUA_RenderTimers(void) } } + /* Draw tally = row.flags(color_flag(cum * 1'000'000.0)); tally.text("{:8.2f} us - TOTAL", cum * 1'000'000.0); @@ -205,6 +222,23 @@ void LUA_RenderTimers(void) ); row = row.y(kRowHeight * 4); + */ + + { + const INT32 tally_flags = color_flag(cum * 1'000'000.0); + + draw_row(0.f, row_y, tally_flags, fmt::format("{:8.2f} us - TOTAL", cum * 1'000'000.0)); + draw_row(0.f, row_y + kRowHeight, tally_flags, fmt::format("{:8.2f} ms", cum * 1000.0)); + draw_row(0.f, row_y + kRowHeight * 2, tally_flags, fmt::format( + "{:8.2f}% overhead ({:.2f} / {:.2f}) <-- not counting rendering time", + (cum / g_avg_tic_time) * 100.0, + (cum * (double)TICRATE), + (g_avg_tic_time * (double)TICRATE) + )); + } + + row_y += kRowHeight * 4; // row = row.y(kRowHeight * 4) + } std::sort( @@ -224,6 +258,7 @@ void LUA_RenderTimers(void) double t = timer.avg.time * 1'000'000.0; + /* row.flags(color_flag(t)).text( "{:>8.2f} us {:>8.2f} calls - {}", t, @@ -232,6 +267,20 @@ void LUA_RenderTimers(void) ); row = row.y(kRowHeight); + */ + + draw_row(0.f, row_y, color_flag(t), fmt::format( + "{:>8.2f} us {:>8.2f} calls - {}", + t, + timer.avg.calls, + key + )); + + row_y += kRowHeight; // row = row.y(kRowHeight) + + // FIXME this is all ugly and sucks + if (row_y >= BASEVIDHEIGHT) + break; } } From 78ebc14d884fc53969608458ef48dba1d5c92453 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jul 2026 19:21:32 +0200 Subject: [PATCH 466/589] print performance warning for lua scripts using mobj hooks without specific mobjtype thx indev for help <3 these may trash performance quite hard at times and are not visible from just perfstats most of the time --- src/lua_hooklib.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 90d8ec367..b380945ab 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -530,10 +530,48 @@ static int call_string_hooks(Hook_State *hook) return calls; } +FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) +{ + static UINT8 seen = 0; // so we dont have to check all this shit constantly + int numCalls = call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); + + if (!seen && numCalls > 0 && mobj_type == MT_NULL && ( + hook->hook_type == MOBJ_HOOK(MobjThinker ) + || hook->hook_type == MOBJ_HOOK(MobjCollide ) + || hook->hook_type == MOBJ_HOOK(MobjMoveCollide) + || hook->hook_type == MOBJ_HOOK(MobjFuse ) + || hook->hook_type == MOBJ_HOOK(MobjThinker ) + || hook->hook_type == MOBJ_HOOK(BossThinker ) + )) + { + seen = 1; + CONS_Alert( + CONS_WARNING, "%s\n", va( + "%s hooks not attached to a specific mobj type may cause performance issues!", + mobjHookNames[hook->hook_type]) + ); + + // print which script triggered it, ty indev <3 + for (int k = 0; k < mobjHookIds[mobj_type][hook->hook_type].numHooks; ++k) + { + lua_getref(gL, hookRefs[mobjHookIds[mobj_type][hook->hook_type].ids[k].id]); + + lua_Debug ar; + lua_getinfo(gL, ">S", &ar); + + CONS_Printf("%s:%d\n", ar.short_src, ar.linedefined); + } + } + + return numCalls; +} + +/* FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) { return call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); } +*/ static int call_hooks ( From 5775c12b162c06cf3de55c5d7731751cbe0e7f85 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 1 Jul 2026 23:22:56 +0300 Subject: [PATCH 467/589] Disable writing to replay query while replays are loading --- src/m_menu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index 38b5e2875..bc7c47c42 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4247,6 +4247,14 @@ static boolean M_HandleReplayHutQuery(INT32 choice) char tmp[MAXREPLAYQUERY+1]; memcpy(tmp, replayqueryinput_buffer, MAXREPLAYQUERY+1); + Lock_search_state(); + if (!replaynamesloaded) + { + Unlock_search_state(); + return false; + } + Unlock_search_state(); + if (M_TextInputHandle(&replayqueryinput, choice)) { S_StartSound(NULL, sfx_menu1); From 8b6ebfbad4bf69ca0d47494d3c38b0adfd17da28 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jul 2026 22:06:07 +0200 Subject: [PATCH 468/589] promote those null checks again..... sigh...... atleast this should be right this time --- src/w_wad.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 06af7a127..a8bdc0f9b 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2733,7 +2733,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) const char *name = (fileinfo + realentry)->name; I_Assert(name != NULL); - if (CHECKMAPMARKER(name)) + if (!name || CHECKMAPMARKER(name)) { numlumps--; // We skip map marker, so 1 of entries becomes empty continue; // This will skip i++ so we will write to same entry @@ -2764,7 +2764,8 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) const char *name = W_CheckNameForNum(lumppos); I_Assert(name != NULL); - if (CHECKMAPMARKER(name)) + // if no name then theres no lump + if (!name || CHECKMAPMARKER(name)) { break; } @@ -2781,7 +2782,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) const char *name = W_CheckNameForNum(lumpnum); I_Assert(name != NULL); - if (CHECKMAPMARKER(name)) + if (!name || CHECKMAPMARKER(name)) { --i; // Decrement so on next iteration we write on same i, so we don't leave corrupted vlumps entry numlumps--; // Just so we don't try to access the leftover vlumps entry From 7a309bc0b8eac61dccd047e7c3b5d08c4dff5d9b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 1 Jul 2026 22:45:17 +0200 Subject: [PATCH 469/589] make this less messy --- src/k_kart.c | 9 +++++---- src/p_map.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 027572458..461041aa8 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6243,11 +6243,12 @@ void K_KartUpdatePosition(player_t *player) if (G_RaceGametype()) { - if ((((players[i].starpostnum) + (numstarposts + 1) * players[i].laps) > - ((player->starpostnum) + (numstarposts + 1) * player->laps))) + const INT32 iplayerlaps = (players[i].starpostnum + (numstarposts + 1) * players[i].laps); + const INT32 pplayerlaps = (player->starpostnum + (numstarposts + 1) * player->laps); + + if (iplayerlaps > pplayerlaps) position++; - else if (((players[i].starpostnum) + (numstarposts+1)*players[i].laps) == - ((player->starpostnum) + (numstarposts+1)*player->laps)) + else if (iplayerlaps == pplayerlaps) { ppcd = pncd = ipcd = incd = 0; diff --git a/src/p_map.c b/src/p_map.c index 5b78d9a3d..51e9af656 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2684,7 +2684,7 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y) if (tmfloorz - thing->z > maxstep) return false; // too big a step up } - } while(tryx != x || tryy != y); + } while (tryx != x || tryy != y); // the move is ok, // so link the thing into its new position From e445669521b8be4a66855e3a7d0df16805c511b1 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 18:17:42 +0200 Subject: [PATCH 470/589] cleanup stuff a bit for unused gametypes wish could just remove all of this but gotta keep it for compat reasons ig --- src/d_clisrv.c | 2 +- src/g_demo.c | 4 ++-- src/g_game.h | 7 +++--- src/m_cheat.c | 6 ++--- src/p_enemy.c | 11 +++++---- src/p_inter.c | 26 ++++++++++---------- src/p_local.h | 8 +++++-- src/p_map.c | 35 +++++++++++++++++---------- src/p_mobj.c | 64 ++++++++++++++++++++++++-------------------------- src/p_spec.c | 6 ++--- src/p_user.c | 28 +++++++++++----------- 11 files changed, 106 insertions(+), 91 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8cb038251..8efc2a1cd 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3449,7 +3449,7 @@ void CL_ClearPlayer(INT32 playernum) if (players[playernum].mo) { // Don't leave a NiGHTS ghost! - if (UNLIKELY((players[playernum].pflags & PF_NIGHTSMODE) && players[playernum].mo->tracer)) + if (nightsplayer(&players[playernum]) && players[playernum].mo->tracer) P_RemoveMobj(players[playernum].mo->tracer); P_RemoveMobj(players[playernum].mo); } diff --git a/src/g_demo.c b/src/g_demo.c index 1123aed69..17ed25d85 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -716,7 +716,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) if (!(demoflags & DF_GHOST)) return; // No ghost data to write. - if (ghost->player && ghost->player->pflags & PF_NIGHTSMODE && ghost->tracer) + if (ghost->player && nightsplayer(ghost->player) && ghost->tracer) { // We're talking about the NiGHTS thing, not the normal platforming thing! ziptic |= GZT_NIGHTS; @@ -979,7 +979,7 @@ void G_ConsGhostTic(INT32 playernum) if (ziptic & GZT_NIGHTS) { - if (!testmo || !testmo->player || !(testmo->player->pflags & PF_NIGHTSMODE) || !testmo->tracer) + if (!testmo || !testmo->player || !nightsplayer(testmo->player) || !testmo->tracer) nightsfail = true; else testmo = testmo->tracer; diff --git a/src/g_game.h b/src/g_game.h index 6b2fae46d..038bc68df 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -228,10 +228,11 @@ void G_SaveGameData(boolean force); void G_SaveGame(UINT32 slot); -#define G_GametypeHasTeams() (G_IsGameType(GT_TEAMMATCH) || G_IsGameType(GT_CTF)) +#define G_RaceGametype() (G_IsGameType(GT_RACE)) #define G_BattleGametype() (G_IsGameType(GT_MATCH)) -#define G_RaceGametype() (G_IsGameType(GT_RACE)) -#define G_TagGametype() (G_IsGameType(GT_TAG) || G_IsGameType(GT_HIDEANDSEEK)) + +#define G_GametypeHasTeams() (UNLIKELY(G_IsGameType(GT_TEAMMATCH) || G_IsGameType(GT_CTF))) +#define G_TagGametype() (UNLIKELY(G_IsGameType(GT_TAG) || G_IsGameType(GT_HIDEANDSEEK))) FUNCINLINE static ATTRINLINE boolean G_IsGameType(int type) { diff --git a/src/m_cheat.c b/src/m_cheat.c index 783ff3bcb..0360ecc56 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -766,7 +766,7 @@ boolean OP_FreezeObjectplace(void) if (!objectplacing) return false; - if ((maptol & TOL_NIGHTS) && (players[consoleplayer].pflags & PF_NIGHTSMODE)) + if (nightsmode && nightsplayer(&players[consoleplayer])) return false; return true; @@ -1049,7 +1049,7 @@ void Command_ObjectPlace_f(void) { objectplacing = true; - if ((players[0].pflags & PF_NIGHTSMODE)) + if (nightsplayer(&players[0])) return; if (!COM_CheckParm("-silent")) @@ -1120,7 +1120,7 @@ void Command_ObjectPlace_f(void) // Don't touch the NiGHTS Objectplace stuff. // ... or if the mo mysteriously vanished. - if (!players[0].mo || (players[0].pflags & PF_NIGHTSMODE)) + if (!players[0].mo || nightsplayer(&players[0])) return; // If still in dummy state, get out of it. diff --git a/src/p_enemy.c b/src/p_enemy.c index 1502f5ff3..f3fb1761c 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -250,7 +250,8 @@ boolean P_Move(mobj_t *actor, fixed_t speed) I_Assert(movedir < NUMDIRS); tryx = actor->x + FixedMul(speed*xspeed[movedir], actor->scale); - if (UNLIKELY(twodlevel || actor->flags2 & MF2_TWOD)) + + if (twodmo(actor)) tryy = actor->y; else tryy = actor->y + FixedMul(speed*yspeed[movedir], actor->scale); @@ -328,7 +329,7 @@ void P_NewChaseDir(mobj_t *actor) else d[1] = DI_NODIR; - if (UNLIKELY(twodlevel || actor->flags2 & MF2_TWOD)) + if (twodmo(actor)) d[2] = DI_NODIR; if (deltay < -FixedMul(10*FRACUNIT, actor->scale)) d[2] = DI_SOUTH; @@ -2762,10 +2763,10 @@ void A_Invincibility(void *thing) { S_StopMusic(); - if (UNLIKELY(mariomode)) + if (mariomode) G_GhostAddColor((INT32) (player - players), GHC_INVINCIBLE); - S_ChangeMusicInternal((UNLIKELY(mariomode)) ? "minvnc" : "invinc", false); + S_ChangeMusicInternal(mariomode ? "minvnc" : "invinc", false); } } @@ -4359,7 +4360,7 @@ void A_MouseThink(void *thing) || (actor->eflags & MFE_VERTICALFLIP && actor->z + actor->height == actor->ceilingz)) && !actor->reactiontime) { - if (UNLIKELY(twodlevel || actor->flags2 & MF2_TWOD)) + if (twodmo(actor)) { if (P_RandomChance(FRACUNIT/2)) actor->angle += ANGLE_180; diff --git a/src/p_inter.c b/src/p_inter.c index a2948d01b..7f533859e 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -589,7 +589,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) special->momx = special->momy = special->momz = 0; P_GivePlayerRings(player, 1); - if (UNLIKELY((maptol & TOL_NIGHTS) && special->type != MT_FLINGRING)) + if (nightsmode && special->type != MT_FLINGRING) P_DoNightsScore(player); break; @@ -601,7 +601,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) special->momx = special->momy = 0; P_GivePlayerRings(player, 1); - if (UNLIKELY((maptol & TOL_NIGHTS) && special->type != MT_FLINGCOIN)) + if (nightsmode && special->type != MT_FLINGCOIN) P_DoNightsScore(player); break; case MT_BLUEBALL: @@ -617,7 +617,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) else special->scalespeed = 4*FRACUNIT/5; - if (UNLIKELY(maptol & TOL_NIGHTS)) + if (nightsmode) P_DoNightsScore(player); break; case MT_AUTOPICKUP: @@ -831,7 +831,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { S_StartSound(toucher, special->info->seesound); - if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(player)) { player->bumpertime = TICRATE/2; if (special->threshold > 0) @@ -1131,7 +1131,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) S_StartSound(toucher, special->info->painsound); return; } - else if (UNLIKELY((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) + else if ((nightsplayer(player) && (player->pflags & PF_DRILLING)) || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? { // Shatter the shield! @@ -2360,11 +2360,11 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (player->exiting) return false; - if (UNLIKELY(!(target->player->pflags & (PF_NIGHTSMODE|PF_NIGHTSFALL)) && (maptol & TOL_NIGHTS))) + if (UNLIKELY(!(target->player->pflags & (PF_NIGHTSMODE|PF_NIGHTSFALL)) && nightsmode)) return false; } - if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) // NiGHTS damage handling + if (nightsplayer(player)) // NiGHTS damage handling { if (!force) { @@ -2609,7 +2609,7 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) ns = FixedMul(((i*FRACUNIT)/16)+2*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) mo->momy = FixedMul(FINESINE(fa),ns); P_SetObjectMomZ(mo, 8*FRACUNIT, false); @@ -2633,7 +2633,7 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) ns = FixedMul(momxy, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) mo->momy = FixedMul(FINESINE(fa),ns); ns = momz; @@ -2740,7 +2740,7 @@ void P_PlayerWeaponPanelBurst(player_t *player) ns = FixedMul(3*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) mo->momy = FixedMul(FINESINE(fa),ns); P_SetObjectMomZ(mo, 4*FRACUNIT, false); @@ -2824,7 +2824,7 @@ void P_PlayerWeaponAmmoBurst(player_t *player) ns = FixedMul(2*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa), ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) mo->momy = FixedMul(FINESINE(fa),ns); P_SetObjectMomZ(mo, 3*FRACUNIT, false); @@ -2940,7 +2940,7 @@ void P_PlayerEmeraldBurst(player_t *player, boolean toss) momx = FixedMul(FINECOSINE(fa), ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) momy = FixedMul(FINESINE(fa),ns); else momy = 0; @@ -2997,7 +2997,7 @@ void P_PlayerFlagBurst(player_t *player, boolean toss) { angle_t fa = P_RandomByte()*FINEANGLES/256; flag->momx = FixedMul(FINECOSINE(fa), FixedMul(6*FRACUNIT, player->mo->scale)); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) flag->momy = FixedMul(FINESINE(fa), FixedMul(6*FRACUNIT, player->mo->scale)); } diff --git a/src/p_local.h b/src/p_local.h index 383469bcc..142e896da 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -59,8 +59,12 @@ extern "C" { #define AIMINGTOSLOPE(aiming) FINESINE((aiming>>ANGLETOFINESHIFT) & FINEMASK) -#define mariomode (maptol & TOL_MARIO) -#define twodlevel (maptol & TOL_2D) +// unused modes, kept for compat +#define nightsmode (UNLIKELY(maptol & TOL_NIGHTS)) +#define nightsplayer(player) (UNLIKELY((player)->pflags & PF_NIGHTSMODE)) +#define mariomode (UNLIKELY(maptol & TOL_MARIO)) +#define twodlevel (UNLIKELY(maptol & TOL_2D)) +#define twodmo(mobj) (UNLIKELY(twodlevel || ((mobj)->flags2 & MF2_TWOD))) // // P_TICK diff --git a/src/p_map.c b/src/p_map.c index 51e9af656..82dba1274 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -136,14 +136,17 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (object->eflags & MFE_SPRUNG) // Object was already sprung this tic return false; - // Spectators don't trigger springs. - if (object->player && object->player->spectator) - return false; - - if (UNLIKELY(object->player && (object->player->pflags & PF_NIGHTSMODE))) + if (object->player) { - /*Someone want to make these work like bumpers?*/ - return false; + // Spectators don't trigger springs. + if (object->player->spectator) + return false; + + if (nightsplayer(object->player)) + { + /*Someone want to make these work like bumpers?*/ + return false; + } } object->standingslope = NULL; // Okay, now we can't return - no launching off at silly angles for you. @@ -160,10 +163,15 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (spring->eflags & MFE_VERTICALFLIP) vertispeed *= -1; + // Vertical springs teleport you on TOP of them. if (vertispeed > 0) + { object->z = spring->z + spring->height + 1; + } else if (vertispeed < 0) + { object->z = spring->z - object->height - 1; + } else { // Horizontal springs teleport you in FRONT of them. @@ -215,7 +223,9 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (object->player) { if (spring->flags & MF_ENEMY) // Spring shells + { P_SetTarget(&spring->target, object); + } if (horizspeed && object->player->cmd.forwardmove == 0 && object->player->cmd.sidemove == 0) { @@ -350,12 +360,13 @@ static boolean PIT_CheckThing(mobj_t *thing) } #endif - if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE)) || (thing->flags & MF_NOCLIPTHING)) + if ((thing->flags & MF_NOCLIPTHING) || !(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE))) return true; // Don't collide with your buddies while NiGHTS-flying. - if (UNLIKELY(tmthing->player && thing->player && (maptol & TOL_NIGHTS) - && ((tmthing->player->pflags & PF_NIGHTSMODE) || (thing->player->pflags & PF_NIGHTSMODE)))) + if (nightsmode && + tmthing->player && thing->player && + (nightsplayer(tmthing->player) || nightsplayer(thing->player))) return true; blockdist = thing->radius + tmthing->radius; @@ -3294,7 +3305,7 @@ stairstep: if (bestslideline != NULL) P_HitSlideLine(bestslideline); // clip the moves - if (UNLIKELY((twodlevel || (mo->flags2 & MF2_TWOD)) && mo->player)) + if (twodmo(mo) && mo->player) { mo->momx = tmxmove; tmymove = 0; @@ -4200,7 +4211,7 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) * Must clear tmthing at tic end, as it might contain a pointer to a removed thinker, or the level might have ended/been ended and we clear the objects it was pointing too. Hopefully we don't need to carry this between tics for sync. */ void P_MapStart(void) { - if (UNLIKELY(tmthing)) + if (tmthing) I_Error("P_MapStart: tmthing set!"); } diff --git a/src/p_mobj.c b/src/p_mobj.c index 49916eb50..007f3d108 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -172,7 +172,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) do { - if (UNLIKELY(state == S_NULL)) + if (state == S_NULL) { // Bad SOC! CONS_Alert(CONS_ERROR, "Cannot remove player mobj by setting its state to S_NULL.\n"); //P_RemoveMobj(mobj); @@ -905,7 +905,7 @@ static void P_PlayerFlip(mobj_t *mo) G_GhostAddFlip((INT32) (mo->player - players)); // Flip aiming to match! - if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) // NiGHTS doesn't use flipcam + if (nightsplayer(mo->player)) // NiGHTS doesn't use flipcam { if (mo->tracer) mo->tracer->eflags ^= MFE_VERTICALFLIP; @@ -998,7 +998,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (mo->player) { - if (UNLIKELY(mo->player->climbing || (mo->player->pflags & PF_NIGHTSMODE))) + if (UNLIKELY(mo->player->climbing || nightsplayer(mo->player))) return 0; if (!(mo->flags2 & MF2_OBJECTFLIP) != !(mo->player->powers[pw_gravityboots])) // negated to turn numeric into bool - would be double negated, but not needed if both would be @@ -1177,7 +1177,7 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) } else if (abs(player->rmomx) < mo->scale && abs(player->rmomy) < mo->scale - && (!(player->cmd.forwardmove && !(twodlevel || mo->flags2 & MF2_TWOD)) && !player->cmd.sidemove && !(player->pflags & PF_SPINNING)) + && (!(player->cmd.forwardmove && !twodmo(mo)) && !player->cmd.sidemove && !(player->pflags & PF_SPINNING)) && !(player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && (abs(player->mo->standingslope->zdelta) >= FRACUNIT/2)) ) { @@ -1619,7 +1619,7 @@ void P_XYMovement(mobj_t *mo) // Check the gravity status. P_CheckGravity(mo, false); - if (UNLIKELY(player && !moved && player->pflags & PF_NIGHTSMODE && mo->target)) + if (player && !moved && nightsplayer(player) && mo->target) { angle_t fa; @@ -1669,11 +1669,14 @@ void P_XYMovement(mobj_t *mo) if (mo->flags & MF_MISSILE || mo->flags2 & MF2_SKULLFLY || mo->type == MT_SHELL || mo->type == MT_VULTURE) return; // no friction for missiles ever - if (player && player->homing) // no friction for homing - return; + if (player) + { + if (player->homing) // no friction for homing + return; - if (UNLIKELY(player && player->pflags & PF_NIGHTSMODE)) - return; // no friction for NiGHTS players + if (nightsplayer(player)) + return; // no friction for NiGHTS players + } if ((mo->type == MT_BIGTUMBLEWEED || mo->type == MT_LITTLETUMBLEWEED) && (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8)) // Special exception for tumbleweeds on slopes @@ -2221,7 +2224,7 @@ static boolean P_ZMovement(mobj_t *mo) || mo->type == MT_CANNONBALLDECOR || mo->type == MT_FALLINGROCK) { - if (UNLIKELY(maptol & TOL_NIGHTS)) + if (nightsmode) mom.z = -FixedDiv(mom.z, 10*FRACUNIT); else mom.z = -FixedMul(mom.z, FixedDiv(17*FRACUNIT,20*FRACUNIT)); @@ -2359,11 +2362,9 @@ static boolean P_ZMovement(mobj_t *mo) { if (mo->flags2 & MF2_SKULLFLY) // the skull slammed into something mo->momz = -mo->momz; - else - // Flags bounce - if (UNLIKELY(mo->type == MT_REDFLAG || mo->type == MT_BLUEFLAG)) + else if (UNLIKELY(mo->type == MT_REDFLAG || mo->type == MT_BLUEFLAG)) // Flags bounce { - if (UNLIKELY(maptol & TOL_NIGHTS)) + if (nightsmode) mo->momz = -FixedDiv(mo->momz, 10*FRACUNIT); else mo->momz = -FixedMul(mo->momz, FixedDiv(17*FRACUNIT,20*FRACUNIT)); @@ -2429,7 +2430,7 @@ static void P_PlayerZMovement(mobj_t *mo) else mo->z = mo->floorz; - if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(mo->player)) { // bounce off floor if you were flying towards it if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 0 && mo->player->flyangle < 180) @@ -2620,7 +2621,7 @@ nightsdone: else mo->z = mo->ceilingz - mo->height; - if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(mo->player)) { // bounce off ceiling if you were flying towards it if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 180 && mo->player->flyangle <= 359) @@ -2665,7 +2666,7 @@ nightsdone: } // hit the ceiling - if (UNLIKELY(mariomode)) + if (mariomode) S_StartSound(mo, sfx_mario1); if (!mo->player->climbing) @@ -3223,7 +3224,7 @@ void P_CalcChasePostImg(player_t *player, camera_t *thiscam) player_flipcam = cv_flipcam[pnum].value; } - const boolean flipcam = (player_flipcam && player->mo->eflags & MFE_VERTICALFLIP && LIKELY(!(player->pflags & PF_NIGHTSMODE))); + const boolean flipcam = (player_flipcam && player->mo->eflags & MFE_VERTICALFLIP && !nightsplayer(player)); UINT8 postimgtype = 0; if (encoremode) @@ -3406,7 +3407,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) P_CheckPosition(mobj, mobj->x, mobj->y); goto animonly; } - else if (UNLIKELY(mobj->player->pflags & PF_MACESPIN)) + else if (mobj->player->pflags & PF_MACESPIN) { P_CheckPosition(mobj, mobj->x, mobj->y); goto animonly; @@ -3520,7 +3521,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) } else { - if (LIKELY(!(mobj->player->pflags & PF_NIGHTSMODE))) // "jumping" is used for drilling + if (!nightsplayer(mobj->player)) // "jumping" is used for drilling mobj->player->jumping = 0; mobj->player->pflags &= ~PF_JUMPED; @@ -8552,7 +8553,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (mobj->tracer && mobj->tracer->player) { - if (LIKELY(!(mobj->tracer->player->pflags & PF_NIGHTSMODE))) + if (!nightsplayer(mobj->tracer->player)) { mobj->flags &= ~MF_NOGRAVITY; mobj->flags2 &= ~MF2_DONTDRAW; @@ -8576,7 +8577,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_SetTarget(&mobj->target, NULL); } - if (UNLIKELY(mobj->tracer->player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(mobj->tracer->player)) { if (mobj->tracer->player->bonustime) { @@ -9078,7 +9079,7 @@ void P_MobjThinker(mobj_t *mobj) const sector_t *sec1 = mobj->subsector ? mobj->subsector->sector : NULL; // 970 allows ANY mobj to trigger a linedef exec - if (UNLIKELY(!mobj->islocal && sec1 && GETSECSPECIAL(sec1->special, 2) == 8)) // BEWARE: islocal does not exist in vanilla + if (!mobj->islocal && sec1 && GETSECSPECIAL(sec1->special, 2) == 8) // BEWARE: islocal does not exist in vanilla { sector_t *sec2; sec2 = P_ThingOnSpecial3DFloor(mobj); @@ -9144,7 +9145,7 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->flags2 & MF2_FIRING && mobj->target && mobj->health > 0) P_FiringThink(mobj); - if (UNLIKELY(mobj->flags & MF_AMBIENT)) + if (mobj->flags & MF_AMBIENT) { if (leveltime % mobj->health) return; @@ -9208,8 +9209,8 @@ void P_MobjThinker(mobj_t *mobj) P_ButteredSlope(mobj); } - if (UNLIKELY(mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health - && P_CheckDeathPitCollide(mobj))) // extra pit check in case these didn't have momz + if (mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health + && P_CheckDeathPitCollide(mobj)) // extra pit check in case these didn't have momz { P_KillMobj(mobj, NULL, NULL); return; @@ -9218,10 +9219,7 @@ void P_MobjThinker(mobj_t *mobj) // Crush enemies! if (mobj->ceilingz - mobj->floorz < mobj->height) { - if (UNLIKELY(( - (mobj->flags & (MF_ENEMY|MF_BOSS) - && mobj->flags & MF_SHOOTABLE) - || mobj->type == MT_EGGSHIELD)) + if (((mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->flags & MF_SHOOTABLE) || mobj->type == MT_EGGSHIELD) && !(mobj->flags & MF_NOCLIPHEIGHT) && mobj->health > 0) { @@ -9243,7 +9241,7 @@ void P_MobjThinker(mobj_t *mobj) if (P_MobjWasRemoved(mobj)) return; - if (UNLIKELY(P_WeaponOrPanel(mobj->type))) + if (P_WeaponOrPanel(mobj->type)) { if (mobj->health == 0) // Fading tile { @@ -10131,14 +10129,14 @@ void P_RemoveMobj(mobj_t *mobj) } } // Rings only, please! - else if (UNLIKELY(mobj->spawnpoint && + else if (mobj->spawnpoint && !(mobj->flags2 & MF2_DONTRESPAWN) && (mobj->type == MT_RING || mobj->type == MT_COIN || mobj->type == MT_BLUEBALL || mobj->type == MT_REDTEAMRING || mobj->type == MT_BLUETEAMRING - || P_WeaponOrPanel(mobj->type)))) + || P_WeaponOrPanel(mobj->type))) { itemrespawnque[iquehead] = mobj->spawnpoint; itemrespawntime[iquehead] = leveltime; diff --git a/src/p_spec.c b/src/p_spec.c index 9aff26b3c..35efaa857 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3880,7 +3880,7 @@ DoneSection2: player->kartstuff[k_lapanimation] = 80; - if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(player)) player->drillmeter += 48*20; if (netgame && player->laps >= (UINT8)cv_numlaps.value) @@ -7126,7 +7126,7 @@ static inline boolean PIT_PushThing(mobj_t *thing) return false; // Allow this to affect pushable objects at some point? - if (thing->player && (!(thing->flags & (MF_NOGRAVITY | MF_NOCLIP)) || UNLIKELY(thing->player->pflags & PF_NIGHTSMODE))) + if (thing->player && (!(thing->flags & (MF_NOGRAVITY | MF_NOCLIP)) || nightsplayer(thing->player))) { INT32 dist; INT32 speed; @@ -7156,7 +7156,7 @@ static inline boolean PIT_PushThing(mobj_t *thing) // Written with bits and pieces of P_HomingAttack if ((speed > 0) && (P_CheckSight(thing, tmpusher->source))) { - if (LIKELY(!(thing->player->pflags & PF_NIGHTSMODE))) + if (!nightsplayer(thing->player)) { // only push wrt Z if health & 1 (mapthing has ambush flag) if (tmpusher->source->health & 1) diff --git a/src/p_user.c b/src/p_user.c index 90bca6cff..8480b0e60 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -74,7 +74,7 @@ void P_Thrust(mobj_t *mo, angle_t angle, fixed_t move) mo->momx += FixedMul(move, FINECOSINE(angle)); - if (LIKELY(!(twodlevel || (mo->flags2 & MF2_TWOD)))) + if (!twodmo(mo)) mo->momy += FixedMul(move, FINESINE(angle)); } @@ -90,7 +90,7 @@ void P_InstaThrust(mobj_t *mo, angle_t angle, fixed_t move) mo->momx = FixedMul(move, FINECOSINE(angle)); - if (LIKELY(!(twodlevel || (mo->flags2 & MF2_TWOD)))) + if (!twodmo(mo)) mo->momy = FixedMul(move,FINESINE(angle)); } @@ -475,7 +475,7 @@ void P_PlayLivesJingle(player_t *player) if (UNLIKELY(use1upSound)) S_StartSound(NULL, sfx_oneup); - else if (UNLIKELY(mariomode)) + else if (mariomode) S_StartSound(NULL, sfx_marioa); else { @@ -503,7 +503,7 @@ void P_PlayRinglossSound(mobj_t *source, mobj_t *damager) S_StartSound(NULL, sfx); } else - S_StartSound(source, UNLIKELY(mariomode) ? sfx_mario8 : sfx_khurt1 + key); + S_StartSound(source, mariomode ? sfx_mario8 : sfx_khurt1 + key); } else S_StartSound(source, sfx_slip); @@ -1725,7 +1725,7 @@ static void P_DoBubbleBreath(player_t *player) else zh = player->mo->z + FixedDiv(player->mo->height,5*(FRACUNIT/4)); - if (!(player->mo->eflags & MFE_UNDERWATER) || player->spectator || ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL && !(player->pflags & PF_NIGHTSMODE))) + if (!(player->mo->eflags & MFE_UNDERWATER) || player->spectator || ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL && !nightsplayer(player))) return; if (P_RandomChance(FRACUNIT/16)) @@ -2298,7 +2298,7 @@ static void P_MovePlayer(player_t *player) P_3dMovement(player); } - if (UNLIKELY(maptol & TOL_2D)) // psure this doesent even work at all + if (twodlevel) // psure this doesent even work at all runspd = FixedMul(runspd, 2*FRACUNIT/3); ///////////////////////// @@ -2748,8 +2748,8 @@ boolean P_LookForEnemies(player_t *player) if (modist > FixedMul(RING_DIST, player->mo->scale)) continue; // out of range - if (UNLIKELY((twodlevel || player->mo->flags2 & MF2_TWOD) - && abs(player->mo->y-mo->y) > player->mo->radius)) + + if (twodmo(player->mo) && abs(player->mo->y-mo->y) > player->mo->radius) continue; // not in your 2d plane if (closestmo && modist > P_AproxDistance(P_AproxDistance(player->mo->x-closestmo->x, @@ -3508,7 +3508,7 @@ static boolean P_CheckNoclipCameraPosition(player_t *player, camera_t *thiscam, boolean cameranoclip; mobj_t *mo = player->mo; - cameranoclip = ((player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) + cameranoclip = (nightsplayer(player) || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)) // Noclipping player camera noclips too!! || (leveltime < introtime)); // Kart intro cam @@ -4097,7 +4097,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall angle -= (angle - thiscam->pitch)/2; } - if (player->playerstate != PST_DEAD && LIKELY(!((player->pflags & PF_NIGHTSMODE) && player->exiting))) + if (player->playerstate != PST_DEAD && !(nightsplayer(player) && player->exiting)) angle += (focusaiming < ANGLE_180 ? focusaiming/2 : InvAngle(InvAngle(focusaiming)/2)); // overcomplicated version of '((signed)focusaiming)/2;' if (!camstill && !timeover) // Keep the view still... @@ -4174,7 +4174,7 @@ boolean P_SpectatorJoinGame(player_t *player) // Team changing in Team Match and CTF // Pressing fire assigns you to a team that needs players if allowed. // Partial code reproduction from p_tick.c autobalance code. - else if (UNLIKELY(G_GametypeHasTeams())) + else if (G_GametypeHasTeams()) { INT32 changeto = 0; INT32 z, numplayersred = 0, numplayersblue = 0; @@ -4871,7 +4871,7 @@ void P_PlayerThink(player_t *player) // Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot. if (UNLIKELY(!objectplacing && !((netgame || multiplayer) && player->spectator) - && maptol & TOL_NIGHTS && (!(player->pflags & PF_NIGHTSMODE) || player->powers[pw_nights_helper]))) + && nightsmode && (!nightsplayer(player) || player->powers[pw_nights_helper]))) { thinker_t *th; mobj_t *mo2; @@ -4973,7 +4973,7 @@ void P_PlayerThink(player_t *player) #endif // check for use - if (LIKELY(!(player->pflags & PF_NIGHTSMODE))) + if (!nightsplayer(player)) { if (cmd->buttons & BT_BRAKE) player->pflags |= PF_USEDOWN; @@ -5164,7 +5164,7 @@ void P_PlayerAfterThink(player_t *player) } } - if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(player)) { player->powers[pw_gravityboots] = 0; } From 56c2178bde9374d119747c1dc7c3f5a6f4f0b073 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 18:34:19 +0200 Subject: [PATCH 471/589] cleanup COMPAT_VANILLA mobj checks move stuff into a helper func, which just returns if mo != NULL in vanilla compat mode, otherwise returns P_MobjWasRemoved reasoning for this crap is in the comment above said helper --- src/k_kart.c | 20 ++++++-------------- src/p_inter.c | 20 ++++---------------- src/p_local.h | 11 +++++++++++ src/p_map.c | 17 ++++++++++------- src/p_mobj.c | 44 ++++++++++---------------------------------- 5 files changed, 41 insertions(+), 71 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 461041aa8..d7759a3f7 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4725,11 +4725,7 @@ void K_RepairOrbitChain(mobj_t *orbit) } // Then recount to make sure item amount is correct -#ifndef COMPAT_VANILLA - if (!P_MobjWasRemoved(orbit->target) && orbit->target->player) -#else - if (orbit->target && orbit->target->player) -#endif + if (!P_MobjWasRemovedCompat(orbit->target) && orbit->target->player) { INT32 num = 0; @@ -4746,11 +4742,7 @@ void K_RepairOrbitChain(mobj_t *orbit) prev->movedir = num; } -#ifndef COMPAT_VANILLA - if (!P_MobjWasRemoved(orbit->target)) -#else - if (orbit->target) -#endif + if (!P_MobjWasRemovedCompat(orbit->target)) orbit->target->player->kartstuff[k_itemamount] = num; } } @@ -4897,7 +4889,7 @@ static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z // Move the hnext chain! static void K_MoveHeldObjects(player_t *player) { - if (!player->mo) + if (P_MobjWasRemovedCompat(player->mo)) return; if (!player->mo->hnext) @@ -6600,7 +6592,7 @@ static void K_PlayerItemThink(player_t *player, boolean onground, boolean oldatt { mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_BANANA_SHIELD); - if (!mo) + if (P_MobjWasRemovedCompat(mo)) { player->kartstuff[k_itemamount] = moloop; break; @@ -6661,7 +6653,7 @@ static void K_PlayerItemThink(player_t *player, boolean onground, boolean oldatt newangle = (player->mo->angle + ANGLE_157h) + FixedAngle(((360 / player->kartstuff[k_itemamount]) * moloop) << FRACBITS) + ANGLE_90; mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_ORBINAUT_SHIELD); - if (!mo) + if (P_MobjWasRemovedCompat(mo)) { player->kartstuff[k_itemamount] = moloop; break; @@ -6704,7 +6696,7 @@ static void K_PlayerItemThink(player_t *player, boolean onground, boolean oldatt newangle = (player->mo->angle + ANGLE_157h) + FixedAngle(((360 / player->kartstuff[k_itemamount]) * moloop) << FRACBITS) + ANGLE_90; mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_JAWZ_SHIELD); - if (!mo) + if (P_MobjWasRemovedCompat(mo)) { player->kartstuff[k_itemamount] = moloop; break; diff --git a/src/p_inter.c b/src/p_inter.c index 7f533859e..856050959 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1466,11 +1466,7 @@ static void P_UpdateRemovedOrbital(mobj_t *target, mobj_t *inflictor, mobj_t *so { // SRB2kart // I wish I knew a better way to do this -#ifndef COMPAT_VANILLA - if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) -#else - if (target->target && target->target->player && target->target->player->mo) -#endif + if (!P_MobjWasRemovedCompat(target->target) && target->target->player && !P_MobjWasRemovedCompat(target->target->player->mo)) { if (target->target->player->kartstuff[k_eggmanheld] && target->type == MT_EGGMANITEM_SHIELD) target->target->player->kartstuff[k_eggmanheld] = 0; @@ -1483,11 +1479,7 @@ static void P_UpdateRemovedOrbital(mobj_t *target, mobj_t *inflictor, mobj_t *so { if (target->movedir != 0 && target->movedir < (UINT16)target->target->player->kartstuff[k_itemamount]) { -#ifndef COMPAT_VANILLA - if (!P_MobjWasRemoved(target->target->hnext)) -#else - if (target->target->hnext) -#endif + if (!P_MobjWasRemovedCompat(target->target->hnext)) K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; @@ -2245,11 +2237,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; // well no clue but this may happen ig -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(target)) -#else - if (!target) -#endif + if (P_MobjWasRemovedCompat(target)) return false; if (target->health <= 0) @@ -2266,7 +2254,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; } - if (source && source->player && source->player->spectator) + if (!P_MobjWasRemovedCompat(source) && source->player && source->player->spectator) return false; } diff --git a/src/p_local.h b/src/p_local.h index 142e896da..1198335ec 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -291,6 +291,17 @@ FUNCINLINE static ATTRINLINE boolean P_MobjWasRemoved(const mobj_t *mobj) return (!mobj || mobj->thinker.function != (actionf_p1)P_MobjThinker); } +// stupid, but kart allows mobjs that are marked to be removed to be accessed and modified in many cases +// so can only check if its not NULL in vanilla compat mode +FUNCINLINE static ATTRINLINE boolean P_MobjWasRemovedCompat(const mobj_t *mobj) +{ +#ifdef COMPAT_VANILLA + return (!mobj); +#else + return P_MobjWasRemoved(mobj); +#endif +} + fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect); fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect); #define P_GetFloorZ(mobj, sector, x, y, line) P_MobjFloorZ(mobj, sector, NULL, x, y, line, false, false) diff --git a/src/p_map.c b/src/p_map.c index 82dba1274..01ab5c0e8 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -322,13 +322,13 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing == tmthing) return true; - // Ignore... things. - if (!tmthing || P_MobjWasRemoved(thing)) - return true; - I_Assert(!P_MobjWasRemoved(tmthing)); I_Assert(!P_MobjWasRemoved(thing)); + // Ignore... things. + if (P_MobjWasRemovedCompat(tmthing) || P_MobjWasRemoved(thing)) + return true; + // Ignore spectators if ((tmthing->player && tmthing->player->spectator) || (thing->player && thing->player->spectator)) @@ -3371,12 +3371,15 @@ void P_BouncePlayerMove(mobj_t *mo) { fixed_t leadx, leady; fixed_t trailx, traily; - fixed_t mmomx = 0, mmomy = 0; - fixed_t oldmomx = mo->momx, oldmomy = mo->momy; + fixed_t mmomx, mmomy; + fixed_t oldmomx, oldmomy; - if (!mo->player) + if (mo->player == NULL) return; + oldmomx = mo->momx; + oldmomy = mo->momy; + if (mo->player->spectator) { P_SlideMove(mo, true); diff --git a/src/p_mobj.c b/src/p_mobj.c index 007f3d108..02e1e1bc6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -347,7 +347,7 @@ void P_ExplodeMissile(mobj_t *mo) explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - if (explodemo) + if (!P_MobjWasRemovedCompat(explodemo)) { P_SetScale(explodemo, mo->scale); explodemo->destscale = mo->destscale; @@ -358,7 +358,7 @@ void P_ExplodeMissile(mobj_t *mo) explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - if (explodemo) + if (!P_MobjWasRemovedCompat(explodemo)) { P_SetScale(explodemo, mo->scale); explodemo->destscale = mo->destscale; @@ -369,7 +369,7 @@ void P_ExplodeMissile(mobj_t *mo) explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - if (explodemo) + if (!P_MobjWasRemovedCompat(explodemo)) { P_SetScale(explodemo, mo->scale); explodemo->destscale = mo->destscale; @@ -380,7 +380,7 @@ void P_ExplodeMissile(mobj_t *mo) explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - if (explodemo) + if (!P_MobjWasRemovedCompat(explodemo)) { P_SetScale(explodemo, mo->scale); explodemo->destscale = mo->destscale; @@ -3380,11 +3380,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return; P_MobjCheckWater(mobj); @@ -5634,11 +5630,7 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale) player_t *player; fixed_t oldscale; -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return; oldscale = mobj->scale; //keep for adjusting stuff below @@ -8989,11 +8981,7 @@ static boolean P_FuseThink(mobj_t *mobj) static boolean P_MobjPushableThink(mobj_t *mobj) { // would be cool if we could use P_MobjWasRemoved Zzz... -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return false; P_MobjCheckWater(mobj); @@ -9199,11 +9187,7 @@ void P_MobjThinker(mobj_t *mobj) { P_TryMove(mobj, mobj->x, mobj->y, true); // Sets mo->standingslope correctly -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) // anything that calls checkposition can be lethal -#else - if (!mobj) // anything that calls checkposition can be lethal -#endif + if (P_MobjWasRemovedCompat(mobj)) // anything that calls checkposition can be lethal return; P_ButteredSlope(mobj); @@ -9228,11 +9212,7 @@ void P_MobjThinker(mobj_t *mobj) } } -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return; // obligatory paranoia check // Can end up here if a player dies. @@ -9292,11 +9272,7 @@ void P_PushableThinker(mobj_t *mobj) I_Assert(!P_MobjWasRemoved(mobj)); -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return; sec = mobj->subsector->sector; From 1dee3060dd9f9729a83d3c09069af00d30027a4f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 18:31:02 +0200 Subject: [PATCH 472/589] add some more mobj checks to p_map cross-checked against srb2 next branch --- src/p_map.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 01ab5c0e8..ce43c2235 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3190,6 +3190,9 @@ void P_SlideMove(mobj_t *mo, boolean forceslide) INT16 hitcount = 0; boolean success = false; + if (P_MobjWasRemovedCompat(mo)) + return; + if (tmhitthing && mo->z + mo->height > tmhitthing->z && mo->z < tmhitthing->z + tmhitthing->height) { // Don't mess with your momentum if it's a pushable object. Pushables do their own crazy things already. @@ -3226,6 +3229,9 @@ void P_SlideMove(mobj_t *mo, boolean forceslide) bestslideline = NULL; retry: + if (P_MobjWasRemovedCompat(mo)) + return; + if (++hitcount == 3) goto stairstep; // don't loop forever @@ -3274,7 +3280,13 @@ retry: // the move must have hit the middle, so stairstep stairstep: if (!P_TryMove(mo, mo->x, mo->y + mo->momy, true)) //Allow things to drop off. + { + if (P_MobjWasRemovedCompat(mo)) + return; + P_TryMove(mo, mo->x + mo->momx, mo->y, true); + } + return; } @@ -3286,7 +3298,12 @@ stairstep: newy = FixedMul(mo->momy, bestslidefrac); if (!P_TryMove(mo, mo->x + newx, mo->y + newy, true)) + { goto stairstep; + } + + if (P_MobjWasRemovedCompat(mo)) + return; } // Now continue along the wall. @@ -3357,8 +3374,11 @@ stairstep: goto retry; } + if (P_MobjWasRemovedCompat(mo)) + return; + success = true; - } while(tmxmove || tmymove); + } while (tmxmove || tmymove); } // @@ -3374,6 +3394,9 @@ void P_BouncePlayerMove(mobj_t *mo) fixed_t mmomx, mmomy; fixed_t oldmomx, oldmomy; + if (P_MobjWasRemovedCompat(mo)) + return; + if (mo->player == NULL) return; @@ -3468,6 +3491,9 @@ void P_BouncePlayerMove(mobj_t *mo) if (!P_TryMove(mo, mo->x + tmxmove, mo->y + tmymove, true)) { + if (P_MobjWasRemovedCompat(mo)) + return; + P_TryMove(mo, mo->x - oldmomx, mo->y - oldmomy, true); } } @@ -3485,6 +3511,9 @@ void P_BounceMove(mobj_t *mo) INT32 hitcount; fixed_t mmomx = 0, mmomy = 0; + if (P_MobjWasRemovedCompat(mo)) + return; + if (mo->player) { P_BouncePlayerMove(mo); @@ -3501,6 +3530,9 @@ void P_BounceMove(mobj_t *mo) hitcount = 0; retry: + if (P_MobjWasRemovedCompat(mo)) + return; + if (++hitcount == 3) goto bounceback; // don't loop forever @@ -3559,7 +3591,12 @@ bounceback: newy = FixedMul(mmomy, bestslidefrac); if (!P_TryMove(mo, mo->x + newx, mo->y + newy, true)) + { + if (P_MobjWasRemovedCompat(mo)) + return; + goto bounceback; + } } // Now continue along the wall. From bba86fe4af56d35188c0ec13cbabde92bf3932ed Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 18:10:07 +0200 Subject: [PATCH 473/589] fix DRAWONLYFORX sprite visability handling this effectively didnt do anything and had a typo for the player 3 case anyways --- src/r_things.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index d891d40ce..bc01c4cc8 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2941,16 +2941,16 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) /* Check if thing may be drawn from our current view. */ boolean R_ThingVisible(mobj_t *thing) { - if (UNLIKELY((thing->sprite == SPR_NULL) || (thing->flags2 & MF2_DONTDRAW))) + if ((thing->sprite == SPR_NULL) || (thing->flags2 & MF2_DONTDRAW)) return false; - if (UNLIKELY(splitscreen)) + if (splitscreen) { - if ((viewssnum == 0 && (thing->eflags & MFE_DRAWONLYFORP1)) - || (viewssnum == 1 && (thing->eflags & MFE_DRAWONLYFORP2)) - || (viewssnum == 2 && (thing->eflags & MFE_DRAWONLYFORP2)) - || (viewssnum == 3 && (thing->eflags & MFE_DRAWONLYFORP4))) - return true; + if (((thing->eflags & MFE_DRAWONLYFORP1) && viewssnum != 0) + || ((thing->eflags & MFE_DRAWONLYFORP2) && viewssnum != 1) + || ((thing->eflags & MFE_DRAWONLYFORP3) && viewssnum != 2) + || ((thing->eflags & MFE_DRAWONLYFORP4) && viewssnum != 3)) + return false; } return true; From 63e4c5a63ddb168687513679d8585d29ec7da5fd Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 18:09:20 +0200 Subject: [PATCH 474/589] use viewsin and viewcos for spherefrustum checks in gl dont need all those yaw vars, since they effectively map to gl_viewsin and -gl_viewcos respectively while those are less accurate due to being fixed point, there appears to be no visual issues from this and seems to even slightly improve performance in some cases --- src/hardware/hw_batching.c | 1 + src/hardware/hw_main.cpp | 30 +++++++++--------------------- src/hardware/r_opengl/r_opengl.c | 6 +++--- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 8bf7f7375..9b1699029 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -183,6 +183,7 @@ static int comparePolygons(const void *p1, const void *p2) UINT32 downloaded1 = poly1->texture ? poly1->texture->downloaded : 0; // there should be a opengl texture name here, usable for comparisons UINT32 downloaded2 = poly2->texture ? poly2->texture->downloaded : 0; + diff64 = downloaded1 - downloaded2; if (diff64 != 0) return diff64; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 642fdfec7..c01c59afc 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -84,11 +84,6 @@ float gl_viewsin = 0.0f, gl_viewcos = 0.0f; static float gl_viewludsin, gl_viewludcos; static angle_t gl_aimingangle; -static float yaw = 0.0f; -static float inv_yaw = 0.0f; -static float cos_inv_yaw = 0.0f; -static float sin_inv_yaw = 0.0f; - static constexpr float deg2radians = (M_PIf / 180.0f); seg_t *gl_curline = NULL; @@ -4764,9 +4759,9 @@ static void HWR_ProjectSprite(mobj_t *thing) // if the sprite is out of our view, dont need to draw it X) if (!gld_SphereInFrustum( - (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, + (FixedToFloat(interp.x)) + gl_viewsin * (x1 + x2) / 2.0f, FixedToFloat(interp.z) + (y1 + y2) / 2.0f, - FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + FixedToFloat(interp.y) - (-gl_viewcos) * (x1 + x2) / 2.0f, //1.5 == sqrt(2) + small delta for MF_FOREGROUND std::max(FixedToFloat(spr_width) * spritexscale, FixedToFloat(spr_height) * spriteyscale) / 2.0f * 1.5f)) @@ -4984,9 +4979,9 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) y2 *= thing_scale; if (!gld_SphereInFrustum( - (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, + (FixedToFloat(interp.x)) + gl_viewsin * (x1 + x2) / 2.0f, FixedToFloat(interp.z) + (y1 + y2) / 2.0f, - FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + FixedToFloat(interp.y) - (-gl_viewcos) * (x1 + x2) / 2.0f, //1.5 == sqrt(2) + small delta for MF_FOREGROUND std::max(FixedToFloat(spr_width) * thing_scale, FixedToFloat(spr_height) * thing_scale) / 2.0f * 1.5f)) @@ -5116,24 +5111,22 @@ void HWR_BuildSkyDome(void) int c, r; signed char yflip; static constexpr int row_count = 4; - int col_count = 4; + static constexpr int col_count = (4 * 16); float delta; gl_sky_t *sky = &gl_sky; gl_skyvertex_t *vertex_p; const texture_t *texture = textures[texturetranslation[skytexture]]; - col_count *= 16; - if ((sky->columns != col_count) || (sky->rows != row_count)) HWR_ClearSkyDome(); sky->columns = col_count; sky->rows = row_count; - sky->vertex_count = 2 * sky->rows * (sky->columns * 2 + 2) + sky->columns * 2; + sky->vertex_count = 2 * row_count * (col_count * 2 + 2) + col_count * 2; if (!sky->loops) - sky->loops = static_cast(malloc((sky->rows * 2 + 2) * sizeof(sky->loops[0]))); + sky->loops = static_cast(malloc((row_count * 2 + 2) * sizeof(sky->loops[0]))); // create vertex array if (!sky->data) @@ -5397,12 +5390,6 @@ void HWR_SetTransform(float fpov) HWR_SetTransformAiming(&atransform); atransform.angley = static_cast(viewangle >> ANGLETOFINESHIFT)*(FINEDEGREE); - yaw = 270.0f - atransform.angley; - inv_yaw = 180.0f - yaw; - const float inv_yaw_radians = inv_yaw * deg2radians; - cos_inv_yaw = cosf(inv_yaw_radians); - sin_inv_yaw = sinf(inv_yaw_radians); - // only needed for sprite billboarding if (cv_glspritebillboarding.value && !cv_glshearing.value) { @@ -5540,7 +5527,8 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool if constexpr (Type == RenderViewpointType::kPortal) { - gl_collect_skywalls = (allow_portals && !rootportal && portallist.base && (!skyboxmo[0] || !cv_skybox.value)); // if portals have been drawn in the main view, then render skywalls differently + // if portals have been drawn in the main view, then render skywalls differently + gl_collect_skywalls = (allow_portals && !rootportal && portallist.base && (!skyboxmo[0] || !cv_skybox.value)); // HAYA: Save the old portal state, and turn portals off while normally rendering the BSP tree. // This fixes specific effects not working, such as horizon lines. diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 071e67f03..aff722773 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2490,7 +2490,7 @@ void GL_RenderSkyDome(gl_sky_t *sky) GL_Shader_SetUniforms(NULL, NULL, NULL, NULL); // Build the sky dome! Yes! - if (sky->rebuild) + if (sky->rebuild || !sky->vbo) { // delete VBO when already exists if (sky->vbo) @@ -3208,8 +3208,8 @@ void GL_SetTransform(FTransform *stransform) { float dy = stransform->viewaiming * 2; - if (stransform->fliptype == TRANSFORM_FLIP - || stransform->fliptype == TRANSFORM_MIRRORFLIP) + if (stransform->fliptype == TRANSFORM_FLIP || + stransform->fliptype == TRANSFORM_MIRRORFLIP) dy *= -1.0f; pglTranslatef(0.0f, -dy/BASEVIDHEIGHT, 0.0f); From 41cbce3ed3b108427deddd233eaf9cc907388428 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 19:42:58 +0200 Subject: [PATCH 475/589] hack for kartdebugcheckpoint display see comment --- src/k_hud.c | 6 ++++- src/k_kart.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/k_kart.h | 2 ++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/src/k_hud.c b/src/k_hud.c index 0deb8f0f5..3dd36c95d 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4576,7 +4576,11 @@ static void K_drawCheckpointDebugger(void) else V_DrawString(8, 184, 0, va("Checkpoint: %d / %d (Skip: %d)", stplyr->starpostnum, numstarposts, ((numstarposts/2) + stplyr->starpostnum))); - V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", stplyr->kartstuff[k_prevcheck], stplyr->kartstuff[k_nextcheck])); + // really gnarly hack + const INT32 prevcheck = (stprevnextchecks[0] != INT32_MAX) ? stprevnextchecks[0]: stplyr->kartstuff[k_prevcheck]; + const INT32 nextcheck = (stprevnextchecks[1] != INT32_MAX) ? stprevnextchecks[1]: stplyr->kartstuff[k_nextcheck]; + + V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", prevcheck, nextcheck)); } // determines if gametype info (laps/bumpers) should be hidden diff --git a/src/k_kart.c b/src/k_kart.c index d7759a3f7..39961c1a9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6212,6 +6212,64 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_brakedrift] = 0; } +INT32 stprevnextchecks[2] = {INT32_MAX, INT32_MAX}; // there wont be any map this big, wont there?..... + +// K_KartUpdatePosition has a bug where whatever player comes last in the players array +// gets its distance calculations applied twice +// since we cannot fix this due to compat concerns (kartstuff is exposed after all) +// we gotta do this shit hack to atleast fix the debugcheckpoint display +static void K_KartUpdatePositionDebugHack(player_t *player, player_t *otherplayer) +{ + mobj_t *mo; + fixed_t pmo; + fixed_t ppcd, pncd; + + // dont need this crap + if (!cv_kartdebugcheckpoint.value) + return; + + // not checking against ourselves + if (player != otherplayer) + return; + + // dont care if its not first displayplayer + // since this is only used for the debug display + if (player != &players[displayplayers[0]]) + return; + + ppcd = pncd = 0; + stprevnextchecks[0] = stprevnextchecks[1] = 0; + + // This checks every thing on the map, and looks for MT_BOSS3WAYPOINT (the thing we're using for checkpoint wp's, for now) + for (mo = waypointcap; mo != NULL; mo = mo->tracer) + { + const boolean isprevcheckpointp = mo->health == player->starpostnum; + const boolean isnextcheckpointp = mo->health == (player->starpostnum + 1); + + if ((isprevcheckpointp || isnextcheckpointp) && (!mo->movecount || mo->movecount == player->laps+1)) + { + pmo = P_AproxDistance(P_AproxDistance( mo->x - player->mo->x, + mo->y - player->mo->y), + mo->z - player->mo->z) / FRACUNIT; + + if (isprevcheckpointp) + { + stprevnextchecks[0] += pmo; + ppcd++; + } + + if (isnextcheckpointp) + { + stprevnextchecks[1] += pmo; + pncd++; + } + } + } + + if (ppcd > 1) stprevnextchecks[0] /= ppcd; + if (pncd > 1) stprevnextchecks[1] /= pncd; +} + // // K_KartUpdatePosition // @@ -6223,6 +6281,9 @@ void K_KartUpdatePosition(player_t *player) fixed_t pmo, imo; mobj_t *mo; + // always reset this + stprevnextchecks[0] = stprevnextchecks[1] = INT32_MAX; + if (player->spectator || !player->mo) return; @@ -6323,6 +6384,9 @@ void K_KartUpdatePosition(player_t *player) if (players[i].starposttime < player->starposttime) position++; } + + // stupid hack + K_KartUpdatePositionDebugHack(player, &players[i]); } } else if (G_BattleGametype()) diff --git a/src/k_kart.h b/src/k_kart.h index 9307ce273..4d81375cd 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -32,6 +32,8 @@ extern consvar_t cv_bananajitter; extern consvar_t cv_bananthrowroll; extern consvar_t cv_airsparks; +extern INT32 stprevnextchecks[2]; + boolean K_IsPlayerLosing(player_t *player); boolean K_IsPlayerWanted(player_t *player); INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean spbrush); From fdd8381258c3ce9322ab06896bdb6f710da747a9 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 3 Jul 2026 15:10:02 +0300 Subject: [PATCH 476/589] Fix 'attack or protect' text being offcentered on certain resolutions --- src/k_hud.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 3dd36c95d..c5b166d36 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -3941,10 +3941,23 @@ static void K_drawBattleFullscreen(void) INT32 x = BASEVIDWIDTH/2; INT32 y = (-64*FRACUNIT) + cardanim; // card animation goes from 0 to 164, 164 is the middle of the screen - INT32 splitflags = V_SNAPTOTOP; // I don't feel like properly supporting non-green resolutions, so you can have a misuse of SNAPTO instead + INT32 splitflags = splitscreen ? V_SNAPTOTOP : 0; // I don't feel like properly supporting non-green resolutions, so you can have a misuse of SNAPTO instead fixed_t scale = FRACUNIT; boolean drawcomebacktimer = true; // lazy hack because it's cleaner in the long run. + // Small hack, if we're not in splitscreen we will not use V_SNAPTOTOP, instead we will just slightly offset + // y position so "attack or protect" doesn't slightly show before popping in + // We will also reduce this when is closer to finishing so when its at the bottom, the "hack offset" is 0 + if (!splitscreen) + { + fixed_t offset = ((vid.height - vid.dup*BASEVIDHEIGHT)/vid.dup) * FRACUNIT/2; + + // cardanim goes from 0 to 164, so when it is 164 offset will be multiplied by (1 - 164/164) = 0 :3 + offset = FixedMul(offset, FRACUNIT - FixedDiv(cardanim, 164*FRACUNIT)); + + y -= offset; + } + if (!LUA_HudEnabled(hud_battlecomebacktimer)) drawcomebacktimer = false; @@ -4032,12 +4045,12 @@ static void K_drawBattleFullscreen(void) if (K_UseColorHud()) // Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawFixedPatch(x<kartstuff[k_comebacktimer]/TICRATE)); + V_DrawKartString(x-txoff, ty, splitflags, va("%d", stplyr->kartstuff[k_comebacktimer]/TICRATE)); } } From 3fa8ab442af4b03f7df5587f6dd801796332e377 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jul 2026 18:27:39 +0200 Subject: [PATCH 477/589] print warning if whitespaces are encountered in musicdef fields technically that is a non issue for saturn but vanilla will completely explode from this --- src/s_sound.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 050b2c932..8df386aa7 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1297,9 +1297,7 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde if (!value) { - CONS_Alert(CONS_WARNING, - "MUSICDEF: Field '%s' is missing name. (file %s, line %d)\n", - stoken, wadfiles[wadnum]->filename, line); + CONS_Alert(CONS_WARNING, "MUSICDEF: Field '%s' is missing name. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); (void)strtok(NULL, " "); return true; } @@ -1332,9 +1330,7 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde if (!value) { - CONS_Alert(CONS_WARNING, - "MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n", - stoken, wadfiles[wadnum]->filename, line); + CONS_Alert(CONS_WARNING, "MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); (void)strtok(NULL, " "); return true; } @@ -1344,9 +1340,7 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde if (!def) { - CONS_Alert(CONS_ERROR, - "MUSICDEF: No music definition before field '%s'. (file %s, line %d)\n", - stoken, wadfiles[wadnum]->filename, line); + CONS_Alert(CONS_ERROR, "MUSICDEF: No music definition before field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); return false; } @@ -1360,9 +1354,11 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde // turn _ into spaces. #define ADDDEF(field)\ + int err = 0;\ STRBUFCPY(def->field, textline);\ for (textline = def->field; *textline; textline++)\ - if (*textline == '_') *textline = ' '; + if (err == 0 && *textline == ' ') {err = 1; CONS_Alert(CONS_WARNING, "MUSICDEF: Erroneous whitespace detected in field '%s': '%s'.\n(file %s, line %d) Musicdef might not work correctly!\n", stoken, def->field, wadfiles[wadnum]->filename, line);}\ + if (*textline == '_') *textline = ' '; if (fasticmp(stoken, "usage")) { From 59b7b0529f20376144097a63859b1c3c408ddae7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jul 2026 19:00:39 +0200 Subject: [PATCH 478/589] add warning if theres no music lump for musicdef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if theyre left over or typo´d (which prevents them from showing up) --- src/s_sound.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/s_sound.c b/src/s_sound.c index 8df386aa7..6bdc18381 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1303,6 +1303,13 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde } else { + if (!S_MusicExists(value, false, true)) // && !S_MusicExists(value, true, false) idk if we wanna check for midi? + { + CONS_Alert(CONS_WARNING, "MUSICDEF: No music found for lump %s. (file %s, line %d)\n", value, wadfiles[wadnum]->filename, line); + //(void)strtok(NULL, " "); if we skip this the rest of the musicdef will also be skipped, even if we return true here :chaosleep: + //return true; + } + def = S_FindMusicCredit(value); // Nothing found, add to the end. From 05e8771fbcd5fde4548b506202224ec67d4a41bd Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 3 Jul 2026 19:08:36 +0200 Subject: [PATCH 479/589] Revert "add warning if theres no music lump for musicdef" This reverts commit 59b7b0529f20376144097a63859b1c3c408ddae7. very fun if the music lumps were split into some other file! --- src/s_sound.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 6bdc18381..8df386aa7 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1303,13 +1303,6 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde } else { - if (!S_MusicExists(value, false, true)) // && !S_MusicExists(value, true, false) idk if we wanna check for midi? - { - CONS_Alert(CONS_WARNING, "MUSICDEF: No music found for lump %s. (file %s, line %d)\n", value, wadfiles[wadnum]->filename, line); - //(void)strtok(NULL, " "); if we skip this the rest of the musicdef will also be skipped, even if we return true here :chaosleep: - //return true; - } - def = S_FindMusicCredit(value); // Nothing found, add to the end. From ba5c85ba8a2b17f863c01d42aa1d0a79e1c2f3dc Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jul 2026 06:20:59 +0200 Subject: [PATCH 480/589] :chaosleep: --- src/s_sound.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 8df386aa7..0a81764c7 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1356,9 +1356,10 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde #define ADDDEF(field)\ int err = 0;\ STRBUFCPY(def->field, textline);\ - for (textline = def->field; *textline; textline++)\ + for (textline = def->field; *textline; textline++) {\ if (err == 0 && *textline == ' ') {err = 1; CONS_Alert(CONS_WARNING, "MUSICDEF: Erroneous whitespace detected in field '%s': '%s'.\n(file %s, line %d) Musicdef might not work correctly!\n", stoken, def->field, wadfiles[wadnum]->filename, line);}\ - if (*textline == '_') *textline = ' '; + if (*textline == '_') *textline = ' ';\ + } if (fasticmp(stoken, "usage")) { From 7b91666db9835400beebce0b0bf8cb8e46229970 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 4 Jul 2026 20:09:30 +0200 Subject: [PATCH 481/589] clean up some frameflags stuff mfw no FF_VERTICALFLIP --- src/hardware/hw_main.cpp | 21 ++++++++++----------- src/hardware/hw_md2.c | 5 ++++- src/r_main.cpp | 2 +- src/r_things.cpp | 34 ++++++++++++++++++++++++++++++---- src/r_things.h | 5 +++++ 5 files changed, 50 insertions(+), 17 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index c01c59afc..9be30db07 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3702,7 +3702,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; } - HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(sprmo->frame & FF_FULLBRIGHT)); + HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !R_ThingIsFullBright(sprmo)); Surf.PolyColor.s.alpha = alpha; @@ -3756,7 +3756,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) if (!sprmo->subsector) return; - const boolean papersprite = (sprmo->frame & FF_PAPERSPRITE); + const boolean papersprite = R_ThingIsPaperSprite(sprmo); const sector_t *sector = sprmo->subsector->sector; if (sector->numlights) @@ -3915,7 +3915,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) INT32 shader = SHADER_NONE; - const precipmobj_t *sprmo = spr->precip; + precipmobj_t *sprmo = spr->precip; if (!sprmo->subsector) return; @@ -3961,11 +3961,10 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) if (sector->numlights) { - INT32 light; + // Always use the light at the top instead of whatever I was doing before + INT32 light = R_GetPlaneLight(sector, sprmo->z, false); // sprmo->z + sprmo->height - light = R_GetPlaneLight(sector, sprmo->z, false); // Always use the light at the top instead of whatever I was doing before - - if (!(sprmo->frame & FF_FULLBRIGHT)) + if (!R_PrecipThingIsFullBright(sprmo)) lightlevel = static_cast(*sector->lightlist[light].lightlevel); if (sector->lightlist[light].extra_colormap) @@ -3973,7 +3972,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) } else { - if (!(sprmo->frame & FF_FULLBRIGHT)) + if (!R_PrecipThingIsFullBright(sprmo)) lightlevel = static_cast(sector->lightlevel); if (sector->extra_colormap) @@ -4557,7 +4556,7 @@ static void HWR_ProjectSprite(mobj_t *thing) return; } - const boolean papersprite = (thing->frame & FF_PAPERSPRITE); + const boolean papersprite = R_ThingIsPaperSprite(thing); // transform the origin point tr_x = FixedToFloat(interp.x); @@ -4571,8 +4570,8 @@ static void HWR_ProjectSprite(mobj_t *thing) return; const boolean mirrored = thing->mirrored; - const boolean vflip = (thing->eflags & MFE_VERTICALFLIP); - const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); + const boolean vflip = R_ThingVerticallyFlipped(thing); + const boolean hflip = (!R_ThingHorizontallyFlipped(thing) != !mirrored); // decide which patch to use for sprite relative to player #ifdef RANGECHECK diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 4cb8a0a51..0f8328041 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1153,8 +1153,11 @@ void HWR_DrawMD2(gl_vissprite_t *spr) INT32 durs = spr->mobj->state->tics; INT32 tics = spr->mobj->tics; //mdlframe_t *next = NULL; + + //const UINT8 flip = (UINT8)(!(spr->mobj->eflags & MFE_VERTICALFLIP) != !R_ThingVerticallyFlipped(spr->mobj)); // :chaosleep: const UINT8 flip = (UINT8)((spr->mobj->eflags & MFE_VERTICALFLIP) == MFE_VERTICALFLIP); - const UINT8 hflip = (UINT8)(!(spr->mobj->mirrored) != !(spr->mobj->frame & FF_HORIZONTALFLIP)); + const UINT8 hflip = (UINT8)(!(spr->mobj->mirrored) != !R_ThingHorizontallyFlipped(spr->mobj)); + spritedef_t *sprdef; spriteframe_t *sprframe; spriteinfo_t *sprinfo; diff --git a/src/r_main.cpp b/src/r_main.cpp index 038fa8a6a..d2b6eed65 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -411,7 +411,7 @@ angle_t R_PlayerSliptideAngle(player_t *player) if (!sprframe) return 0; - if (sprframe->rotate != SRF_SINGLE || (mo->frame & FF_PAPERSPRITE)) + if (sprframe->rotate != SRF_SINGLE || R_ThingIsPaperSprite(mo)) ang = R_PointToAngle(mo->x, mo->y) - mo->angle; return FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mo->player->sliproll * mo->player->kartstuff[k_aizdriftstrat]); diff --git a/src/r_things.cpp b/src/r_things.cpp index bc01c4cc8..4d9f2e738 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1241,9 +1241,9 @@ static void R_ProjectSprite(mobj_t *thing) return; const boolean mirrored = thing->mirrored; - const boolean vflip = (thing->eflags & MFE_VERTICALFLIP); - const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); - const boolean papersprite = (thing->frame & FF_PAPERSPRITE); + const boolean vflip = R_ThingVerticallyFlipped(thing); + const boolean hflip = (!R_ThingHorizontallyFlipped(thing) != !mirrored); + const boolean papersprite = R_ThingIsPaperSprite(thing); // transform the origin point tr_x = interp.x - viewx; @@ -3022,11 +3022,37 @@ boolean R_CheckMobjInterpDist(mobj_t *thing) return R_CheckInterpDist(thing); } -boolean R_ThingIsFullBright(mobj_t *thing) +boolean R_ThingHorizontallyFlipped(mobj_t *thing) +{ + return (thing->frame & FF_HORIZONTALFLIP); +} + +boolean R_ThingVerticallyFlipped(mobj_t *thing) +{ + return (thing->eflags & MFE_VERTICALFLIP); //(thing->frame & FF_VERTICALFLIP); +} + +boolean R_ThingIsPaperSprite(mobj_t *thing) +{ + return (thing->frame & FF_PAPERSPRITE); +} + +template +boolean R_ThingIsFullBrightT(T *thing) { return ((thing->frame & FF_BRIGHTMASK) == FF_FULLBRIGHT); } +boolean R_PrecipThingIsFullBright(precipmobj_t *thing) +{ + return R_ThingIsFullBrightT(thing); +} + +boolean R_ThingIsFullBright(mobj_t *thing) +{ + return R_ThingIsFullBrightT(thing); +} + boolean R_ThingIsSemiBright(mobj_t *thing) { return ((thing->frame & FF_BRIGHTMASK) == FF_SEMIBRIGHT); diff --git a/src/r_things.h b/src/r_things.h index e8e30ca6b..bde0ad592 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -88,6 +88,11 @@ boolean R_CheckPrecipMobjInterpDist(precipmobj_t *thing); boolean R_CheckMobjInterpDist(mobj_t *thing); fixed_t R_DoPlayerFade(mobj_t *thing); +boolean R_ThingHorizontallyFlipped(mobj_t *thing); +boolean R_ThingVerticallyFlipped(mobj_t *thing); +boolean R_ThingIsPaperSprite(mobj_t *thing); + +boolean R_PrecipThingIsFullBright(precipmobj_t *thing); boolean R_ThingIsFullBright(mobj_t *thing); boolean R_ThingIsSemiBright(mobj_t *thing); boolean R_ThingIsFullDark(mobj_t *thing); From be08c9cd1f31caac647909d35e6697f77ba30b27 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jul 2026 21:36:48 +0200 Subject: [PATCH 482/589] changes to some saturn specific visual effects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit most of those were added cause they´re cool to look at, but without much thought about potentially giving players that enable such features an "unfair" advantage over others. - eggboxes wont be rotated while stationary and on the ground anymore (they are meant to deceive players, being rotated makes them stand out alot!) - players that are about to explode due to eggboxes wont spawn extra red speedlines anymore - option to show driftlevel per speedlines has been removed --- src/k_kart.c | 78 ++++++++++++---------------------------------------- src/p_mobj.c | 8 +++++- 2 files changed, 24 insertions(+), 62 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 39961c1a9..4120311bc 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -34,7 +34,7 @@ // extra colourisation stuff -static CV_PossibleValue_t colorspeedlines_cons_t[] = {{0, "Off"}, {1, "Normal"}, {2, "+Driftcharge"}, {3, "Drift only"}, {0, NULL}}; +static CV_PossibleValue_t colorspeedlines_cons_t[] = {{0, "Off"}, {1, "On"}, {0, NULL}}; consvar_t cv_coloredspeedlines = {"colorizedspeedlines", "Off", CV_SAVE, colorspeedlines_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_coloredsneakertrail = {"sneakertrailcolor", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -3526,13 +3526,14 @@ static INT32 K_StairJankFlip(INT32 value) // if not cv_bananthrowroll option "+Onground" static void K_ResetBananaRollangle(mobj_t* mo) { - if (cv_bananthrowroll.value != 1) - return; - if (!mo->rollangle) return; - if (mo->type != MT_BANANA && mo->type != MT_EGGMANITEM) + if (mo->type != MT_BANANA && mo->type != MT_EGGMANITEM) // always reset eggboxes + return; + + // keep banans "rotated" if we want them to + if (mo->type == MT_BANANA && cv_bananthrowroll.value == 2) return; // only reset if on ground @@ -5485,59 +5486,15 @@ boolean K_PlayerEffectsShouldBlend(player_t *player) return false; } -static UINT8 K_GetSpeedLineColor(player_t *player, boolean colorSpeed) +FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player) { - UINT8 speedcolor = SKINCOLOR_NONE; - const UINT8 playercolor = player->mo->color; - - if (colorSpeed) - { - if (cv_coloredspeedlines.value != 3) - speedcolor = playercolor; - - if (cv_coloredspeedlines.value >= 2 && player->kartstuff[k_driftboost]) - { - if (player->kartstuff[k_driftboost] <= 20) - speedcolor = SKINCOLOR_SAPPHIRE; - else if (player->kartstuff[k_driftboost] <= 50) - speedcolor = SKINCOLOR_RASPBERRY; - else if (player->kartstuff[k_driftboost] <= 125) - speedcolor = K_RainbowColor(); - - if (cv_coloredspeedlines.value == 2) - speedcolor = (leveltime & 1) ? playercolor : speedcolor; - } - } - - if (cv_coloredspeedlines.value != 3) - { - if (player->kartstuff[k_eggmanexplode]) - { - // Make it red when you have the eggman speed boost - speedcolor = SKINCOLOR_RED; - } - else if (player->kartstuff[k_invincibilitytimer]) - { - speedcolor = playercolor; - } - } - - return speedcolor; -} - -typedef INT32 (*randomFunc)(INT32 min, INT32 max); - -FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, boolean synched) -{ - const randomFunc randomfunc = synched ? P_RandomRange : M_RandomRange; - fixed_t rand_x; fixed_t rand_y; fixed_t rand_z; - rand_z = player->mo->z + (player->mo->height/2) + (randomfunc(-20,20) * player->mo->scale); - rand_y = player->mo->y + (randomfunc(-36,36) * player->mo->scale); - rand_x = player->mo->x + (randomfunc(-36,36) * player->mo->scale); + rand_z = player->mo->z + (player->mo->height/2) + (P_RandomRange(-20,20) * player->mo->scale); + rand_y = player->mo->y + (P_RandomRange(-36,36) * player->mo->scale); + rand_x = player->mo->x + (P_RandomRange(-36,36) * player->mo->scale); mobj_t *fast = P_SpawnMobj(rand_x, rand_y, rand_z, MT_FASTLINE); @@ -5545,7 +5502,7 @@ FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, bool fast->momx = 3*player->mo->momx/4; fast->momy = 3*player->mo->momy/4; fast->momz = 3*player->mo->momz/4; - fast->islocal = !synched; + //fast->islocal = false; P_SetTarget(&fast->target, player->mo); // easier lua access K_MatchGenericExtraFlags(fast, player->mo); @@ -5556,8 +5513,11 @@ FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, bool if (cv_coloredspeedlines.value) { - fast->color = K_GetSpeedLineColor(player, colorSpeed); - fast->colorized = true; + if (colorSpeed || player->kartstuff[k_invincibilitytimer]) // let invul color them even when players go rather slow + { + fast->color = player->mo->color; + fast->colorized = true; + } } if (colorSpeed && K_PlayerEffectsShouldBlend(player)) @@ -5586,11 +5546,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) // Speed lines if ((player->kartstuff[k_sneakertimer] || player->kartstuff[k_driftboost] || player->kartstuff[k_startboost]) && player->speed > 0) { - K_SpawnNormalSpeedLines(player, true); - } - else if ((cv_coloredspeedlines.value == 1 || cv_coloredspeedlines.value == 2) && player->kartstuff[k_eggmanexplode]) // gotta love the speedlines calling synched rng :chaosleep: - { - K_SpawnNormalSpeedLines(player, false); + K_SpawnNormalSpeedLines(player); } if (player->playerstate == PST_DEAD || player->kartstuff[k_respawn] > 1) // Ensure these are set correctly here diff --git a/src/p_mobj.c b/src/p_mobj.c index 02e1e1bc6..14ba3a93d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7184,6 +7184,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) { boolean grounded = P_IsObjectOnGround(mobj); + // rotate thrown eggboxes and bananas mid air! if (cv_bananthrowroll.value && !grounded) { // tilt n tumble @@ -7204,7 +7205,12 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->health = 1; } - P_RollPitchMobj(mobj); + // do not rotate eggman items on slopes + // they are meant to deceive the player + // having them rotated makes them stand out a lot more + // since random items do not roll´n pitch on slopes! + if (mobj->type == MT_BANANA) + P_RollPitchMobj(mobj); if (mobj->threshold > 0) mobj->threshold--; From 2302d4efbd1ef975ce0dd74dcedaad404ada742e Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jul 2026 21:36:11 +0200 Subject: [PATCH 483/589] mark R_ThingIsFullBrightT as static --- src/i_tcp.c | 1 + src/r_things.cpp | 2 +- src/sdl/i_video.c | 3 +++ src/v_video.c | 4 ++-- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index f7f4a3210..4eab1efbc 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1694,6 +1694,7 @@ boolean I_InitTcpNetwork(void) hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; } } + if (M_CheckProtoParam("ip")) { COM_ImmedExecute(va("exec \"%s"PATHSEP"kartexec.cfg\" -noerror\n", srb2home)); diff --git a/src/r_things.cpp b/src/r_things.cpp index 4d9f2e738..ee517c11f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -3038,7 +3038,7 @@ boolean R_ThingIsPaperSprite(mobj_t *thing) } template -boolean R_ThingIsFullBrightT(T *thing) +static boolean R_ThingIsFullBrightT(T *thing) { return ((thing->frame & FF_BRIGHTMASK) == FF_FULLBRIGHT); } diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c736330ad..c6554c2b9 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1816,15 +1816,18 @@ void I_StartupGraphics(void) framebuffer = SDL_TRUE; } + // Choose Software renderer if (M_CheckParm("-software")) rendermode = render_soft; #ifdef HWRENDER + // Choose OpenGL renderer else if (M_CheckParm("-opengl")) rendermode = render_opengl; msaa = 0; boolean msaa_set = false; a2c = false; boolean a2c_set = false; + // MSAA antialiasing if (M_CheckParm("-msaa") && M_IsNextParm()) { const char* str = M_GetNextParm(); diff --git a/src/v_video.c b/src/v_video.c index 2ac659ba6..fc84a0cdc 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -1563,8 +1563,8 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) { // mpc 12-04-2018 const UINT8 *fadetable = ((UINT8 *)transtables + ((alphalevel-1)<y) ? y : x - w = clip(w,vid.width); - h = clip(h,vid.height); + w = clip(w, vid.width); + h = clip(h, vid.height); #undef clip for (v = 0; v < h; v++, dest += vid.width) { From 2ae1e0f56ef4718df52c6fd8ab7b129335bacb76 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jul 2026 22:25:33 +0200 Subject: [PATCH 484/589] only rumble controllers for local players also not in replays --- src/g_input.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/g_input.c b/src/g_input.c index fa18272b8..c317e164d 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1059,7 +1059,7 @@ void G_DeviceRumbleTick(void) { UINT8 i; - if (dedicated || numcontrollers == 0 || gamestate != GS_LEVEL) + if (dedicated || numcontrollers == 0 || gamestate != GS_LEVEL || demo.playback) { return; } @@ -1096,6 +1096,12 @@ void G_DeviceRumbleTick(void) continue; } + // only rumble for local players! + if (!P_IsLocalPlayer(player)) + { + continue; + } + // reset the rumble if you exit or are ded lel if (player->exiting || player->playerstate == PST_DEAD || From 3ad6159e85a50f0ec8c4199803f78d93a81b3c6a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 5 Jul 2026 22:51:04 +0200 Subject: [PATCH 485/589] make controller rumble types toggable separately needs a proper menu, but too lazy for that currently --- src/d_netcmd.c | 12 +++++++++-- src/g_input.c | 55 +++++++++++++++++++++++++++++++++++------------- src/g_input.h | 20 +++++++++++++----- src/k_kart.c | 6 +++--- src/m_menudefs.c | 8 ++++--- 5 files changed, 73 insertions(+), 28 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index fd08830f0..4e217946e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1008,9 +1008,17 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_usejoystick[i]); CV_RegisterVar(&cv_joyscale[i]); - CV_RegisterVar(&cv_rumble[i]); - CV_RegisterVar(&cv_rumblestrength[i]); CV_RegisterVar(&cv_gamepadled[i]); + + CV_RegisterVar(&cv_rumble[i]); + CV_RegisterVar(&cv_rumble_strength[i]); + CV_RegisterVar(&cv_rumble_spinout[i]); + CV_RegisterVar(&cv_rumble_sneakerboost[i]); + CV_RegisterVar(&cv_rumble_offroad[i]); + CV_RegisterVar(&cv_rumble_bananadrag[i]); + CV_RegisterVar(&cv_rumble_stairjank[i]); + CV_RegisterVar(&cv_rumble_brakedrift[i]); + CV_RegisterVar(&cv_rumble_driftcharge[i]); } CV_RegisterVar(&cv_gamepadifunfocused); diff --git a/src/g_input.c b/src/g_input.c index c317e164d..438f70b09 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -66,13 +66,30 @@ consvar_t cv_rumble[MAXSPLITSCREENPLAYERS] = { static CV_PossibleValue_t rumblestrength_cons_t[] = {{FRACUNIT/4, "MIN"}, {FRACUNIT*4, "MAX"}, {0, NULL}}; -consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS] = { +consvar_t cv_rumble_strength[MAXSPLITSCREENPLAYERS] = { {"rumblestrength", "1.0", CV_SAVE|CV_FLOAT, rumblestrength_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"rumblestrength2", "1.0", CV_SAVE|CV_FLOAT, rumblestrength_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"rumblestrength3", "1.0", CV_SAVE|CV_FLOAT, rumblestrength_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"rumblestrength4", "1.0", CV_SAVE|CV_FLOAT, rumblestrength_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; +#define IMPL_RUMBLE_TYPE(type)\ +consvar_t cv_rumble_##type [MAXSPLITSCREENPLAYERS] = {\ + {"rumble_" #type, "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},\ + {"rumble2_" #type, "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},\ + {"rumble3_" #type, "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},\ + {"rumble4_" #type, "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}\ +}; + +IMPL_RUMBLE_TYPE(spinout); +IMPL_RUMBLE_TYPE(sneakerboost); +IMPL_RUMBLE_TYPE(offroad); +IMPL_RUMBLE_TYPE(bananadrag); +IMPL_RUMBLE_TYPE(stairjank); +IMPL_RUMBLE_TYPE(brakedrift); +IMPL_RUMBLE_TYPE(driftcharge); + + static CV_PossibleValue_t gamepadled_cons_t[] = {{0, "Off"}, {1, "Skincolor"}, {2, "Mobjcolor"}, {0, NULL}}; consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = { {"gamepadled", "Skincolor", CV_SAVE|CV_CALL|CV_NOINIT, gamepadled_cons_t, led_off_handle, 0, NULL, NULL, 0, 0, NULL}, @@ -1036,8 +1053,8 @@ void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_stre // doesent need to be super precise // but ensure this is within range (0-65535) // placed here so it applies to lua aswell - low_strength = (UINT16)min(FixedMul(low_strength, cv_rumblestrength[playernum].value), UINT16_MAX); - high_strength = (UINT16)min(FixedMul(high_strength, cv_rumblestrength[playernum].value), UINT16_MAX); + low_strength = (UINT16)min(FixedMul(low_strength, cv_rumble_strength[playernum].value), UINT16_MAX); + high_strength = (UINT16)min(FixedMul(high_strength, cv_rumble_strength[playernum].value), UINT16_MAX); I_GamepadRumble(playernum, low_strength, high_strength, duration); } @@ -1111,17 +1128,20 @@ void G_DeviceRumbleTick(void) continue; } - if (player->kartstuff[k_spinouttimer]) + if (cv_rumble_spinout[i].value + && player->kartstuff[k_spinouttimer]) { //low = high = FRACUNIT / 6; low = high = FixedMul((RUMBLE_VERYSTRONG), (FixedDiv(player->kartstuff[k_spinouttimer], (3*TICRATE / 2)))); // try do some some kinda fadeout, 3*TICRATE / 2 is the "default" spinout time } - else if (player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2))) + else if (cv_rumble_sneakerboost[i].value + && (player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2)))) { low = high = RUMBLE_STRONG; } - else if ((player->kartstuff[k_offroad]) - && player->speed != 0 + else if (cv_rumble_offroad[i].value + && (player->kartstuff[k_offroad]) + && (player->speed != 0) && P_IsObjectOnGround(player->mo)) { // weaken this depending on if you got hyu or invinc @@ -1138,32 +1158,37 @@ void G_DeviceRumbleTick(void) low = high = RUMBLE_MODERATE; } } - else if ((player->kartstuff[k_bananadrag] > TICRATE) - && player->speed != 0 + else if (cv_rumble_bananadrag[i].value + && (player->kartstuff[k_bananadrag] > TICRATE) + && (player->speed != 0) && P_IsObjectOnGround(player->mo)) { if (leveltime & 1) // this is actually funny lel high = RUMBLE_MODERATE; } - /*else if ((player->stairjank > 8) // this is kinda cool but prob gets annoying after a while - && player->speed != 0 + else if (cv_rumble_stairjank[i].value + && (player->stairjank > 8) + && (player->speed != 0) && P_IsObjectOnGround(player->mo)) { - low = high = RUMBLE_WEAK; - }*/ + low = high = RUMBLE_VERYWEAK; + } - if (player->kartstuff[k_brakedrift]) + if (cv_rumble_brakedrift[i].value + && player->kartstuff[k_brakedrift]) { high = CLAMP((high + RUMBLE_VERYWEAK), 0, UINT16_MAX); } // pulse when gettin new driftlevel // let this come last - if (player->kartstuff[k_driftcharge] + if (cv_rumble_driftcharge[i].value + && player->kartstuff[k_driftcharge] && player->driftlevel) { high = CLAMP((high + RUMBLE_VERYWEAK), 0, UINT16_MAX); + // make it rumble slightly longer the higher your driftlevel! if (player->driftlevel == 2) lenght = 114; else if (player->driftlevel == 3) diff --git a/src/g_input.h b/src/g_input.h index 1cf4b2956..bed5beb0e 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -100,9 +100,10 @@ typedef enum gc_custom2, // Lua scriptable gc_custom3, // Lua scriptable gc_director, - gc_freecam, // Toggle for freecam while ingame - gc_camfloat, // alternative button for raising cam - gc_camsink, // alternative button for sinking + // freecam specific controls + gc_freecam, // Toggle for freecam while ingame + gc_camfloat, // alternative button for raising camera + gc_camsink, // alternative button for sinking camera gc_strafeleft, gc_straferight, num_gamecontrols @@ -112,10 +113,19 @@ typedef enum extern consvar_t cv_mousexsens, cv_mouseysens; extern consvar_t cv_controlperkey; extern consvar_t cv_turnsmooth[MAXSPLITSCREENPLAYERS]; -extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS]; -extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS]; + extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_rumble_strength[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_rumble_spinout[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_rumble_sneakerboost[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_rumble_offroad[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_rumble_bananadrag[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_rumble_stairjank[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_rumble_brakedrift[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_rumble_driftcharge[MAXSPLITSCREENPLAYERS]; + extern consvar_t cv_gamepadifunfocused; extern consvar_t cv_gamepadledifunfocused; extern consvar_t cv_rumbleifunfocused; diff --git a/src/k_kart.c b/src/k_kart.c index 4120311bc..44aa70377 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5492,9 +5492,9 @@ FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player) fixed_t rand_y; fixed_t rand_z; - rand_z = player->mo->z + (player->mo->height/2) + (P_RandomRange(-20,20) * player->mo->scale); - rand_y = player->mo->y + (P_RandomRange(-36,36) * player->mo->scale); - rand_x = player->mo->x + (P_RandomRange(-36,36) * player->mo->scale); + rand_z = player->mo->z + (player->mo->height/2) + (P_RandomRange(-20, 20) * player->mo->scale); + rand_y = player->mo->y + (P_RandomRange(-36, 36) * player->mo->scale); + rand_x = player->mo->x + (P_RandomRange(-36, 36) * player->mo->scale); mobj_t *fast = P_SpawnMobj(rand_x, rand_y, rand_z, MT_FASTLINE); diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 4da3c7ea7..77cf9a030 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -745,9 +745,11 @@ static const char* OP_AllControlsTooltips[sizeof(OP_AllControlsMenu)/sizeof(OP_A {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[pnum] , 100}, \ {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[pnum] , 105}, \ {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, \ - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[pnum] , 120}, \ - {IT_STRING | IT_CVAR, NULL, "Controller Rumble Strength" , &cv_rumblestrength[pnum] , 125}, \ - {IT_STRING | IT_CVAR, NULL, "Set LED to Player color" , &cv_gamepadled[pnum] , 130}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[pnum] , 120}, \ + {IT_STRING | IT_CVAR, NULL, "Controller Rumble Strength" , &cv_rumble_strength[pnum] , 125}, \ + {IT_STRING | IT_CVAR, NULL, "Set LED to Player color" , &cv_gamepadled[pnum] , 130}, + +//TODO: add menu for controller rumble stuff static menuitem_t OP_Joystick1Menu[] = { From ec70e8aa298d34b25ed3df8a4c68c8fe62ffd9db Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 6 Jul 2026 04:56:45 +0200 Subject: [PATCH 486/589] only apply LUA controller rumble and led color to local players what my dumb ass was meaning to do with 2ae1e0f56ef4718df52c6fd8ab7b129335bacb76 displayplayer[0] does not necessarily map to a local player! --- src/g_input.c | 7 +++---- src/lua_baselib.c | 38 ++++++++++++-------------------------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/g_input.c b/src/g_input.c index 438f70b09..c4dfece9d 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1107,14 +1107,13 @@ void G_DeviceRumbleTick(void) const player_t *player = P_GetLocalPlayerForNum(i); - // allow lua to do some crap for spectators - if (player->spectator || !player->mo) + if (!player) { continue; } - // only rumble for local players! - if (!P_IsLocalPlayer(player)) + // allow lua to do some crap for spectators + if (player->spectator || !player->mo) { continue; } diff --git a/src/lua_baselib.c b/src/lua_baselib.c index bc94e2949..d24b88c51 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3055,58 +3055,44 @@ static int lib_kSetHyuCountdown(lua_State *L) static int lib_gSetPlayerGamepadIndicatorColor(lua_State *L) { - INT32 player = -1; - player_t *plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player + INT32 pnum = -1; + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player UINT8 color = (UINT8)luaL_checkinteger(L, 2); // skincolor - if (!plr) + if (!player) return LUA_ErrInvalid(L, "player_t"); if (color >= MAXTRANSLATIONS) return luaL_error(L, "color %d out of range (0 - %d).", color, MAXTRANSLATIONS-1); - for (int i = 0; i < MAXSPLITSCREENPLAYERS; ++i) - { - if (plr - players == displayplayers[i]) - { - player = i; - break; - } - } + pnum = P_GetLocalPlayerNumForPlayer(player); // Not a local player - if (player == -1) return 0; + if (pnum == -1) return 0; // pls update with color 0 when youre done with changing led stuff so it can get player color again - G_SetPlayerGamepadIndicatorColor(player, color); + G_SetPlayerGamepadIndicatorColor(pnum, color); return 0; } static int lib_gPlayerDeviceRumble(lua_State *L) { - INT32 player = -1; - player_t *plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player + INT32 pnum = -1; + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); // retrieve player UINT16 low_strength = (UINT16)luaL_checkinteger(L, 2); // low frequency rumble motor strenght UINT16 high_strength = (UINT16)luaL_checkinteger(L, 3); // high frequency rumble motor strenght UINT32 duration = (UINT32)luaL_optinteger(L, 4, 84); // duration of rumble in ms - if (!plr) + if (!player) return LUA_ErrInvalid(L, "player_t"); - for (int i = 0; i < MAXSPLITSCREENPLAYERS; ++i) - { - if (plr - players == displayplayers[i]) - { - player = i; - break; - } - } + pnum = P_GetLocalPlayerNumForPlayer(player); // Not a local player - if (player == -1) return 0; + if (pnum == -1) return 0; - G_PlayerDeviceRumble(player, low_strength, high_strength, duration); + G_PlayerDeviceRumble(pnum, low_strength, high_strength, duration); return 0; } From c374bd75fcbf6adc8bf0e3b617a76cde38f7d5f0 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 7 Jul 2026 13:09:57 +0200 Subject: [PATCH 487/589] menu for controller rumble stuff --- src/m_menudefs.c | 61 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 77cf9a030..23557b8c4 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -36,6 +36,7 @@ static menu_t SP_TimeAttackDef, SP_ReplayDef, SP_GuestReplayDef, SP_GhostDef; menu_t OP_ControlsDef, OP_AllControlsDef; menu_t OP_MouseOptionsDef; menu_t OP_Joystick1Def, OP_Joystick2Def, OP_Joystick3Def, OP_Joystick4Def; +menu_t OP_Joystick1RumbleDef, OP_Joystick2RumbleDef, OP_Joystick3RumbleDef, OP_Joystick4RumbleDef; // Custom cvar menu menu_t OP_CustomCvarMenuDef; @@ -725,6 +726,14 @@ static const char* OP_AllControlsTooltips[sizeof(OP_AllControlsMenu)/sizeof(OP_A // The rest is null, for now }; +// i really do not feel like messing with setup routines +// and macro preprocessor cannot eval maths for string shit like this :chaosleep: +#define RUMBDEF_0 OP_Joystick1RumbleDef +#define RUMBDEF_1 OP_Joystick2RumbleDef +#define RUMBDEF_2 OP_Joystick3RumbleDef +#define RUMBDEF_3 OP_Joystick4RumbleDef +#define RUMBDEF(x) RUMBDEF_##x + #define OP_JOYMENU(pnum) \ {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, \ {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[pnum] , 15}, \ @@ -745,11 +754,8 @@ static const char* OP_AllControlsTooltips[sizeof(OP_AllControlsMenu)/sizeof(OP_A {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[pnum] , 100}, \ {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[pnum] , 105}, \ {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, \ - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[pnum] , 120}, \ - {IT_STRING | IT_CVAR, NULL, "Controller Rumble Strength" , &cv_rumble_strength[pnum] , 125}, \ - {IT_STRING | IT_CVAR, NULL, "Set LED to Player color" , &cv_gamepadled[pnum] , 130}, - -//TODO: add menu for controller rumble stuff + {IT_SUBMENU|IT_STRING, NULL, "Rumble Options..." , &RUMBDEF(pnum) , 120}, \ + {IT_STRING | IT_CVAR, NULL, "Set LED to Player color" , &cv_gamepadled[pnum] , 125}, static menuitem_t OP_Joystick1Menu[] = { @@ -775,6 +781,46 @@ static menuitem_t OP_Joystick4Menu[] = OP_JOYMENU(3) }; +#undef RUMBDEF +#undef RUMBDEF_0 +#undef RUMBDEF_1 +#undef RUMBDEF_2 +#undef RUMBDEF_3 + +// FIXME: stair jank rumble should be greyed out if its disabled, but menus suck butt! +#define OP_JOYRUMBLEMENU(pnum) \ + {IT_HEADER, NULL, "Global", NULL, 7}, \ + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[pnum] , 15}, \ + {IT_STRING | IT_CVAR, NULL, "Controller Rumble Strength" , &cv_rumble_strength[pnum] , 20}, \ + {IT_HEADER, NULL, "Rumble Types", NULL, 27}, \ + {IT_STRING | IT_CVAR, NULL, "Spinout" , &cv_rumble_spinout[pnum] , 35}, \ + {IT_STRING | IT_CVAR, NULL, "Sneaker Boost" , &cv_rumble_sneakerboost[pnum] , 40}, \ + {IT_STRING | IT_CVAR, NULL, "Offroad" , &cv_rumble_offroad[pnum] , 45}, \ + {IT_STRING | IT_CVAR, NULL, "Banana Dragging" , &cv_rumble_bananadrag[pnum] , 50}, \ + {IT_STRING | IT_CVAR, NULL, "Stair Jank" , &cv_rumble_stairjank[pnum] , 55}, \ + {IT_STRING | IT_CVAR, NULL, "Brake Drift" , &cv_rumble_brakedrift[pnum] , 60}, \ + {IT_STRING | IT_CVAR, NULL, "Drift Charge" , &cv_rumble_driftcharge[pnum] , 65}, \ + +static menuitem_t OP_Joystick1RumbleMenu[] = +{ + OP_JOYRUMBLEMENU(0) +}; + +static menuitem_t OP_Joystick2RumbleMenu[] = +{ + OP_JOYRUMBLEMENU(1) +}; + +static menuitem_t OP_Joystick3RumbleMenu[] = +{ + OP_JOYRUMBLEMENU(2) +}; + +static menuitem_t OP_Joystick4RumbleMenu[] = +{ + OP_JOYRUMBLEMENU(3) +}; + static menuitem_t OP_JoystickSetMenu[] = { {IT_CALL | IT_NOTHING, "None", NULL, M_AssignJoystick, LINEHEIGHT+5}, @@ -2532,6 +2578,11 @@ menu_t OP_Joystick2Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick2Menu, &OP menu_t OP_Joystick3Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 30, 36, NULL); menu_t OP_Joystick4Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 30, 36, NULL); +menu_t OP_Joystick1RumbleDef = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick1RumbleMenu, &OP_Joystick1Def, 30, 36, NULL); +menu_t OP_Joystick2RumbleDef = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick2RumbleMenu, &OP_Joystick2Def, 30, 36, NULL); +menu_t OP_Joystick3RumbleDef = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick3RumbleMenu, &OP_Joystick3Def, 30, 36, NULL); +menu_t OP_Joystick4RumbleDef = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick4RumbleMenu, &OP_Joystick4Def, 30, 36, NULL); + menu_t OP_JoystickSetDef = { "M_CONTRO", From 2b0e4b74688d71f899fbdb02b5df335592e570e4 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jul 2026 20:31:56 +0200 Subject: [PATCH 488/589] have fallback if SDL_OpenURL fails or does not exist on the Error box --- src/i_system.h | 3 +++ src/sdl/i_system.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/i_system.h b/src/i_system.h index 9e981cf0f..8a875728f 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -14,6 +14,9 @@ #ifndef __I_SYSTEM__ #define __I_SYSTEM__ +// page for Saturn issue reports +#define SATURNISSUEPAGE "https://github.com/Indev450/SRB2Kart-Saturn/issues" + #ifdef __cplusplus extern "C" { #endif diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 437c04243..76df07cf3 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1711,6 +1711,8 @@ static int I_OpenURL(const char *url) static void I_ShowErrorBox(const char *title, const char *msg) { + int url = -1; + if (M_CheckParm("-dedicated")) return; @@ -1736,7 +1738,11 @@ static void I_ShowErrorBox(const char *title, const char *msg) SDL_ShowMessageBox(&messageboxdata, &buttonid); if (buttonid == 1) - I_OpenURL("https://github.com/Indev450/SRB2Kart-Saturn/issues"); + url = I_OpenURL(SATURNISSUEPAGE); + + // SDL_OpenURL unsupported or failed + if (url == -1) + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Failed to Open Web Page", "Please open the following page in your web browser:\n" SATURNISSUEPAGE, NULL); } static void I_ShowSimpleErrorBox(const char *title, char *msg) From b6b70ae8f090b3a2b79b6a76771a58ae3d2c8a6c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jul 2026 20:33:07 +0200 Subject: [PATCH 489/589] Add "Report an Issue" button in the Saturn Menu yoinked from SRB2-Legacy --- src/i_system.h | 4 ++++ src/m_menu.c | 17 +++++++++++++++++ src/m_menudefs.c | 3 +++ src/sdl/i_system.cpp | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/i_system.h b/src/i_system.h index 8a875728f..9f7b0ae2e 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -212,6 +212,10 @@ static inline void I_HandleInterrupt(void) I_Quit(); } +/** \brief Open A URL + */ +int I_OpenURL(const char *url); + /** \brief The I_GetDiskFreeSpace function \param freespace a INT64 pointer to hold the free space amount diff --git a/src/m_menu.c b/src/m_menu.c index bc7c47c42..ae5bfed18 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -25,6 +25,7 @@ #include "d_netcmd.h" #include "d_clisrv.h" #include "i_net.h" +#include "i_system.h" #include "console.h" #include "r_fps.h" #include "r_local.h" @@ -276,6 +277,8 @@ static void M_ConfirmTeamChange(INT32 choice); static void M_ConfirmSpectateChange(INT32 choice); static void M_QuitSRB2(INT32 choice); +static void M_SaturnReportIssue(INT32 choice); + // Single Player static void M_TimeAttack(INT32 choice); static boolean M_QuitTimeAttackMenu(void); @@ -10589,6 +10592,20 @@ static void M_QuitSRB2(INT32 choice) M_StartMessage(quitmsg[M_RandomKey(NUM_QUITMESSAGES)], M_QuitResponse, MM_YESNO); } +// =========== +// SATURN MENU +// =========== + +static void M_SaturnReportIssue(INT32 choice) +{ + (void)choice; + int url = I_OpenURL(SATURNISSUEPAGE); + + // SDL_OpenURL unsupported or failed + if (url == -1) + M_StartMessage(M_GetText("Failed to Open Web Page.\nPlease open the following page in your web browser:\n\n" SATURNISSUEPAGE "\n\n(Press a key)\n"), NULL, MM_NOTHING); +} + #ifdef HAVE_DISCORDRPC // ===================================================================== diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 23557b8c4..4a00f3020 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1784,6 +1784,7 @@ static menuitem_t OP_SaturnMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 140}, {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 145}, {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 150}, // uwu + {IT_STRING|IT_CALL, NULL, "Report an Issue", M_SaturnReportIssue, 155} }; static const char* OP_SaturnTooltips[] = @@ -1807,6 +1808,7 @@ static const char* OP_SaturnTooltips[] = "Options for Saturn specific HUD things.", "Options for sprite distortion effects.", "See the people who helped make this project possible!", + "Noticed a bug, have a Suggestion or other Feedback?\nFeel free to tell us!", }; enum @@ -1828,6 +1830,7 @@ enum sm_hud, sm_distortionmenu, sm_credits, + sm_issue, }; static menuitem_t OP_PlayerDistortMenu[] = diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 76df07cf3..9cbdc879c 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1700,7 +1700,7 @@ static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_ms sprintf(signal_name, "%s", signame); } -static int I_OpenURL(const char *url) +int I_OpenURL(const char *url) { #if SDL_VERSION_ATLEAST(2,0,14) return SDL_OpenURL(va("%s", url)); From 29159ca5cd5727df619b5467c83b72aa8a378d9a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 8 Jul 2026 20:37:09 +0200 Subject: [PATCH 490/589] whoopsie sleeby.... --- src/sdl/i_system.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 9cbdc879c..3ecef0b9f 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1711,8 +1711,6 @@ int I_OpenURL(const char *url) static void I_ShowErrorBox(const char *title, const char *msg) { - int url = -1; - if (M_CheckParm("-dedicated")) return; @@ -1738,11 +1736,13 @@ static void I_ShowErrorBox(const char *title, const char *msg) SDL_ShowMessageBox(&messageboxdata, &buttonid); if (buttonid == 1) - url = I_OpenURL(SATURNISSUEPAGE); + { + int url = I_OpenURL(SATURNISSUEPAGE); - // SDL_OpenURL unsupported or failed - if (url == -1) - SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Failed to Open Web Page", "Please open the following page in your web browser:\n" SATURNISSUEPAGE, NULL); + // SDL_OpenURL unsupported or failed + if (url == -1) + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Failed to Open Web Page", "Please open the following page in your web browser:\n" SATURNISSUEPAGE, NULL); + } } static void I_ShowSimpleErrorBox(const char *title, char *msg) From c805fa9f339ab61ec70a400ce51cb01a06ecb1cc Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 9 Jul 2026 06:34:38 +0200 Subject: [PATCH 491/589] remove a bunch of unused crap --- src/Makefile.d/platform.mk | 2 - src/Makefile.d/sdl.mk | 10 - src/hardware/r_opengl/ogl_win.c | 549 -------------- src/hardware/r_opengl/r_opengl.dev | 79 -- src/hardware/r_opengl/r_opengl.dsp | 105 --- src/sdl/SDL_main/SDL_openxdk_main.c | 7 - src/sdl/SRB2Pandora/Makefile.cfg | 39 - src/sdl/SRB2Pandora/PXML.xml | 17 - src/sdl/SRB2Pandora/icon.png | Bin 1690 -> 0 bytes src/sdl/Srb2SDL.dsp | 1035 --------------------------- src/sdl/Srb2SDL.dsw | 62 -- src/sdl/Srb2SDL.ico | Bin 50558 -> 0 bytes src/sdl/Srb2SDL.props | 15 - src/sdl/i_system.cpp | 2 +- 14 files changed, 1 insertion(+), 1921 deletions(-) delete mode 100644 src/hardware/r_opengl/ogl_win.c delete mode 100644 src/hardware/r_opengl/r_opengl.dev delete mode 100644 src/hardware/r_opengl/r_opengl.dsp delete mode 100644 src/sdl/SDL_main/SDL_openxdk_main.c delete mode 100644 src/sdl/SRB2Pandora/Makefile.cfg delete mode 100644 src/sdl/SRB2Pandora/PXML.xml delete mode 100644 src/sdl/SRB2Pandora/icon.png delete mode 100644 src/sdl/Srb2SDL.dsp delete mode 100644 src/sdl/Srb2SDL.dsw delete mode 100644 src/sdl/Srb2SDL.ico delete mode 100644 src/sdl/Srb2SDL.props diff --git a/src/Makefile.d/platform.mk b/src/Makefile.d/platform.mk index d5423a397..12c3220d7 100644 --- a/src/Makefile.d/platform.mk +++ b/src/Makefile.d/platform.mk @@ -42,8 +42,6 @@ include Makefile.d/haiku.mk else ifdef SOLARIS # FIXME: UNTESTED UNIX=1 platform=solaris -else ifdef CYGWIN32 # FIXME: UNTESTED -platform=cygwin else ifdef MINGW ifdef MINGW64 NONX86=1 diff --git a/src/Makefile.d/sdl.mk b/src/Makefile.d/sdl.mk index 36f87fe30..aa4d4a7ee 100644 --- a/src/Makefile.d/sdl.mk +++ b/src/Makefile.d/sdl.mk @@ -15,16 +15,6 @@ sources+=$(call List,sdl/Sourcefile) NOUPNP=1 -# FIXME: UNTESTED -#ifdef PANDORA -#include sdl/SRB2Pandora/Makefile.cfg -#endif #ifdef PANDORA - -# FIXME: UNTESTED -#ifdef CYGWIN32 -#include sdl/MakeCYG.cfg -#endif #ifdef CYGWIN32 - ifndef NOHW sources+=sdl/ogl_sdl.c endif diff --git a/src/hardware/r_opengl/ogl_win.c b/src/hardware/r_opengl/ogl_win.c deleted file mode 100644 index 31daa22fd..000000000 --- a/src/hardware/r_opengl/ogl_win.c +++ /dev/null @@ -1,549 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -//----------------------------------------------------------------------------- -/// \file -/// \brief Windows specific part of the OpenGL API for Doom Legacy -/// -/// TODO: -/// - check if windowed mode works -/// - support different pixel formats - - -#if defined (_WIN32) - -//#define WIN32_LEAN_AND_MEAN -#define RPC_NO_WINDOWS_H -#include -#include -#include "r_opengl.h" - - -// ************************************************************************** -// GLOBALS -// ************************************************************************** - -#ifdef DEBUG_TO_FILE -static unsigned long nb_frames = 0; -static clock_t my_clock; -FILE *gllogstream; -#endif - -static HDC hDC = NULL; // the window's device context -static HGLRC hGLRC = NULL; // the OpenGL rendering context -static HWND hWnd = NULL; -static BOOL WasFullScreen = FALSE; -static void UnSetRes(void); - -#ifdef USE_WGL_SWAP -PFNWGLEXTSWAPCONTROLPROC wglSwapIntervalEXT = NULL; -#endif - -PFNglClear pglClear; -PFNglGetIntegerv pglGetIntegerv; -PFNglGetString pglGetString; - -#define MAX_VIDEO_MODES 32 -static vmode_t video_modes[MAX_VIDEO_MODES]; -INT32 oglflags = 0; - -// ************************************************************************** -// FUNCTIONS -// ************************************************************************** - -// -----------------+ -// APIENTRY DllMain : DLL Entry Point, -// : open/close debug log -// Returns : -// -----------------+ -BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module - DWORD fdwReason, // reason for calling function - LPVOID lpvReserved) // reserved -{ - // Perform actions based on the reason for calling. - UNREFERENCED_PARAMETER(lpvReserved); - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - // Initialize once for each new process. - // Return FALSE to fail DLL load. -#ifdef DEBUG_TO_FILE - gllogstream = fopen("ogllog.txt", "wt"); - if (gllogstream == NULL) - return FALSE; -#endif - DisableThreadLibraryCalls(hinstDLL); - break; - - case DLL_THREAD_ATTACH: - // Do thread-specific initialization. - break; - - case DLL_THREAD_DETACH: - // Do thread-specific cleanup. - break; - - case DLL_PROCESS_DETACH: - // Perform any necessary cleanup. -#ifdef DEBUG_TO_FILE - if (gllogstream) - { - fclose(gllogstream); - gllogstream = NULL; - } -#endif - break; - } - - return TRUE; // Successful DLL_PROCESS_ATTACH. -} - -#ifdef STATIC_OPENGL -#define pwglGetProcAddress wglGetProcAddress; -#define pwglCreateContext wglCreateContext; -#define pwglDeleteContext wglDeleteContext; -#define pwglMakeCurrent wglMakeCurrent; -#else -static HMODULE OGL32; -typedef void *(WINAPI *PFNwglGetProcAddress) (const char *); -static PFNwglGetProcAddress pwglGetProcAddress; -typedef HGLRC (WINAPI *PFNwglCreateContext) (HDC hdc); -static PFNwglCreateContext pwglCreateContext; -typedef BOOL (WINAPI *PFNwglDeleteContext) (HGLRC hglrc); -static PFNwglDeleteContext pwglDeleteContext; -typedef BOOL (WINAPI *PFNwglMakeCurrent) (HDC hdc, HGLRC hglrc); -static PFNwglMakeCurrent pwglMakeCurrent; -#endif - -#ifndef STATIC_OPENGL -void *GetGLFunc(const char *proc) -{ - void *func = NULL; - if (pwglGetProcAddress) - func = pwglGetProcAddress(proc); - if (!func) - func = GetProcAddress(OGL32, proc); - return func; -} -#endif - -boolean LoadGL(void) -{ -#ifndef STATIC_OPENGL - OGL32 = LoadLibrary("OPENGL32.DLL"); - - if (!OGL32) - return 0; - - pwglGetProcAddress = GetGLFunc("wglGetProcAddress"); - pwglCreateContext = GetGLFunc("wglCreateContext"); - pwglDeleteContext = GetGLFunc("wglDeleteContext"); - pwglMakeCurrent = GetGLFunc("wglMakeCurrent"); -#endif - return SetupGLfunc(); -} - -// -----------------+ -// SetupPixelFormat : Set the device context's pixel format -// Note : Because we currently use only the desktop's BPP format, all the -// : video modes in Doom Legacy OpenGL are of the same BPP, thus the -// : PixelFormat is set only once. -// : Setting the pixel format more than once on the same window -// : doesn't work. (ultimately for different pixel formats, we -// : should close the window, and re-create it) -// -----------------+ -int SetupPixelFormat(INT32 WantColorBits, INT32 WantStencilBits, INT32 WantDepthBits) -{ - static DWORD iLastPFD = 0; - INT32 nPixelFormat; - PIXELFORMATDESCRIPTOR pfd = - { - sizeof (PIXELFORMATDESCRIPTOR), // size - 1, // version - PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, - PFD_TYPE_RGBA, // color type - 32 /*WantColorBits*/, // cColorBits : prefered color depth - 0, 0, // cRedBits, cRedShift - 0, 0, // cGreenBits, cGreenShift - 0, 0, // cBlueBits, cBlueShift - 0, 0, // cAlphaBits, cAlphaShift - 0, // cAccumBits - 0, 0, 0, 0, // cAccum Red/Green/Blue/Alpha Bits - 0, // cDepthBits (0,16,24,32) - 0, // cStencilBits - 0, // cAuxBuffers - PFD_MAIN_PLANE, // iLayerType - 0, // reserved, must be zero - 0, 0, 0, // dwLayerMask, dwVisibleMask, dwDamageMask - }; - - DWORD iPFD = (WantColorBits<<16) | (WantStencilBits<<8) | WantDepthBits; - - pfd.cDepthBits = (BYTE)WantDepthBits; - pfd.cStencilBits = (BYTE)WantStencilBits; - - if (iLastPFD) - { - DBG_Printf("WARNING : SetPixelFormat() called twise not supported by all drivers !\n"); - } - - // set the pixel format only if different than the current - if (iPFD == iLastPFD) - return 2; - else - iLastPFD = iPFD; - - DBG_Printf("SetupPixelFormat() - %d ColorBits - %d StencilBits - %d DepthBits\n", - WantColorBits, WantStencilBits, WantDepthBits); - - nPixelFormat = ChoosePixelFormat(hDC, &pfd); - - if (nPixelFormat == 0) - DBG_Printf("ChoosePixelFormat() FAILED\n"); - - if (SetPixelFormat(hDC, nPixelFormat, &pfd) == 0) - { - DBG_Printf("SetPixelFormat() FAILED\n"); - return 0; - } - - return 1; -} - - -// -----------------+ -// SetRes : Set a display mode -// Notes : pcurrentmode is actually not used -// -----------------+ -static INT32 WINAPI SetRes(viddef_t *lvid, vmode_t *pcurrentmode) -{ - LPCSTR renderer; - BOOL WantFullScreen = !(lvid->u.windowed); //(lvid->u.windowed ? 0 : CDS_FULLSCREEN); - - UNREFERENCED_PARAMETER(pcurrentmode); - DBG_Printf ("SetMode(): %dx%d %d bits (%s)\n", - lvid->width, lvid->height, lvid->bpp*8, - WantFullScreen ? "fullscreen" : "windowed"); - - hWnd = lvid->WndParent; - - // BP : why flush texture ? - // if important flush also the first one (white texture) and restore it ! - Flush(); // Flush textures. - -// TODO: if not fullscreen, skip display stuff and just resize viewport stuff ... - - // Exit previous mode - //if (hGLRC) //Hurdler: TODO: check if this is valid - // UnSetRes(); - if (WasFullScreen) - ChangeDisplaySettings(NULL, CDS_FULLSCREEN); //switch in and out of fullscreen - - // Change display settings. - if (WantFullScreen) - { - DEVMODE dm; - ZeroMemory(&dm, sizeof (dm)); - dm.dmSize = sizeof (dm); - dm.dmPelsWidth = lvid->width; - dm.dmPelsHeight = lvid->height; - dm.dmBitsPerPel = lvid->bpp*8; - dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; - if (ChangeDisplaySettings(&dm, CDS_TEST) != DISP_CHANGE_SUCCESSFUL) - return -2; - if (ChangeDisplaySettings(&dm, CDS_FULLSCREEN) !=DISP_CHANGE_SUCCESSFUL) - return -3; - - SetWindowLong(hWnd, GWL_STYLE, WS_POPUP|WS_VISIBLE); - // faB : book says to put these, surely for windowed mode - //WS_CLIPCHILDREN|WS_CLIPSIBLINGS); - SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, lvid->width, lvid->height, SWP_NOACTIVATE|SWP_NOZORDER); - } - else - { - RECT bounds; - INT32 x, y; - INT32 w = lvid->width, h = lvid->height; - GetWindowRect(hWnd, &bounds); - bounds.right = bounds.left+w; - bounds.bottom = bounds.top+h; - AdjustWindowRectEx(&bounds, GetWindowLong(hWnd, GWL_STYLE), (GetMenu(hWnd) != NULL), 0); - w = bounds.right-bounds.left; - h = bounds.bottom-bounds.top; - x = (GetSystemMetrics(SM_CXSCREEN)-w)/2; - y = (GetSystemMetrics(SM_CYSCREEN)-h)/2; - SetWindowPos(hWnd, NULL, x, y, w, h, SWP_NOACTIVATE|SWP_NOZORDER); - } - - if (!hDC) - hDC = GetDC(hWnd); - if (!hDC) - { - DBG_Printf("GetDC() FAILED\n"); - return 0; - } - - { - INT32 res; - - // Set res. - res = SetupPixelFormat(lvid->bpp*8, 0, 16); - - if (res == 0) - return 0; - else if (res == 1) - { - // Exit previous mode - if (hGLRC) - UnSetRes(); - hGLRC = pwglCreateContext(hDC); - if (!hGLRC) - { - DBG_Printf("pwglCreateContext() FAILED\n"); - return 0; - } - if (!pwglMakeCurrent(hDC, hGLRC)) - { - DBG_Printf("wglMakeCurrent() FAILED\n"); - return 0; - } - } - } - - gl_extensions = pglGetString(GL_EXTENSIONS); - // Get info and extensions. - //BP: why don't we make it earlier ? - //Hurdler: we cannot do that before intialising gl context - renderer = (LPCSTR)pglGetString(GL_RENDERER); - DBG_Printf("Vendor : %s\n", pglGetString(GL_VENDOR)); - DBG_Printf("Renderer : %s\n", renderer); - DBG_Printf("Version : %s\n", pglGetString(GL_VERSION)); - DBG_Printf("Extensions : %s\n", gl_extensions); - - // BP: disable advenced feature that don't work on somes hardware - // Hurdler: Now works on G400 with bios 1.6 and certified drivers 6.04 - if (strstr(renderer, "810")) oglflags |= GLF_NOZBUFREAD; - DBG_Printf("oglflags : 0x%X\n", oglflags); - -#ifdef USE_WGL_SWAP - if (isExtAvailable("WGL_EXT_swap_control",gl_extensions)) - wglSwapIntervalEXT = GetGLFunc("wglSwapIntervalEXT"); - else - wglSwapIntervalEXT = NULL; -#endif - - if (isExtAvailable("GL_EXT_texture_filter_anisotropic",gl_extensions)) - pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy); - else - maximumAnisotropy = 0; - - SetupGLFunc13(); - - screen_depth = (GLbyte)(lvid->bpp*8); - if (screen_depth > 16) - textureformatGL = GL_RGBA; - else - textureformatGL = GL_RGB5_A1; - - GL_SetModelView(lvid->width, lvid->height); - GL_SetStates(); - // we need to clear the depth buffer. Very important!!! - pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); - - lvid->buffer = NULL; // unless we use the software view - lvid->direct = NULL; // direct access to video memory, old DOS crap - - WasFullScreen = WantFullScreen; - - return 1; // on renvoie une valeur pour dire que cela s'est bien pass� -} - - -// -----------------+ -// UnSetRes : Restore the original display mode -// -----------------+ -static void UnSetRes(void) -{ - DBG_Printf("UnSetRes()\n"); - - pwglMakeCurrent(hDC, NULL); - pwglDeleteContext(hGLRC); - hGLRC = NULL; - if (WasFullScreen) - ChangeDisplaySettings(NULL, CDS_FULLSCREEN); -} - - -// -----------------+ -// GetModeList : Return the list of available display modes. -// Returns : pvidmodes - points to list of detected OpenGL video modes -// : numvidmodes - number of detected OpenGL video modes -// -----------------+ -EXPORT void HWRAPI(GetModeList) (vmode_t** pvidmodes, INT32 *numvidmodes) -{ - INT32 i; - -#if 1 - INT32 iMode; -/* - faB test code - - Commented out because there might be a problem with combo (Voodoo2 + other card), - we need to get the 3D card's display modes only. -*/ - (*pvidmodes) = &video_modes[0]; - - // Get list of device modes - for (i = 0,iMode = 0; iMode < MAX_VIDEO_MODES; i++) - { - DEVMODE Tmp; - ZeroMemory(&Tmp, sizeof (Tmp)); - Tmp.dmSize = sizeof (Tmp); - if (!EnumDisplaySettings(NULL, i, &Tmp)) - break; - - // add video mode - if (Tmp.dmBitsPerPel == 16 && - (iMode == 0 || ! - (Tmp.dmPelsWidth == video_modes[iMode-1].width && - Tmp.dmPelsHeight == video_modes[iMode-1].height) - ) - ) - { - video_modes[iMode].pnext = &video_modes[iMode+1]; - video_modes[iMode].windowed = 0; // fullscreen is the default - video_modes[iMode].misc = 0; - video_modes[iMode].name = malloc(12 * sizeof (CHAR)); - sprintf(video_modes[iMode].name, "%dx%d", (INT32)Tmp.dmPelsWidth, (INT32)Tmp.dmPelsHeight); - DBG_Printf ("Mode: %s\n", video_modes[iMode].name); - video_modes[iMode].width = Tmp.dmPelsWidth; - video_modes[iMode].height = Tmp.dmPelsHeight; - video_modes[iMode].bytesperpixel = Tmp.dmBitsPerPel/8; - video_modes[iMode].rowbytes = Tmp.dmPelsWidth * video_modes[iMode].bytesperpixel; - video_modes[iMode].pextradata = NULL; - video_modes[iMode].setmode = SetRes; - iMode++; - } - } - (*numvidmodes) = iMode; -#else - - // classic video modes (fullscreen/windowed) - // Added some. Tails - INT32 res[][2] = { - { 320, 200}, - { 320, 240}, - { 400, 300}, - { 512, 384}, - { 640, 400}, - { 640, 480}, - { 800, 600}, - { 960, 600}, - {1024, 768}, - {1152, 864}, - {1280, 800}, - {1280, 960}, - {1280,1024}, - {1600,1000}, - {1680,1050}, - {1920,1200}, -}; - - HDC bpphdc; - INT32 iBitsPerPel; - - DBG_Printf ("HWRAPI GetModeList()\n"); - - bpphdc = GetDC(NULL); // on obtient le bpp actuel - iBitsPerPel = GetDeviceCaps(bpphdc, BITSPIXEL); - - ReleaseDC(NULL, bpphdc); - - (*pvidmodes) = &video_modes[0]; - (*numvidmodes) = sizeof (res) / sizeof (res[0]); - for (i = 0; i < (*numvidmodes); i++) - { - video_modes[i].pnext = &video_modes[i+1]; - video_modes[i].windowed = 0; // fullscreen is the default - video_modes[i].misc = 0; - video_modes[i].name = malloc(12 * sizeof (CHAR)); - sprintf(video_modes[i].name, "%dx%d", res[i][0], res[i][1]); - DBG_Printf ("Mode: %s\n", video_modes[i].name); - video_modes[i].width = res[i][0]; - video_modes[i].height = res[i][1]; - video_modes[i].bytesperpixel = iBitsPerPel/8; - video_modes[i].rowbytes = res[i][0] * video_modes[i].bytesperpixel; - video_modes[i].pextradata = NULL; - video_modes[i].setmode = SetRes; - } -#endif - video_modes[(*numvidmodes)-1].pnext = NULL; -} - - -// -----------------+ -// Shutdown : Shutdown OpenGL, restore the display mode -// -----------------+ -EXPORT void HWRAPI(Shutdown) (void) -{ -#ifdef DEBUG_TO_FILE - long nb_centiemes; - - DBG_Printf ("HWRAPI Shutdown()\n"); - nb_centiemes = ((clock()-my_clock)*100)/CLOCKS_PER_SEC; - DBG_Printf("Nb frames: %li; Nb sec: %2.2f -> %2.1f fps\n", - nb_frames, nb_centiemes/100.0f, (100*nb_frames)/(double)nb_centiemes); -#endif - - Flush(); - - // Exit previous mode - if (hGLRC) - UnSetRes(); - - if (hDC) - { - ReleaseDC(hWnd, hDC); - hDC = NULL; - } - FreeLibrary(OGL32); - DBG_Printf ("HWRAPI Shutdown(DONE)\n"); -} - -// -----------------+ -// FinishUpdate : Swap front and back buffers -// -----------------+ -void GL_FinishUpdate (INT32 waitvbl) -{ -#ifdef USE_WGL_SWAP - static INT32 oldwaitvbl = 0; -#else - UNREFERENCED_PARAMETER(waitvbl); -#endif - // DBG_Printf ("FinishUpdate()\n"); -#ifdef DEBUG_TO_FILE - if ((++nb_frames)==2) // on ne commence pas � la premi�re frame - my_clock = clock(); -#endif - -#ifdef USE_WGL_SWAP - if (oldwaitvbl != waitvbl && wglSwapIntervalEXT) - wglSwapIntervalEXT(waitvbl); - oldwaitvbl = waitvbl; -#endif - - SwapBuffers(hDC); -} -#endif diff --git a/src/hardware/r_opengl/r_opengl.dev b/src/hardware/r_opengl/r_opengl.dev deleted file mode 100644 index f0b23ae23..000000000 --- a/src/hardware/r_opengl/r_opengl.dev +++ /dev/null @@ -1,79 +0,0 @@ -[Project] -FileName=r_opengl.dev -Name=r_opengl -Ver=1 -IsCpp=1 -Type=3 -Compiler=-D_M_IX86=500_@@_-Wall_@@_-D_WINDOWS_@@_-DUSE_WGL_SWAP_@@_-Os_@@_-fomit-frame-pointer_@@_ -CppCompiler= -Includes= -Linker=--def ../r_mingw.def_@@_-lgdi32_@@_ -Libs= -UnitCount=3 -Folders= -ObjFiles= -PrivateResource= -ResourceIncludes= -MakeIncludes= -Icon= -ExeOutput=C:\srb2demo2 -ObjectOutput=..\..\..\objs\Mingw\r_opengl -OverrideOutput=1 -OverrideOutputName=r_opengl.dll -HostApplication= -CommandLine= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=00000000000000000111d0 -UseCustomMakefile=0 -CustomMakefile= - -[Unit1] -FileName=ogl_win.c -Folder= -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit2] -FileName=r_opengl.c -Folder= -Compile=1 -CompileCpp=0 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[Unit3] -FileName=r_opengl.h -Folder= -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion=0.1 -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename=r_opengl.exe -ProductName=r_opengl -ProductVersion=0.1 -AutoIncBuildNr=0 - diff --git a/src/hardware/r_opengl/r_opengl.dsp b/src/hardware/r_opengl/r_opengl.dsp deleted file mode 100644 index b1603e7f2..000000000 --- a/src/hardware/r_opengl/r_opengl.dsp +++ /dev/null @@ -1,105 +0,0 @@ -# Microsoft Developer Studio Project File - Name="r_opengl" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=r_opengl - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "r_opengl.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "r_opengl.mak" CFG="r_opengl - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "r_opengl - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "r_opengl - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "r_opengl - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "r_opengl___Win32_Release" -# PROP BASE Intermediate_Dir "r_opengl___Win32_Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\..\..\bin\VC\Release\r_opengl" -# PROP Intermediate_Dir "..\..\..\objs\VC\Release\r_opengl" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "R_OPENGL_EXPORTS" /YX /FD /c -# ADD CPP /nologo /G5 /W3 /GX /Zi /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WIN32__" /D "__MSC__" /D "USE_WGL_SWAP" /FR /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x80c /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 user32.lib gdi32.lib /nologo /dll /pdb:"..\..\..\bin\VC\Release\r_opengl.pdb" /machine:I386 /out:"C:\srb2demo2\r_opengl.dll" -# SUBTRACT LINK32 /pdb:none /debug - -!ELSEIF "$(CFG)" == "r_opengl - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "..\..\..\objs\Debug" -# PROP BASE Intermediate_Dir "..\..\..\objs\Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\..\..\bin\VC\Debug\r_opengl" -# PROP Intermediate_Dir "..\..\..\objs\VC\Debug\r_opengl" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "R_OPENGL_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /G6 /W4 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "__WIN32__" /D "__MSC__" /D "USE_WGL_SWAP" /FR /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x80c /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 user32.lib gdi32.lib /nologo /dll /pdb:"..\..\..\bin\VC\Debug\r_opengl.pdb" /debug /machine:I386 /out:"C:\srb2demo2\r_opengld.dll" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "r_opengl - Win32 Release" -# Name "r_opengl - Win32 Debug" -# Begin Source File - -SOURCE=.\ogl_win.c -# End Source File -# Begin Source File - -SOURCE=.\r_opengl.c -# End Source File -# Begin Source File - -SOURCE=.\r_opengl.h -# End Source File -# End Target -# End Project diff --git a/src/sdl/SDL_main/SDL_openxdk_main.c b/src/sdl/SDL_main/SDL_openxdk_main.c deleted file mode 100644 index 63db8da2d..000000000 --- a/src/sdl/SDL_main/SDL_openxdk_main.c +++ /dev/null @@ -1,7 +0,0 @@ -/* Include the SDL main definition header */ -#include "SDL_main.h" - -void XBoxStartup() -{ - SDL_main(0, NULL); /// \todo ? -} diff --git a/src/sdl/SRB2Pandora/Makefile.cfg b/src/sdl/SRB2Pandora/Makefile.cfg deleted file mode 100644 index c7f0f8449..000000000 --- a/src/sdl/SRB2Pandora/Makefile.cfg +++ /dev/null @@ -1,39 +0,0 @@ -# Quick Pandora target to make a compliant SRB2 PND file. - -PNDNAME=SRB2.pnd -PNDDIR=$(BIN)/pnd -ICON=sdl/SRB2Pandora/icon.png -PXML=sdl/SRB2Pandora/PXML.xml - -SED=sed -CAT=cat -CP=cp -XARGS=xargs -FOR=for -WGET=wget -P $(PNDDIR) -c -nc - -SHXARGS:=$(XARGS) -SHSED:=$(SED) - -ifndef ECHO - CP:=@$(CP) - CAT:=@$(CAT) - SED:=@$(SED) - XARGS:=@$(XARGS) - FOR:=@(FOR) -endif - -$(BIN)/$(PNDNAME): $(BIN)/$(EXENAME) - @echo Linking $(PNDNAME)... - $(MKDIR) $(PNDDIR) - $(CP) $(BIN)/$(EXENAME) $(PNDDIR) - $(CP) $(ICON) $(PNDDIR) - $(CP) $(PXML) $(PNDDIR) -ifdef WITHDATA - $(FOR) datafile in $(shell echo $(D_FILES) | $(SHSED) 's/\.srb/\.wad/' | $(SHXARGS) -n 1 basename); do \ - $(WGET) http://alam.srb2.org/SRB2/2.0.6-Final/Resources/$$datafile; \ - done -endif - $(MKISOFS) -l -r -o $@ $(PNDDIR) - $(CAT) $(PXML) >> $@ - $(REMOVE) -r $(PNDDIR) diff --git a/src/sdl/SRB2Pandora/PXML.xml b/src/sdl/SRB2Pandora/PXML.xml deleted file mode 100644 index 33a9587db..000000000 --- a/src/sdl/SRB2Pandora/PXML.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - Sonic Robo Blast 2 - ソニック・ロボ・ブラスト・2 - A 3D Sonic fangame with a huge fanbase developing custom content, including characters, levels, and even large-scale modifications - - - - - - - - - - - diff --git a/src/sdl/SRB2Pandora/icon.png b/src/sdl/SRB2Pandora/icon.png deleted file mode 100644 index 63af73ac3a4e3046783312465aec2d985172f726..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1690 zcmV;L24(q)P)O!-2lB^gLcZMPU)B9hVuf<6yDwU?fX z3ky{b9)wn$97OyF7K$k7!Y+%HJ!Fs`_8_7N3oYwmd#LMDR_Z(CP+?IDQqitximl=- z%<|pC{K!l*NoUfO-9q1`O(rwn_j%vXd*Amyi6Vr+ezp$mb2|X=Ut3!fKnNjCa|i$d z=m+oxhzJ0{%mCgvpL`8f{Rx(3DZ5=$X-5(ZA>`1|Eyr<+aVLY>*cF&v0kEv1B+>!s zAY$JY0&~1)F<*tM-i!^TB><|b%6$I&5Xb!vQ41kqFqa@iB{B#loleWGtt};b)Tbm- z88)?>g_#`Q2iyZipjaFbB9}V@B3&}OiN;7K@4z%o08oN-DFdK}QLj0`4mf{KxXyE1 ztB@jukj3JUPPOoJ*G@1YW?@-H5Ix;7>a~cwjxz`b-~cuZ9iZmBV6Pd2LP7}i_4Uc| z@t;GJkohWzrXxD9JFg7r#Lhi6D;YYN4X?Crx0RJEv6EN;!20^S!pySvV0&?92GO+l zUNf`rWiSJU!V-uQJ^%#X;r>>f4^*L4DkaaH`8716J119nu3 zhCLfjiJr#L(C@IUqKpl|=A_=F(zuI6c{F*aF@vzMun~h81fr*rb|cVA6pMezXw4X7 zZ0tUc965rQFJEF~Bj;-$s9}Atr{(V33lBiCSd@13^&P9rg$w^+aB#5h%AGrZg1HqZ zqcnRZ2r;WP1hBBMAQu-GF*i5eFcO8r3??QfplKQg2M5v9)8k#;+}y;wckgia>_UVf zv=2lF0E~=`$kEYJoH%i!VZARDW-vK9iDSo(;rQ|60p|fg(=_CAIo!K9*7km@@0p@vsYx}=cBU~!g&6A%$e+KXx07F%;z_Nh%@88FI_>(6L zU|=`(rXhX&W}4^gWtFwHH3+ecLg8;zDi#3X!-o%h98Y!*EOr970?V?(LPCC9Akj3t`U#A-+5EjZ5cBu#7%? z_AKzhuC6W+5e^+X1OU$Y5a+;&CZjNy?C2B07Q|YV79T!*=)I9jrQq(y*w`3URmJe| za17@;g1E&1&3UaXInA4@s@B7{IDlabG#KZmAixN+kK3WWly)lFnF8Z=FVpI$pz zsZ{c5LgCFFqqHqG%igXCaXtP_T&-4>yLa!(d_Ircw{PR^+qXEE&w~hfLxiJ8kK*v* z!#h4~Zf*`b0dCW2uwg3^0T3MOyuBHxu(EPf#+i-1X0ETVPiC`OEH5v67pICvl*>8{ zhZZ9vBk1n#4ve2`Yirot+{Bytd1uH8M*Qrz3s_yf7aD!P^EC>dj5Qy7WpsUg9pmG@ zn3$yzBF4=3~sF*W-tuqpmgFn|Jpw=Hf`2a zRc%R?sDZdNi;`iqbfA{K-Lt_we*8G#d=&fm@mzc4^-LxsuYH|`uE+V}g5e6q*M9j6 zuU_@~+8ElF1Jv-4i&{=2eLrApr@c;|))TU%6k?f@q0-c?mo(SL`V)Y{^ zqf!}e9{|4-sZ -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=Srb2SDL - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "Srb2SDL.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "Srb2SDL.mak" CFG="Srb2SDL - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "Srb2SDL - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "Srb2SDL - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "Srb2SDL - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\..\bin\VC\Release\SDL" -# PROP Intermediate_Dir "..\..\objs\VC\Release\SDL" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G5 /W3 /GX /Zi /Ot /Og /Oi /Op /Oy /Ob1 /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "NDEBUG" /D "SDLMAIN" /D "NO_STDIO_REDIRECT" /D "USE_WGL_SWAP" /D "HAVE_SDL" /D "HWRENDER" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GF /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -# SUBTRACT RSC /x -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo /o"..\..\objs\SDL\Release\SRB2.bsc" -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 SDL.lib SDL_mixer.lib user32.lib advapi32.lib ws2_32.lib /nologo /subsystem:windows /pdb:"C:\srb2demo2\srb2sdl.pdb" /debug /machine:I386 /out:"C:\srb2demo2\srb2sdl.exe" -# SUBTRACT LINK32 /profile /pdb:none /incremental:yes - -!ELSEIF "$(CFG)" == "Srb2SDL - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\..\bin\VC\Debug\SDL" -# PROP Intermediate_Dir "..\..\objs\VC\Debug\SDL" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -MTL=midl.exe -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G6 /W4 /WX /Gm /GX /ZI /Od /Op /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "_DEBUG" /D "USE_WGL_SWAP" /D "HAVE_SDL" /D "HWRENDER" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -# SUBTRACT RSC /x -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo /o"..\..\objs\SDL\Debug\SRB2.bsc" -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 SDL.lib SDL_mixer.lib user32.lib advapi32.lib ws2_32.lib /nologo /subsystem:console /pdb:"C:\srb2demo2\srb2sdldebug.pdb" /debug /machine:I386 /out:"C:\srb2demo2\srb2sdldebug.exe" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "Srb2SDL - Win32 Release" -# Name "Srb2SDL - Win32 Debug" -# Begin Group "SDLapp" - -# PROP Default_Filter "" -# Begin Group "filter" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\filter\filters.c -# End Source File -# Begin Source File - -SOURCE=.\filter\filters.h -# End Source File -# Begin Source File - -SOURCE=.\filter\hq2x.c -# End Source File -# Begin Source File - -SOURCE=.\filter\hq2x.h -# End Source File -# Begin Source File - -SOURCE=.\filter\interp.h -# End Source File -# Begin Source File - -SOURCE=.\filter\lq2x.c -# End Source File -# Begin Source File - -SOURCE=.\filter\lq2x.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\dosstr.c -# End Source File -# Begin Source File - -SOURCE=.\endtxt.c -# End Source File -# Begin Source File - -SOURCE=.\endtxt.h -# End Source File -# Begin Source File - -SOURCE=..\filesrch.c -# End Source File -# Begin Source File - -SOURCE=..\filesrch.h -# End Source File -# Begin Source File - -SOURCE=.\hwsym_sdl.c -# End Source File -# Begin Source File - -SOURCE=.\hwsym_sdl.h -# End Source File -# Begin Source File - -SOURCE=.\i_cdmus.c -# End Source File -# Begin Source File - -SOURCE=.\i_main.c -# End Source File -# Begin Source File - -SOURCE=.\i_net.c -# End Source File -# Begin Source File - -SOURCE=.\i_sound.c -# End Source File -# Begin Source File - -SOURCE=.\i_system.c -# End Source File -# Begin Source File - -SOURCE=.\i_video.c -# End Source File -# Begin Source File - -SOURCE=.\IMG_xpm.c -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=.\ogl_sdl.c -# End Source File -# Begin Source File - -SOURCE=.\ogl_sdl.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\r_opengl\r_opengl.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\r_opengl\r_opengl.h -# End Source File -# Begin Source File - -SOURCE=.\SDL_icon.xpm -# End Source File -# Begin Source File - -SOURCE=.\SDL_main\SDL_win32_main.c - -!IF "$(CFG)" == "Srb2SDL - Win32 Release" - -!ELSEIF "$(CFG)" == "Srb2SDL - Win32 Debug" - -# PROP Exclude_From_Build 1 - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\sdlmain.h -# End Source File -# Begin Source File - -SOURCE=..\win32\Srb2win.rc -# End Source File -# Begin Source File - -SOURCE=..\win32\win_dbg.c -# End Source File -# Begin Source File - -SOURCE=..\win32\win_dbg.h -# End Source File -# Begin Source File - -SOURCE=..\win32\win_main.h -# End Source File -# End Group -# Begin Group "A_Asm" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\p5prof.h -# End Source File -# Begin Source File - -SOURCE=..\tmap.nas - -!IF "$(CFG)" == "Srb2SDL - Win32 Release" - -# PROP Ignore_Default_Tool 1 -# Begin Custom Build - Compiling $(InputName).nas with NASM... -IntDir=.\..\..\objs\VC\Release\SDL -InputPath=..\tmap.nas -InputName=tmap - -"$(IntDir)/$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - nasm -g -o $(IntDir)/$(InputName).obj -f win32 $(InputPath) - -# End Custom Build - -!ELSEIF "$(CFG)" == "Srb2SDL - Win32 Debug" - -# PROP Ignore_Default_Tool 1 -# Begin Custom Build - Compiling $(InputName).nas with NASM... -IntDir=.\..\..\objs\VC\Debug\SDL -InputPath=..\tmap.nas -InputName=tmap - -"$(IntDir)/$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - nasm -g -o $(IntDir)/$(InputName).obj -f win32 $(InputPath) - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\tmap_mmx.nas - -!IF "$(CFG)" == "Srb2SDL - Win32 Release" - -# PROP Ignore_Default_Tool 1 -# Begin Custom Build - Compiling $(InputName).nas with NASM... -IntDir=.\..\..\objs\VC\Release\SDL -InputPath=..\tmap_mmx.nas -InputName=tmap_mmx - -"$(IntDir)/$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - nasm -g -o $(IntDir)/$(InputName).obj -f win32 $(InputPath) - -# End Custom Build - -!ELSEIF "$(CFG)" == "Srb2SDL - Win32 Debug" - -# PROP Ignore_Default_Tool 1 -# Begin Custom Build - Compiling $(InputName).nas with NASM... - -IntDir=.\..\..\objs\VC\Debug\SDL -InputPath=..\tmap_mmx.nas -InputName=tmap_mmx - -"$(IntDir)/$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - nasm -g -o $(IntDir)/$(InputName).obj -f win32 $(InputPath) - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\tmap_vc.nas - -!IF "$(CFG)" == "Srb2SDL - Win32 Release" - -# Begin Custom Build - Compiling $(InputName).nas with NASM... -IntDir=.\..\..\objs\VC\Release\SDL -InputPath=..\tmap_vc.nas -InputName=tmap_vc - -"$(IntDir)/$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - nasm -g -o $(IntDir)/$(InputName).obj -f win32 $(InputPath) - -# End Custom Build - -!ELSEIF "$(CFG)" == "Srb2SDL - Win32 Debug" - -# Begin Custom Build - Compiling $(InputName).nas with NASM... -IntDir=.\..\..\objs\VC\Debug\SDL -InputPath=..\tmap_vc.nas -InputName=tmap_vc - -"$(IntDir)/$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - nasm -g -o $(IntDir)/$(InputName).obj -f win32 $(InputPath) - -# End Custom Build - -!ENDIF - -# End Source File -# End Group -# Begin Group "D_Doom" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\comptime.c -# End Source File -# Begin Source File - -SOURCE=..\d_clisrv.c -# End Source File -# Begin Source File - -SOURCE=..\d_clisrv.h -# End Source File -# Begin Source File - -SOURCE=..\d_event.h -# End Source File -# Begin Source File - -SOURCE=..\d_main.c -# End Source File -# Begin Source File - -SOURCE=..\d_main.h -# End Source File -# Begin Source File - -SOURCE=..\d_net.c -# End Source File -# Begin Source File - -SOURCE=..\d_net.h -# End Source File -# Begin Source File - -SOURCE=..\d_netcmd.c -# End Source File -# Begin Source File - -SOURCE=..\d_netcmd.h -# End Source File -# Begin Source File - -SOURCE=..\d_netfil.c -# End Source File -# Begin Source File - -SOURCE=..\d_netfil.h -# End Source File -# Begin Source File - -SOURCE=..\d_player.h -# End Source File -# Begin Source File - -SOURCE=..\d_think.h -# End Source File -# Begin Source File - -SOURCE=..\d_ticcmd.h -# End Source File -# Begin Source File - -SOURCE=..\dehacked.c -# End Source File -# Begin Source File - -SOURCE=..\dehacked.h -# End Source File -# Begin Source File - -SOURCE=..\doomdata.h -# End Source File -# Begin Source File - -SOURCE=..\doomdef.h -# End Source File -# Begin Source File - -SOURCE=..\doomstat.h -# End Source File -# Begin Source File - -SOURCE=..\doomtype.h -# End Source File -# Begin Source File - -SOURCE=..\z_zone.c -# End Source File -# Begin Source File - -SOURCE=..\z_zone.h -# End Source File -# End Group -# Begin Group "F_Frame" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\f_finale.c -# End Source File -# Begin Source File - -SOURCE=..\f_finale.h -# End Source File -# Begin Source File - -SOURCE=..\f_wipe.c -# End Source File -# End Group -# Begin Group "G_Game" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\g_game.c -# End Source File -# Begin Source File - -SOURCE=..\g_game.h -# End Source File -# Begin Source File - -SOURCE=..\g_input.c -# End Source File -# Begin Source File - -SOURCE=..\g_input.h -# End Source File -# Begin Source File - -SOURCE=..\g_state.h -# End Source File -# End Group -# Begin Group "H_Hud" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\am_map.c -# End Source File -# Begin Source File - -SOURCE=..\am_map.h -# End Source File -# Begin Source File - -SOURCE=..\command.c -# End Source File -# Begin Source File - -SOURCE=..\command.h -# End Source File -# Begin Source File - -SOURCE=..\console.c -# End Source File -# Begin Source File - -SOURCE=..\console.h -# End Source File -# Begin Source File - -SOURCE=..\hu_stuff.c -# End Source File -# Begin Source File - -SOURCE=..\hu_stuff.h -# End Source File -# Begin Source File - -SOURCE=..\st_stuff.c -# End Source File -# Begin Source File - -SOURCE=..\st_stuff.h -# End Source File -# Begin Source File - -SOURCE=..\y_inter.c -# End Source File -# Begin Source File - -SOURCE=..\y_inter.h -# End Source File -# End Group -# Begin Group "Hw_Hardware" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\hardware\hw_bsp.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_cache.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_data.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_defs.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_dll.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_draw.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_gl.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_glob.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_main.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_main.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_md2.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_md2.h -# End Source File -# Begin Source File - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\byteptr.h -# End Source File -# Begin Source File - -SOURCE=..\i_joy.h -# End Source File -# Begin Source File - -SOURCE=..\i_net.h -# End Source File -# Begin Source File - -SOURCE=..\i_sound.h -# End Source File -# Begin Source File - -SOURCE=..\i_system.h -# End Source File -# Begin Source File - -SOURCE=..\i_tcp.c -# End Source File -# Begin Source File - -SOURCE=..\i_tcp.h -# End Source File -# Begin Source File - -SOURCE=..\i_video.h -# End Source File -# Begin Source File - -SOURCE=..\keys.h -# End Source File -# Begin Source File - -SOURCE=..\mserv.c -# End Source File -# Begin Source File - -SOURCE=..\mserv.h -# End Source File -# End Group -# Begin Group "M_Misc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\m_argv.c -# End Source File -# Begin Source File - -SOURCE=..\m_argv.h -# End Source File -# Begin Source File - -SOURCE=..\m_bbox.c -# End Source File -# Begin Source File - -SOURCE=..\m_bbox.h -# End Source File -# Begin Source File - -SOURCE=..\m_cheat.c -# End Source File -# Begin Source File - -SOURCE=..\m_cheat.h -# End Source File -# Begin Source File - -SOURCE=..\m_dllist.h -# End Source File -# Begin Source File - -SOURCE=..\m_fixed.c -# End Source File -# Begin Source File - -SOURCE=..\m_fixed.h -# End Source File -# Begin Source File - -SOURCE=..\m_menu.c -# End Source File -# Begin Source File - -SOURCE=..\m_menu.h -# End Source File -# Begin Source File - -SOURCE=..\m_misc.c -# End Source File -# Begin Source File - -SOURCE=..\m_misc.h -# End Source File -# Begin Source File - -SOURCE=..\m_queue.c -# End Source File -# Begin Source File - -SOURCE=..\m_queue.h -# End Source File -# Begin Source File - -SOURCE=..\m_random.c -# End Source File -# Begin Source File - -SOURCE=..\m_random.h -# End Source File -# Begin Source File - -SOURCE=..\m_swap.h -# End Source File -# Begin Source File - -SOURCE=..\string.c -# End Source File -# End Group -# Begin Group "P_Play" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\info.c -# End Source File -# Begin Source File - -SOURCE=..\info.h -# End Source File -# Begin Source File - -SOURCE=..\p_ceilng.c -# End Source File -# Begin Source File - -SOURCE=..\p_enemy.c -# End Source File -# Begin Source File - -SOURCE=..\p_fab.c -# End Source File -# Begin Source File - -SOURCE=..\p_floor.c -# End Source File -# Begin Source File - -SOURCE=..\p_inter.c -# End Source File -# Begin Source File - -SOURCE=..\p_lights.c -# End Source File -# Begin Source File - -SOURCE=..\p_local.h -# End Source File -# Begin Source File - -SOURCE=..\p_map.c -# End Source File -# Begin Source File - -SOURCE=..\p_maputl.c -# End Source File -# Begin Source File - -SOURCE=..\p_maputl.h -# End Source File -# Begin Source File - -SOURCE=..\p_mobj.c -# End Source File -# Begin Source File - -SOURCE=..\p_mobj.h -# End Source File -# Begin Source File - -SOURCE=..\p_polyobj.c -# End Source File -# Begin Source File - -SOURCE=..\p_polyobj.h -# End Source File -# Begin Source File - -SOURCE=..\p_pspr.h -# End Source File -# Begin Source File - -SOURCE=..\p_saveg.c -# End Source File -# Begin Source File - -SOURCE=..\p_saveg.h -# End Source File -# Begin Source File - -SOURCE=..\p_setup.c -# End Source File -# Begin Source File - -SOURCE=..\p_setup.h -# End Source File -# Begin Source File - -SOURCE=..\p_sight.c -# End Source File -# Begin Source File - -SOURCE=..\p_spec.c -# End Source File -# Begin Source File - -SOURCE=..\p_spec.h -# End Source File -# Begin Source File - -SOURCE=..\p_telept.c -# End Source File -# Begin Source File - -SOURCE=..\p_tick.c -# End Source File -# Begin Source File - -SOURCE=..\p_tick.h -# End Source File -# Begin Source File - -SOURCE=..\p_user.c -# End Source File -# Begin Source File - -SOURCE=..\tables.c -# End Source File -# Begin Source File - -SOURCE=..\tables.h -# End Source File -# End Group -# Begin Group "R_Rend" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\r_bsp.c -# End Source File -# Begin Source File - -SOURCE=..\r_bsp.h -# End Source File -# Begin Source File - -SOURCE=..\r_data.c -# End Source File -# Begin Source File - -SOURCE=..\r_data.h -# End Source File -# Begin Source File - -SOURCE=..\r_defs.h -# End Source File -# Begin Source File - -SOURCE=..\r_draw.c -# End Source File -# Begin Source File - -SOURCE=..\r_draw.h -# End Source File -# Begin Source File - -SOURCE=..\r_draw8.c -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=..\r_local.h -# End Source File -# Begin Source File - -SOURCE=..\r_main.c -# End Source File -# Begin Source File - -SOURCE=..\r_main.h -# End Source File -# Begin Source File - -SOURCE=..\r_patch.c -# End Source File -# Begin Source File - -SOURCE=..\r_patch.h -# End Source File -# Begin Source File - -SOURCE=..\r_patchrotation.c -# End Source File -# Begin Source File - -SOURCE=..\r_patchrotation.h -# End Source File -# Begin Source File - -SOURCE=..\r_plane.c -# End Source File -# Begin Source File - -SOURCE=..\r_plane.h -# End Source File -# Begin Source File - -SOURCE=..\r_segs.c -# End Source File -# Begin Source File - -SOURCE=..\r_segs.h -# End Source File -# Begin Source File - -SOURCE=..\r_sky.c -# End Source File -# Begin Source File - -SOURCE=..\r_sky.h -# End Source File -# Begin Source File - -SOURCE=..\r_splats.c -# End Source File -# Begin Source File - -SOURCE=..\r_splats.h -# End Source File -# Begin Source File - -SOURCE=..\r_state.h -# End Source File -# Begin Source File - -SOURCE=..\r_things.c -# End Source File -# Begin Source File - -SOURCE=..\r_things.h -# End Source File -# Begin Source File - -SOURCE=..\screen.c -# End Source File -# Begin Source File - -SOURCE=..\screen.h -# End Source File -# Begin Source File - -SOURCE=..\v_video.c -# End Source File -# Begin Source File - -SOURCE=..\v_video.h -# End Source File -# End Group -# Begin Group "S_Sounds" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\s_sound.c -# End Source File -# Begin Source File - -SOURCE=..\s_sound.h -# End Source File -# Begin Source File - -SOURCE=..\sounds.c -# End Source File -# Begin Source File - -SOURCE=..\sounds.h -# End Source File -# End Group -# Begin Group "W_Wad" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\lzf.c -# End Source File -# Begin Source File - -SOURCE=..\lzf.h -# End Source File -# Begin Source File - -SOURCE=..\md5.c -# End Source File -# Begin Source File - -SOURCE=..\md5.h -# End Source File -# Begin Source File - -SOURCE=..\w_wad.c -# End Source File -# Begin Source File - -SOURCE=..\w_wad.h -# End Source File -# End Group -# Begin Group "Docs" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\doc\copying -# End Source File -# Begin Source File - -SOURCE=..\..\doc\faq.txt -# End Source File -# Begin Source File - -SOURCE=..\..\readme.txt -# End Source File -# Begin Source File - -SOURCE=..\..\doc\source.txt -# End Source File -# End Group -# Begin Source File - -SOURCE=..\win32\Srb2win.ico -# End Source File -# End Target -# End Project diff --git a/src/sdl/Srb2SDL.dsw b/src/sdl/Srb2SDL.dsw deleted file mode 100644 index 888d2fcf3..000000000 --- a/src/sdl/Srb2SDL.dsw +++ /dev/null @@ -1,62 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "Srb2SDL"=.\Srb2SDL.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libpng - End Project Dependency - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency -}}} - -############################################################################### - -Project: "libpng"="..\..\libs\libpng-src\projects\visualc6\libpng.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency -}}} - -############################################################################### - -Project: "zlib"=..\..\libs\zlib\projects\visualc6\zlib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/src/sdl/Srb2SDL.ico b/src/sdl/Srb2SDL.ico deleted file mode 100644 index 87bd2766e8e8ad6a86ca94ed207b402aafa151f9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 50558 zcmeIb2RxQ-{|9`Ly=P>r$S5RP*`Yy5l5CNXoshj}q)AFkfe(vXfp7;I#-~a9WbUCl%JdgQ1j^j7K#}x{NfxPx zjYF27%l%mM|F-sj9Q=h(`n@)ozclQhGOZQeP}z4B z_>=K(DDqEh|GUBe2Sfih7e7t{dJ29=|IPN-DX>N#`16gDfA1T*9yDG5D*e&r{$8u! zN}=odx7uGT1QG)7-)j1M-@dDAtqXr?{NEM&d#!#e^<7o}ziuBre}DCkroew|{C~Aw zbiV&9?W4!@ckllx{r_&e=yLyV`>;RPimsJ|Kj?b??tMc&=*YvyC zI;;Igf^}j8RsJjVM_2N#eyI0P_5Xih`)gD1jY5BHf(`2)&D8$xL@+YP;xs z8w!6{>Hq5X*B0S-Bv=~+SpDch{d@PnwC}$WAH4|w+3l}Q!FTHgy^j7p(r?*<-Z$S> z^}Bul^Avnn=zpMnbj0afFQ5}J9yAHQJ^%3=I>-9pzrBStTtANU_v!Wg-^%~f+Fz&4 z8Wp|~VLh7jUHX?_Hxyc@Hq8Puh9ZcLiAw&ga{j6ttGyv=HLAO zKixjM+vtA$)jPV}f9w8N+ePR5Z?%iA2VL)9y`#%*-Zv?*Nr6oYY*Jv80-F@rq`)Qx zHYu=4flUf*Qecw;n-tij!0P7pkEcNQx>E@kO^APy{`wk)`dZ+J^xS%F$X{lp#($Om zmK}vc^8btUch#*m@MF6B`|{Akf0h0|JJNxFk>1c8bl`s=O^fa#d_mg(F%6H_FXr|4 z|6iwn?9ZR3{}sJ|df$y69diH0{Qfao!`3(zfE&W{w zp!p3Q_+|QAg=@vXtME5zbdSHj{$t7hk^Y(iX?*=!?=3ooF7PeA`RyM|0pxeWq~PNL zALRGQes^vDPT21#v-y0J0{{0ZuxTl6Qecw;n-uti0)Ni({>b*rFGyK5pyk(hB*!m{ zu08zE%Kxjj(LMTQ5B_D((WR05&x6=F>@{%RPk+9z0pkZM{AcCAANfzsZg}vm58qMY zkH)`cMP_2-_3a(H4)hSv#nCyCa%jZfw>$C_o#Sf_Un}_Ul>b`yFWW}<;#(KidhmVw zYsLSx@OmZaDv%0(EDz~l3>@9~*Yc1DY3u)m@<@07O8aXa_(l7Fl>bV~pKizq)-wIN z|L9jgmHYkyI@9mk|32@pzW=T~0<4F3e=M9yLB3`nuBxAhvnJ^Qi6pVI$nd89(5j$d6rHMaR+lLDI*_(xOV zf8Igr0Sps*vF2W9{&w$1I2gFTksHKsR@U$C==)c1JoEVabJFhhJMM4qI7kM4+-~$8 z{{ICO${M%(clWRP(DkF+L*LQ;K=*Ie1E~)Ng1&bnY3M(CTu4S_oPXS*W>O^mKYJm5 zVm|ojBi-Bd69W}CuT2VUQs74l{G)~B=HUOk6!>v*t*3v}2E1IiqJI1fFMclayUb`q zY-5Q(&yAGX(8hNi`D)Jpar@S}Z=L!h`yaVBd_fmM7x%7a8PscS{E#2@dmj|Mg8DY*ho*k$ z`nQ1~?|zeiZ5$i^K(XKD-;nRS#LxM`i?rU!?{a|Z_ zU0-KlJ^#01BHz{ut`GJ*-^#ZF8*{Ih_$fP(3+Wwn>F4Z-`{R43;}2c>xxg>8Bff>T zCXg18FY6a1)}1RGb_=?RwGtb5+FI(D`xhw$FQDFUCB7!V*7wUB6#3!$WwyXHd1Ee0KchLXboyhskD2IMvJa-+rx+U8fo0N(%ndQE$U42Z@K?|)%qAiDX+ z_fX3p7h)THdk+;L?QOW=$+r$d_cpwQ#F{$1PJy)%pfJB50KEQM8X>{j5Watn==bZR zU!%~P5{*y*%D}a*Ja1H;kv5Re+67-WzFn*38+m{6a=o2@;NNvULZ}MTSG7uH(LJPjY10=O3WY;7Yq%pD3A_)rWyjo7kar+R>>3&UUkAm5Q^<6!Ti^P%s7DoTfl z3Frubu*63W%c>&Wc8%jAaa(QMyT&MB!AE4J)f{h+#9VSwYnfk_bolb(dR++_CPoF_ z84YYNk7tRIDQ6<(q_vKoeEq~FK{D?N^`v#VsUUEnEcRG(23|xA3A@)M-0E!65yIh}dJ1I{a zwtoI0sw#b&gp<|`=T#H1oHZGJRHz-T41y92D`Jm^;W>EDZoNb6MVP*9?}zU;#pl~l zlJ(Yd*Uj!ck~?IWgy|iqN~|t-zO&u#8X-7%>~o&JoLg4Q%o^+G6vpL_8-=_l)L_gZ zR(Ezw&ZtoK(WR18J9#o8D~l{uDW)Q7-#Ha^b)3Qu5^1tB8;09TyBJ7t&CZ`U$a`my zqsbby9iE`d`fa7z!=*?Zahy=<07Y~mdku;!(b=MIPD}(MS$%X zn|hWU3nP)E$&iAAqM_izxt;9n75aQqnXQ#30^8Zxu-U`$34AfP24g!F$9CRe!3(Q1 z!l2Z+gQtm`zF)F&YYz<;Mr359Mu9C`$;!g{_xUzkyjaS5tjo*=D=qU5Qpt^rjm?Mz zj_2i=%i@QX?n!7gL7`6EQ7m7W8OA_~)h9i9LU%NULOyA4{2SsESS1N~_82mZdOqnk zm3bPw+a8@IVNw)mM5Kc1IVj1V=Pxae z4O z;x>n`o%X37_#&`JLq~^^Oz!oy7THgyG{;b4qU!XkJgNo+WrUg(ZptBnE=)8uhq{7$ zGkismTIQz)-X&utCM8{siVD0q{3gfri83rz_VD9}Vzhbu71_O2(~`ZQZ7gY2{gjP>EcAmgg#K;a15_j*DH_CgLpqe%qB>qSg z>hm19q_KM|ZHPS4HhwJ0rSXI5PL@%Me&jpkyFb*0Tf`1u2@S0dAm7oDbN-a5;$FHC z6%MMq>FJdz3OB6#pHV|u*g0+Hg0EX!E6+TPFDZ%T%JC(n$xUMjA(ta3@!w)!$T%}I zlhtkxrM!=($iO=4?dvn`P}qZtPm>uJAnZ9(AWNW#A#m_~bx=!7i^d}(d>m4y%g_U< z6jjzedx)KinRspxiq%&R*(Kh&gEQOd%$u#bhlEkoXJNr9^Hrv5T3A?^he4$uD?2;R zx%yaNnFNpL{bpZ;L;K=Y(~!jqub)1Zy{X6!<1{ih-o9%W?%ut7vmG3S8IZAr&qvW`>Zo_&5jL9f(p@O{BPENQ9Jr?-8u6#=HB z%|o+)@xaATK0G>4;u8}wPi5-L$;n~s)E)8(e339Eb|oT$>S=W~uohqr-LUzgk4eS3 zRcFefC)T6yMIs_2rOB|8Q&W?)@+=Q4D$1IfalrzFrIMhY4y-F}o8IZufr*LRZy#_V zxp?tngIP|ua3~i$g|hzRc3_2!Zbs+M8J2lqz>93Ax7&Tn_U!6i94oy7MTBFNUcY$* z`~i4kzBbP%GBpk=;A6l)24AO9`VnpOIxtp5nIs<~1C7Smus%;L<~)_m=~??ki+4hO zE+r&L;HZD4=knt0!St5xtgM~{g-27oV5KT?#tuN=poc>@qo*ygfYtg}N>ls4H1=*D zN+x~>9578y)qthbR+`Mjnv9%od#$VoQ0ue(0dqlm;M?U>V(@+URt0ZX!XZ=GcfgrX z3X0Y55Eo~x^dt6$SyxRn4NmWRyEcgMPZIc;?I?7a5%!>X89FQn==(LL59!-8d2e*Z?&%OEmcZAXm2k_K}mUBTl?~bfmgs)PW1F&VuDWb@Q}2(w-3I} z;XY$%cwAREH0FRqB1op=$B(OUMXHtI6482GzDz_HnF@PxH&*==5LwNn_M(T@Gj<-H z&;_346ILKe&YnFx?Vz4cee&eV{Ke72#yqPo_1T3)$MZI?ukX={}6*J+4Nn1Mv`wlF!2A1-9| z_f#sSQmUs%iZU{i;1Zuy=b(BGYfA045Xi{*Mw76}NbDTVjt^1fzWrC)2<2&eo?}uL zc7#?1(==U?dg3sqBzcO1Dj+Dx zOE>e7sw%~3(Uj6|-6Go6xf;nVi+6(N9Z#s^+*d?&ok#Y+cj$6O<~3W>BAu>So2RDC zbBhhILbGE6d9`;^u*HR}I-fQq9872)q9Y2%^aP$a)>*vQeZ@tzsOM5FiSI2feJXrD z!tT}akDdz0I%=5R8DN?ZD=XJym(L`3UE81m6(>6c^P*UY(hQo%MoJslC}M9dOmCJNX4ZAF~E zd~PqZWnDe=gpI6mt|=`2-aXiA?~Kgb)q&H$d7z^}(}(iV%&0!4=jsc3onXKSv#>Rb z{a9zn<8$@Ba}#}t_Ve*oOfZwUQ$t#bR8))PVtc)b-*ziK7-dJHgTH2myq%q$)U$p< ztD*@U>bYt!Wrkcu3|YLAFGjF)i8W3G6BmIVZ^>_|EdBEK{7ng0(Zs|=kRXVvcmMQb z99WC_F7y1M%#xuXgGhm3@<)#n*oo?t9eeZXlUbZA8;I=`iQrI=IwLdv#)8G?5mH#) z>Eo1{m*Q_8aNuEb?8YEs6s2NzU)sAeohr#HDoWSb*qFb%vN+LqMKUoy9tCm$8Hs!- zL;C~6*PtxTYo9ylM`W5ed5Lg>T42`99N&kVd>CtbCV{}qFd*r*51c_oa&fY#&K^0E#h1G=t64i>R|84 z+t}>I0sb`*=gySZ<#yoc(WB#yhnRcLNiJ@CbN_VngNnGQsG;!jEoFYh^jV;~pd#;% zL_|b%$2fE*jHMj+Rej6vOhF)OBe3KE~m04-S01FTPJ+U7l03O%Wq^kYI4*!6|=+pMc=iaeB&s1cu?5zrZ zcyU<$bNgdlA_CJt2N4>v7+m z{8uA*K?w7RJb3V+`fIhMXsF+y)7-Ujt*vPSikv4y>mhYhlnM2G4LgSd=mL7-9R=$2bP^ zek^6d%eU^q1Y-#%EJS$6!x^XI66sLM?M6+XMU2w8O}ptr`~=m8W_fM|%NL2nD7BgA z;#~DG8jX?d4D8L=$zU|ZXWHE~hZ?G8kYzcXzn5HQvY_gWXS=yPEN>#5gIh4dV$)L= z-WEFxDY8>ii-yQ=Db`i4KSZ@ngt@?-f`u*Q%Z}ML$75U4^d`kp#ynU3cqk7uV3mVf z`sB&2H<3!INx|WCT|(u}0|`p9^C%Z`x5=`LqKu%98a&hpi;F`RVq$i71bYgLI3+p1 zX&-yBOw}Sb&UGcg6gFPK- z0ou_<3fucnaYfp>N(B0{6c8jIk5HA4h>d&CJ0E*H?z1n)jpu0;C%GaATheK8i0Kg3 zQ7WlXpuJG#tvVfdne`;LYy_rBXfgBM=5ug!PdTM@0qeec^Jd#8lgdz^RBA8ti~0e5 z8JKghSq=E3vd+~ry@(d#jX&EfOd{_5<*87Yi#M=;`vBcTNsandLDY92Jov&zv+6un zj2j}~my^>#7a(JPWg+eE-EpVXUGf3l&znwCyo-yC4FzioH@mT}-*&fN34`;O&qI8} zA3Rq{j%hj-X!C%AlsoUVbLJ)}bRhlt`S}})ogI?z+}X~>6|}(h_Llt%`iP@!U{$A4 zm>ePJlR;Ve#tmEoq3F-lnxa5cG*L}oTU(2FxByX*32Aur-)5U)h)6a(d1$Vvc=^;! zj{V46!N`{;0=+%{%+)va+yeV*t|aB>=SwHEMp<^0x=X4*&<+F*6O?`|yTdrBw6rwc zyeO4jbAsnQCcdyjAD4P*O3Og!qjP!CV)hV(sgaRUcXzqBMzK?l-fb<0nw}1at}4() z_FkGadfn18-+x;^iM-fpM&<^O4jD7^70@<87X;-#F*z9v{0Q*4B9!rfSZB>pb82I$ z`>Ju~$>Ya8Asgh$y?0;SX}SyqxlIkD!(4Lm%9p&-o}5-)!oxD;oM0zz0fzZyt9vWC zpT%Y4arJPkjwg|Ka_tW}If-89(Fp=c*i%U=X?`;IG$-sGgv;F)x!@w9F6!Tzs?4l- zO8_6?x}BE>7`01Wwxue^RhN6?PSm@vP|^#Um%Xzp4LQVg$>+|C(e}rwH5W3q3!2gw z7M91{yY4M29XnR_Hs`$SD^8Z2rca+fWx34T4$ds7N0!q&&5j;(J-CM$mzI&riazqC zapibVWwGs&ULKjPxCZDT^Bv2Dz-%*T`Imcb=YW_Am%~NIWQ-p$| z;`EbO@VK|RKqR!%@QS$nz=~F3d+PLA!Ds_MS{E*VUhpzC+6vxS4QrI1$YtH5nTrn%Sz1A8!Lg;$T;at1FlHfraUz zzLT!N2Q!a3Jj(wFYN_etvO?#R;I}bXm>r{Q5&l2cz0FOceq6BsDq0Mm4P`bmuJ_=Wb!i2*_8@9GkLEQ8JZrfd;!lRea>LRj((ncqh+=K{OH)bJW?2$T`TLO zs6fq(J2qR5R!b>&DLIN=X)&vUZSiiJ!BeY#(w9aTQI7cc?JL$KdrBpRTlp?FPVDuy zYZSM|owvg7Fq_#AtKdzh-j%(E)!B3Jz}Z8v&-lf-a7^U2YhKW|-iaFKnnbza@wvV$ zJ9h1=8Edzzzb(?t_4r-CZO_$1OrD_ZQE*Fj4%>+q&GiN|)g!vxnc6T`OK;a(N#|Q1 zfb=gq`&#tA9LWoo_HRb#=+VM`G*T?z#g zsjqE4{ift2h_w;xGI>P1$dR0ljm^@%3$_rlZNM$U6&X}bZO!1{)~0cpZa+czE@gS( z*hAO#z=8<4a-{}#mCc7*a*f^Bb34Q=_fM9%E;g~y>VZA)IMZ_KxQ-6-jpx3}$vbI@ za6S>T;>#g=P(b2hSrpWC23DQpcsVXPBjYg#S&{i}C^e3NobDSC*VdpQqfwTI7Vt%zc%9*n1 z*6rJu-If;;9L73nMeR5iX2-7h_+Wv;39|A`eXKa5(1FnyYSUNEDk8ECR8V2t4|pJK z#~;TngZmo;Se_S4Joq#bM|4a2spDE&?{;F~4HeLH?@?6(f0Z-a`Ng^iWx%0J7g{pO zz=U_`un0spi{o%cURXo~R^(A^5XCp1V}qI#J76a>{n646kBK#~(Re`w(1aV7J}mGmr^4)s`kx(a;Ehm6&k%F5dk7Jow^> zUAFFgN9L)a_LM(3Bt#B45{TO{Snv;Y3i+$Lu1-{4&9NI&eSe`|T%*KA1Y!QH;^G}v z{f>hP{#lo%jF%Q#OZ}8my}>54$m{T1osU~Bw{l<9B4Q9m?2FoG&nkd(`hml$H`9HY z8!>&RM?2`j>n4ybs50Csxw>?LikjL0h`HxYWMz*O5Q>h0_ob99qO6NC#f67&DbQ9r zM_el$$H2?zui&e8t0mwCPgoi2wMbK7otBx4b-Uu`QXasHL(G<5bJUJnNA4xC@}Is= zJ7M$X^XdEA1&`Y2KfeL*fbYn=Jj0#}-+;hC={(Dh@%D3ZJs>J+1B%O4FBZZ)wysbwfb^M~s6#Z(0k-N`_lRtU8O@KeXMtMF%dU zawGn769Ji|MsQb3!@o2&nFN&vXZBSE$?%c@IjPW7X=;2?iiZ^xD#29fa2l>tQm}wr zPQ|uY$z_W!Nr8n5oGY1o0<$XGsw5Ds)g1>8(1)`htLT4z-{APji&me4#0^LS7Q@8l7m{rHtt-CcE%w2T~Y^&0zKqBrJ`GW9pTU&mZ z5;ZPr#-_u1Pv2W9wWU;IPHGLUg319a7ARraDo7@&taVe;UE&0aaT{z@EyK2AxeWC_ zM1!dgp+_t{Dk`dOF#Zsp0$L^LS61<0rb|=1b*mF(ef%`+O)6nB!LV)Hwqv31VA{@{ zIRnnHTSVu@@NF*;#7|hIta4KkAYR-VCzzvx;wxac<)y_2>`-mCLJn_JP&*u(XcH$ivpiK5e1d% zOx-m$M)u`XV01mc$c88Lc!nC};+Oo2iV7UU*ktm(=D!kev^7a$C0}#&KJr11|vqf%WpjMMU(B*jreEhG6vgA~F#y z?CjNj6Cfjxg{D1tAU`|W5uMyhl0B|qNCwsuyVC8pWOI-oz@IJd?SsynVG^yMDtiZ%2x1Ac!Mim)iN(2}kB776y|9MX-uZ&nL*%@|sTGsgOI42tXVXhJa`x zE7hq6X0e&!#e>6v{@dJjmX(#BXkFt7va7iRafGH~Mm#XCr9fxX85tr(eE;^J+c1us zyY1KK$eHFr=AB#_uZ0$6XTNs$9Ye_~@~K!@>=6z<2+9%Sy##A30myVT z<=W`Nb3F0G<7CoLPGo`gS$=3|-(wa$jVyf(hy(!Rxf&fk+;R~t3t+oA;dMSwpFR!a zpNig*JXY~;LJ|a%{b$fA72U{ZH@D^pp?#ek_yZRqRkYp1olK$`?y1t20)n~w~< zJTgsJW0P;|CP}Z1b@k>4x7!?@1j4H6Eo4<%&)vDXxcKY_RbIr3)5|9{_T{^Rk}&r% z+Dc!5E}_M2NN@yYlAP2$B$R%;O-Y5U~qE9%^dpHn56zZzVh< zHilh+cLGbg42aZiEzD<7fd%GG4@et&x49l%2!k|F>wyS5BC`*f7GY}g?eAIz~fr!K>VG_d&uJWp*#KA3eylgMe9-iR7x}x#$ z4EAOD9f%sb|NI+)LUDR>6Y!#e!l)Q4R!|&7uOg$4;do#r^Zxy(6~2U^K!v2nIuRrt zx>7ybQJ9ui6Tkp$ST;{i0jv~6n+BB!LZEqVTazCXf=-6Pd)}Emx7p(1Z3FSR?abYF2_N~-Dddp6E*z6XV~Lj_##uxnY{s>TUf(@<@iZt{FK z1=>swZUp;fR5AEy%b!~2ov5+BTS2c5XYL>4i7-d`AKo04T=aJ!t_lVR9E z>1j>tWV`iRqz@y$F?5cc=md&L9t-Ikc{v|;nZ7KaBJxNK_ls{G_2UE@dad^#v)3Fi#nDagwv>gh2vKn*O^vP=K6MQX8SMbeV`Nm{ zXa0V$FLkR_f(9H8Ilsc>6J_!=;ZBH9_Bj2^fnBb+!R&ujZ1utNKmjOtv5~ooK6(GbKK^xF6cA^G>1ajM2n4$K-vPD*KH6E*QXk~h4Nf0=80q22L zD2&0nn_3Fgs<7+V{Xiv#kTL{LLEGVKU zgo;<;fY=@c1(~Avb}FYB`y5Da2B%Ub#5*2BaDs@I&tteLg>Z6m5>aaqooQ~QuXOy` zUc7v(VNcEdgL|Y;p;oqYa}xqLL!AAO9zC+|slY}Y!idCib#=`OuEAr45G0ng2e^BC zD*cbEsbL+bx*8X!?7q+9ZFVo7CU=@C1kL44=j}M$d;w3k-Be`|lxqF3FTEwGqCy6& zlwJtlqdZdGT-}{%LddIqDn&iBH1Iyy7I^7k;q2InPe>Sl@7}$Zn%w;-telOr&IFGZwW=BDn@$vD? zc`$c)(emk|!0p@AB;!6uzLg;U!nv_il>D?7Y#?=GL@y$X$y+BvkaEGB76m4E1%v?t zK~(20UPfJzk;7rAS;yaiU_H|iFMU(MltR#b<%T{@#xWmXY(AS_S(k;ORE;Ngrdh!t z32JYbs;B#c$pD%r$WU+Xd%2Wbw@QJx^MP)0P~qqkLOu88{SX8jbg~5G&y<*BY>h9o z18(8n%Vga%t$L}e??&vwIdTsLQU_)i#P4gfi&;T~LKQL?5RItxCq+#4oe2J z#>Vc%w#cKt60Qqa1!|t2z>kt3j#@P`pj;pG_7xkx7;7d<%+a8-S=TU|aMbuZs=nRr z;I@xj{@}IWb0x1)EW5n@*LdIg7F5!ld)ZvNS~1+kvs&q$!AX)7GtnQFn`+40_Rgcg z``7GAu_4A|bo|3^)AS1sjGnf%PrOCQi<2^D7(P=wGd8vl{5jK(ri>8>y)gQz66q_F zQTx-LH}{O=GH0wxw8`P&dyQ1h%4QWW)+o{JpMP-z$K1+b>knLiosm<9b&$Ll!SU=q zfLolBBuc)`Vn>^jn3c`I=PhqX$1mXinib!)@0iTq@qms9>qQ_ftxQ$m0HLQw#{l7P zc>NmtzG)wWZS9|WwsI7&X4@9|xgJx_%mZ(m`^HFqBb%fhFc-Y?NDhA7ZG?qs72{lP z|9KwsH~k5-Q5TS>5?|bcNcZ6u-%)*~r{hm=P&sl4h4rHR z2IpWUGk@OBR}n#@=kl=b+{=ry2_DQD{Hj!iEqUx|OjbBxVLBIO zI)XLa-L(60sv+k!WFg2b1ZV`ClLaD!ni*RGAJyeDMGQ`C6iO*IJXVW6e7{M+hoTR> z*6BUhR$I*W1KR=H7NX&V;Kl)E6MPOJT%oqu0SL8-rvlKaAsn2@fW-hq09+=S1GWWZ zl$73}g|e(;63ud+oW5|H3`y~o7^ksi3ye4bfGIg81qptm02%`SfHwkX z1vYGe{zA~QB+ClKOq&8!qfHr`2 zq1J3_fY7L`GF|M^lteEGP!7!mZU>}=ZZrp*t+E%3RGL~7&K^8W0Xkx6rB{m8Z1xU8%w++DTjBcr>OzV?y!v(j{n1jU}Zx6QE82UwPvXcSUx@YXPP%gymuLzW z!kz?K0C56%tg3$=_m1@@0@MxDoL~(HOhOQI7e9~1-VhB=`MBln_cfVVg>hj@Ip(sTTF0RD0Eb0** zmZ>9U#*Y*3-zNe@7C0;uuNxQ!Og0bM2|J8xdmAJa+Hbw*lR~LNFmx3_ErOQs0}%HR zaS1p85px;zry=1}fKfhmDygW50piKl1=@%&9qew1e1PKWf9uvQoPmiu+ zm?Ph{Yu5nzb+=%2NY3xTp5j`oj+ld75wM)WiS-na4hk8O)tNel_F$r9J6^G|v6)*K z&aBLx#jSXX85XKXe~_*Ye7V73HC+<(uk7)Ff9>Yg;Bo?_An`*#Z}r^V)cFCwUvgw2dJIE($(cLT_Ip2$cXhJC^EOQ zI5q*1P!(JqKECLeh|dME)9u|;;2{G?(QyOT`a2U8Z{J|GIBG5&V{r?C4)s9P%B1%k z3;2B#OG-M^hmYOl^ITyL6?fI(Kv@AUY?||Q04$o5C#gY+SAor*ekv2NmKZQf*gc5z z-F3FZAJ%m*xWe1AO;30ai7O+969P3=SKkU)F#N~upHE%_S!+`-J_`tRLx@b;-Q&Gk zH2IACrjV7ccl}|J(z#y3PseaE&$BC>qo}pkZ_6@Za(93YpGkF2U0pr+{OUGFpO1b3 ziSLC_IQZ60oA(2U1t=;K=!2m9)g6b<05miI(iA(0BOfqXAfSG){Q@{;A+ApfxV*}d zysptmN)`5S16cEjjfcdWvxk_LUJ~*aH6%Y69v-Hjo_-pvyt2#KS)p=^!yO3`KO)@Z zR@Qwiebpi7`5BMu0v2YlDJA&SY_4hZ9phuG`rP_{J|BGmz6k&yyV3UrRhP`IAbRMO zOG!a7j(9x)ym9yL-7*q%N?}2QH1Bl6O&fv+`coA4*h&RR%Jhywe zZt7c)cbBtYTuGH&4s_$C)*VXUU(q$E(Or5Ja1My91wGq>9_o#M_3S!;JOP|QGCbkl z)_9Eqa8vk)J;H!rH<~;Jpb!Wt;6mVm8f+Z8tD43K;6SnE>1LR`J+bb9_nQNp@!pG{ z)ZA%0c)=-{pD_hEH^HI#Kt3URRIWOPfW6mN8k$1aFM#uy1DfE2<&vXRxS~U@t3i@TwDYY@ZGb9c^omNur&aX+v9MKHGBFR2?k2Pv*?nguO5{gLM4d~Qk#a{=`(gLnob&E zj_;7aJZ?sCcaPmr6ZZ2PyobOc8Wa>X-W$v-I4%ha6L1yt_D8->QPBrlVVi5kyiXQK z?#OWGM&SwGvtpF zTOhkR?qGe39up8Mr4XPPxwcCR*3XC9t4II`0bYX*jUX^o(py0E0LXdm$i>p60?6Gf z15u(ExghpBJkyp_yluZ374#E9al*7p0Xzl-9s()^N5H@rM^JCTC4+^)Q^HV;YugK6uROBjR47d}v?d140WV4saoGkqSFabASV$HtP`_dnwkv!g|n8 ze`RT2BhQji(7eq90i^=-tjaQ|w4NS3eqX0Bx9%Zm3^319fM^0p<~!E#TZ%XN5{@u3 zi`ZfTHqsK?-zC>+<`etly-jH{X{updxRZsTT0w9cROODo#}7cxKzQx=$&=W@RlPPZ z-2rxO{Nko(tDZX}Z|M?0zzFFaSHy|2D}1xGJGzH3uGXiVf0?1qjUX z;Do3=xfUWoU|O3cP!jv%U^q^?Y8p#WUM~T7$^l3kc>n%x1U%<`G#sDr^h~xlSKnD}>^B9=NF?if0?DU8O2el_}dUj`Ts1I*= zmeJ7cPDucZC!Vm7dag1F@!95ITGn`x@lANPSoYaU1pvcKdTg^K#FL3VXM#i;jZek0zKGVeH zfUJD&2kZ&iviM|GQf|srTR`*GLrpJzaFQ(mWi=6S)NqsokXwjn3ZUJlm?Z9q_Zy^s z?~AB?92^`{XU=Q~>|^ll+qZF)q&NYj&RDU9RLlcB;NYXCJ8F@miI_=KX>jTXVAJ3m zLm<+^1W}lH2AZmvJHNyUY=<2Hcya`73-F}G3-6K#!b6!;>bR4~0##W`*<@t5_W%|Y z&R>BL4TOr}zz&@^3m)dHSn*)@m8rNv07WBEepxxWp69%!Payzp60v<-v(wR7j3uFx zxDSFX#exs%0w^ws#t_3OZ>j|X!jg_9?&@Aq{EX|*`(c^_;KWM==LrahH{EY_g~LD^ z;1Gws1q)Y>`WhT%2vWU;Ukg|+h$l>&34RFXEs+A$7>IumszhKkEfadNG?>fCPM8YN z#i$B$9x z$lxr{u@7)CDUVjKp%JviD!}O@>lQ)x!9g=nqO9V{WRD{VP-IPcd0`?vJ|!iE*y|ox zjG(@IBce@I^lkddaE0r;%RwxFGYimm2$~g87_b3g{obO7Z3WbV5cU~BVI#3A#z#3j zyL*yR6}PS%V+EYnK6Pr~23tjEg$={C@Nh&bA;@^GT=R0kts=??2whgtjsRHz+(V}@ zl2Zk2ojy>m&QF|noVu^M@DfxuSDrWk*TK3OGM7nOvI+<=s%I(f`rGB zlLrU=NfO{pOqctrc&GE2I0*3FI!^>R`X_fW)EIzw(9&?KnA|Ka(Q;G>AVg*}1og0# zi>6*3u*__odvckqG8#u6CPUz{63>kt0AB~~hT(yBffu4y0Tv9H-_8B!)m5HR;UNGH zU~xI^6xOMa#hTT9FB@ao{RP zLcT~u5(1#)d_AARr2;nAhn5HVo;$_GW7vr;>W*@AaFp$<7weln{0am~vRrc0AayXm3(g+}+w zd}Uhurt(S=uRj5}^8rHH2j?090OTf;3L6--+RJdn=~4^@_xnq*WHrW^k2t1d0ktVU zC(5L#8jQTnaRkrpvTX?v4y`>ja;<9jMiFV^Fm+rz!rV&l&w;OC=uavw#$t`12 zM=G@fNI_h{13*OrXF`%6@&j5OjxEZ|A1NfhEvR+lnsj1J^PF z*r5!99s9JZDgpW`5T6X}A9eu3;t@AAg#79D94_kYycQARgOC_3Mm^V=$W!#1hokrm zFgqRlh!J10MvfVE2Z{JKVe4*`?S%^%0v(5wMMQ5U36ROYsAj=(D8$>}nH0Ko5;n-u zqcRY11M#MVrJI z58E*mxL@OydQ!Um5^vBM?^)EX4>Tq&Vu5@SZb}uIDXozocZ9|IyC_#g)!8IVAn_z3 zP$D5x4Eh(xo;_7?2!PHA~V{HoMGBK#06QLw<^ zV9{~sot`-O2iXb3eRraCQ5dWDvE@%N-O#d;HSY?_xkl~u)`tJ#SwY*o?7jt z+J|%@I1p~vB-rU33P5G@Fi1RjdBZZcZb~dBXa|8;a?dq4Wh~WORvtw+-0G*qP6o(I zUp0zvnhhEFLeFigd;pKKUka3f>Gw^BfbwMxucP~1(>5m*VnD$1V&dZELltU)Qsmcn zpY{Td!3r@WP@mOQJhTqX%O5%f2i;W5_eCj!kO#75V}!>Z0M8DDZ3RN8>+)!5X#Byn zKS*WOzvXUPnlu<~BO`%i;j%XcqlqENPiZOpNmII?H+F4ZhmXGW$Nly+8+aduyPqo^*M;4RxY1Gp8*0I3V!b48Mxm~cJ z8#47IGZQ6t$jy1;siUN((kkhMF!}v%2sXgF1l({u90Dr0N+Hw$qz(kTVS`+~bt?## zM+F>b22X*B0DOrD^X2RLAP}sp$SLK1+eRNo@BzZ96*wn>9Lj@mA2GNf1o<-YWl>`V z15Ds>=>_Y%5{_OipSED6%h3!0A42zo!cntvku+{Ab!UETGU>T9_~5Vv{tx(%?Yz9C zaI1b6$*m<8dNUj92l)mdG9V_bAb{E+u-DO&MN8n8h`R&AY;&NdXW8`0M_j+&GfVxaMv~#>@g!CAO8H<7mLn9ssPD+$Uu*Tm_>U z!D+e`l&Ggy0rV&Y@i@SUlbzp1!l7jVt`p1X_>(e+l1j{>AYSF*%mZ8y)Jp)CQIyWV zw0gV0@yMYHbHT!xk0H~hl76^FCs9p)b}LJlN_F(u!x0zf!-o%P_Zbs`A4NX%gr;T? zkfk{UIaq?A%HF@%&LhbN5*o~WYPl(T@m_0Tj}JXWuX0+w>V4vR!ZE{)FYk>~bmJwg zu>n#b$~*!9`$SX-uqZfzgF=B}S{8@+0m6ZWgPMb!4*)``sj2CMsb2f?}JWrTrWdiiNYe0B<#fBS(%9-bGH9j*5V` z561?fi(~zR0bv)hK*tic>BWNZq>gt3!&ROoDJ&lBFE|d*eLI%#Osv9r{awnjPr-z8 z0F?;QBj5=7y{>0$;3EW}H4=>V#APaj2qw6yE(1_L30x?1gGpBai2_{L2h8$?ktd8% zU=P4BphHliA<|>d%h`QBrP%4d#wO>Ld4jeh2vUHr&8Nw(%JJMVtnk5ignEJFVniw8 zz&TB;(&epC@+snx0<`R_vDT5p$T=>sPVz@`-(>+H&iG3nraGl=!&W&JRaGxQ>?J`M z89D9;=UhM4T*Cm-2k{I#5F!Ym=i?p3qC!sFx1PU91wXuPoa@wNlvV+V*N72dxK&esI6Q75r>29pVu;nG$0qinIebn z0F4GgB*Z_erKR8?cI|n;oge&?M&o%@ycZo&06*)&>u}y4IpBLm{0prg2_r$|(H1Ug zE?uRAOHj$GY8>s)q0Bx*d5 zN&UizV%9*iD|Jbz)P=JoInF~SS#JsX%hmA`2q<0Phf5xMlj9R4u!Wb1-0WVYQIBSo z$>+q;^V_aC2$i>!?RrnO#S`CkvCK@wYw+$fFMQ{5{r&aU3h@!xl=f@CszQ5Ne`*y& Z?Q_Yq4~B`=@JlbKBXUZz4`lSc{vS}T*p2`I diff --git a/src/sdl/Srb2SDL.props b/src/sdl/Srb2SDL.props deleted file mode 100644 index 8c4799f20..000000000 --- a/src/sdl/Srb2SDL.props +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - HAVE_ZLIB;HAVE_LIBGME;USE_WGL_SWAP;HAVE_SDL;HWRENDER;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) - - USE_WGL_SWAP;HAVE_SDL;HWRENDER;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) - - - - diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 3ecef0b9f..4e9de24c2 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -691,7 +691,7 @@ void I_OutputMsg(const char *fmt, ...) // // I_GetKey // -INT32 I_GetKey (void) +INT32 I_GetKey(void) { // Warning: I_GetKey empties the event queue till next keypress event_t *ev; From 96484c94db5c7f338e6a3879474cd7883961b5a5 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 9 Jul 2026 06:43:57 +0200 Subject: [PATCH 492/589] fix & cleanup hw_bsp this basically brings it to the latest state from Doom-Legacy before the big refactor (which i had previously ported and tested as well) + some extra stuff from it sadly this does not seem to fix plane holes, but its a bit cleaner and more accurate in some places while the big refactor did fix issues with plane holes, it also introduced a few new issues, like z-fighting sneaker panels and significantly longer loading times may as well just wait at this point for what (or rather if) RR will be doing --- src/hardware/hw_bsp.c | 535 +++++++++++++++++++++------------------ src/hardware/hw_glob.h | 2 +- src/hardware/hw_main.cpp | 4 +- src/p_setup.c | 2 +- src/p_setup.h | 1 + 5 files changed, 297 insertions(+), 247 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 77f66d308..f53153ea9 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -12,20 +12,21 @@ /// \brief convert SRB2 map #include "../doomdef.h" -#include "../doomstat.h" + #ifdef HWRENDER + #include "hw_main.h" #include "hw_glob.h" -#include "../r_local.h" #include "../z_zone.h" + +#ifdef HWR_LOADING_SCREEN #include "../console.h" -#include "../v_video.h" #include "../m_menu.h" -#include "../i_system.h" -#include "../m_argv.h" -#include "../i_video.h" -#include "../w_wad.h" #include "../p_setup.h" // levelfadecol +#include "../i_video.h" +#endif + +//#define DEBUG_HWBSP // -------------------------------------------------------------------------- // This is global data for planes rendering @@ -33,19 +34,20 @@ extrasubsector_t *extrasubsectors = NULL; -// newsubsectors are subsectors without segs, added for the plane polygons -#define NEWSUBSECTORS 50 -static size_t totsubsectors; +// extra subsectors are subsectors without segs, added for the plane polygons +#define NUM_EXTRA_SUBSECTORS 50 +static size_t num_alloc_extra_subsector; #ifdef PARANOIA -size_t addsubsector; +size_t num_extra_subsector; #else -static size_t addsubsector; +static size_t num_extra_subsector; #endif -typedef struct -{ +typedef struct { float x, y; float dx, dy; + polyvertex_t divpt; + float divfrac; } fdivline_t; // when loading the map, this is set to true if portals are found. @@ -53,7 +55,7 @@ typedef struct boolean gl_maphasportals = false; // Determine on mapload if current map has any Horizonlines present -// so we can avoid rather hot checks in HWR_Subsector +// avoids doing a bunch of work during rendering boolean gl_maphashorizonlines = false; // ========================================================================== @@ -80,26 +82,25 @@ static poly_t *HWR_AllocPoly(INT32 numpts) return p; } -/// \todo polygons should be freed in reverse order for efficiency, +/// TODO: polygons should be freed in reverse order for efficiency, /// for now don't free because it doesn't free in reverse order static void HWR_FreePoly(poly_t *poly) { Z_Free(poly); } -// Return interception along bsp line, +// Return interception along bsp line (partline), // with the polygon segment -// -static float bspfrac; -static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, - polyvertex_t *v2) + +// Return the division in partline div fields. +// divfrac = how far along partline vector is crossing pt +static boolean fracdivline(fdivline_t *partline, polyvertex_t *v1, polyvertex_t *v2) { - static polyvertex_t pt; - double frac; - double num; - double den; - double v1x, v1y, v1dx, v1dy; - double v2x, v2y, v2dx, v2dy; + double frac1, frac2; + double num; // numerator + double den; // denominator + double v1x, v1y, v1dx, v1dy; // polygon side vector, v1->v2 + double v3x, v3y, v3dx, v3dy; // partline vector // a segment of a polygon v1x = v1->x; @@ -108,111 +109,118 @@ static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, v1dy = v2->y - v1->y; // the bsp partition line - v2x = bsp->x; - v2y = bsp->y; - v2dx = bsp->dx; - v2dy = bsp->dy; + v3x = partline->x; + v3y = partline->y; + v3dx = partline->dx; + v3dy = partline->dy; - den = v2dy*v1dx - v2dx*v1dy; + den = v3dy*v1dx - v3dx*v1dy; - if (fabsf((float)den) < 1.0E-36f) // avoid checking exactly for 0.0 - return NULL; // parallel + if (fabs(den) < 1.0E-36) // avoid check of float for exact 0 + return false; // partline and polygon side are effectively parallel // first check the frac along the polygon segment, // (do not accept hit with the extensions) - num = (v2x - v1x)*v2dy + (v1y - v2y)*v2dx; - frac = num / den; + num = (v3x - v1x)*v3dy + (v1y - v3y)*v3dx; + frac1 = num / den; - if (frac < 0.0l || frac > 1.0l) - return NULL; + // 0= cross at v1, 1.0= cross at v2 + if (frac1 < 0.0 || frac1 > 1.0) // double + return false; // not within the polygon side // now get the frac along the BSP line // which is useful to determine what is left, what is right - num = (v2x - v1x)*v1dy + (v1y - v2y)*v1dx; - frac = num / den; - bspfrac = (float)frac; + num = (v3x - v1x)*v1dy + (v1y - v3y)*v1dx; + frac2 = num / den; - // find the interception point along the partition line - pt.x = (float)(v2x + v2dx*frac); - pt.y = (float)(v2y + v2dy*frac); + partline->divfrac = frac2; // how far along partline vector - return &pt; + // [WDJ] find the interception point along the segment. + // It should be slightly more accurate because it is always closer to the + // crossing point than arbitrary positions on the partition line. + partline->divpt.x = v1x + v1dx*frac1; + partline->divpt.y = v1y + v1dy*frac1; + + return true; } +// BOOMEDIT.WAD has a vertex error of .21 #define DIVLINE_VERTEX_DIFF 0.45f // if two vertice coords have a x and/or y difference // of less or equal than 1 FRACUNIT, they are considered the same // point. Note: hardcoded value, 1.0f could be anything else. -static boolean SameVertice (polyvertex_t *p1, polyvertex_t *p2) +static boolean SameVertex(polyvertex_t *p1, polyvertex_t *p2) { - if (fabsf( p2->x - p1->x ) > DIVLINE_VERTEX_DIFF) + if (fabsf(p2->x - p1->x) > DIVLINE_VERTEX_DIFF) return false; - if (fabsf( p2->y - p1->y ) > DIVLINE_VERTEX_DIFF) + if (fabsf(p2->y - p1->y) > DIVLINE_VERTEX_DIFF) return false; // p1 and p2 are considered the same vertex return true; } - // split a _CONVEX_ polygon in two convex polygons // outputs: // frontpoly : polygon on right side of bsp line // backpoly : polygon on left side // -static void SplitPoly (fdivline_t *bsp, //splitting parametric line - poly_t *poly, //the convex poly we split - poly_t **frontpoly, //return one poly here - poly_t **backpoly) //return the other here +// Called from: WalkBSPNode +static void SplitPoly (fdivline_t *dlnp, // splitting parametric line + poly_t *poly, // the convex poly we split + poly_t **frontpoly, // return one poly here + poly_t **backpoly) // return the other here { INT32 i, j; polyvertex_t *pv; - INT32 ps = -1, pe = -1; - INT32 nptfront, nptback; + INT32 ps, pe; // poly start, end + INT32 ps_online, pe_online; + INT32 nptfront, nptback; polyvertex_t vs = {}; polyvertex_t ve = {}; polyvertex_t lastpv = {}; - float fracs = 0.0f, frace = 0.0f; //used to tell which poly is on - // the front side of the bsp partition line - INT32 psonline = 0, peonline = 0; + float ps_frac = 0.0f, pe_frac = 0.0f; // used to tell which poly is on + // the front side of the bsp partition line + ps = pe = -1; + ps_online = pe_online = 0; for (i = 0; i < poly->numpts; i++) { - j = i + 1; + // i, j are one side of the poly + j = i+1; if (j == poly->numpts) - j = 0; + j = 0; // wrap poly // start & end points - pv = fracdivline(bsp, &poly->pts[i], &poly->pts[j]); - - if (pv == NULL) + if (!fracdivline(dlnp, &poly->pts[i], &poly->pts[j])) continue; + // have dividing pt if (ps < 0) { // first point ps = i; - vs = *pv; - fracs = bspfrac; + vs = dlnp->divpt; + ps_frac = dlnp->divfrac; } else { - //the partition line traverse a junction between two segments + // the partition line can traverse a junction between two segments // or the two points are so close, they can be considered as one // thus, don't accept, since split 2 must be another vertex - if (SameVertice(pv, &lastpv)) + if (SameVertex(&dlnp->divpt, &lastpv)) { if (pe < 0) { ps = i; - psonline = 1; + ps_online = 1; } else { pe = i; - peonline = 1; + pe_online = 1; } } else @@ -220,24 +228,25 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line if (pe < 0) { pe = i; - ve = *pv; - frace = bspfrac; + ve = dlnp->divpt; + pe_frac = dlnp->divfrac; } else { - // a frac, not same vertice as last one - // we already got pt2 so pt 2 is not on the line, - // so we probably got back to the start point - // which is on the line - if (SameVertice(pv, &vs)) - psonline = 1; + // a frac, not same vertice as last one + // we already got pt2 so pt 2 is not on the line, + // so we probably got back to the start point + // which is on the line + if (SameVertex(&dlnp->divpt, &vs)) + ps_online = 1; + break; } } } // remember last point intercept to detect identical points - lastpv = *pv; + lastpv = dlnp->divpt; } // no split: the partition line is either parallel and @@ -254,28 +263,34 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line // linedefs where each side point the same sector, that is: // the deep water effect with the original Doom - /// \todo make sure front poly is to front of partition line? + //TODO: make sure front poly is to front of partition line? *frontpoly = poly; - *backpoly = NULL; + *backpoly = NULL; return; } + //if (ps >= 0 && pe < 0) if (pe < 0) { //I_Error("SplitPoly: only one point for split line (%d %d)", ps, pe); *frontpoly = poly; - *backpoly = NULL; + *backpoly = NULL; return; } - if (UNLIKELY(pe <= ps)) - I_Error("SplitPoly: invalid splitting line (%d %d)", ps, pe); + if (pe <= ps) + { + //I_Error("SplitPoly: invalid splitting line (%d %d)", ps, pe); + *frontpoly = poly; + *backpoly = NULL; + return; + } - // number of points on each side, _not_ counting those - // that may lie just one the line - nptback = pe - ps - peonline; - nptfront = poly->numpts - peonline - psonline - nptback; + // Number of points on each side, _not_ counting those + // that may lie just on the line. + nptback = pe - ps - pe_online; + nptfront = poly->numpts - pe_online - ps_online - nptback; if (nptback > 0) *backpoly = HWR_AllocPoly(2 + nptback); @@ -295,11 +310,9 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line *pv++ = ve; i = pe; - do - { + do { if (++i == poly->numpts) i = 0; - *pv++ = poly->pts[i]; } while (i != ps && --nptfront); } @@ -312,66 +325,79 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line *pv++ = vs; i = ps; - do - { + do { if (++i == poly->numpts) i = 0; - *pv++ = poly->pts[i]; } while (i != pe && --nptback); } // make sure frontpoly is the one on the 'right' side // of the partition line - if (fracs > frace) + if (ps_frac > pe_frac) { - poly_t *swappoly; - swappoly = *backpoly; - *backpoly = *frontpoly; + poly_t* swappoly; + swappoly = *backpoly; + *backpoly = *frontpoly; *frontpoly = swappoly; } - HWR_FreePoly (poly); + HWR_FreePoly(poly); } +// checks if any line is a portal or horizonline, for optimization +static inline void CheckForPortalsAndHorizonLines(seg_t *lseg, const line_t *line) +{ + // portal check + if (!gl_maphasportals && lseg->side == 0 && line->special == PORTALSPECIAL) + { + // Find the other side! + INT32 line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->tag, -1); -// use each seg of the poly as a partition line, keep only the + if (line == &lines[line2]) + line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->tag, line2); + + if (line2 >= 0) // found it! + gl_maphasportals = 1; + } + + // horizonline check + if (!gl_maphashorizonlines && line->special == HORIZONSPECIAL) + gl_maphashorizonlines = true; +} + +// Use each seg of the poly as a partition line, keep only the // part of the convex poly to the front of the seg (that is, -// the part inside the sector), the part behind the seg, is -// the void space and is cut out +// the part inside the sector). The part behind the seg, is +// the void space and is cut out. // -static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) +// poly : surrounding convex polygon, non-destructive +// lseg : array of seg +// segcount : number of seg in the array +// Return frontpoly, which may be new or ptr to poly. +// Called from: HWR_SubsecPoly +static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 segcount, poly_t *poly) { INT32 i, j; + poly_t* frontpoly = poly; // default, return same poly polyvertex_t *pv; - INT32 nump = 0, ps, pe; + INT32 poly_num_pts = 0, ps, pe; polyvertex_t vs = {}, ve = {}, p1 = {}, p2 = {}; - float fracs = 0.0f; + float ps_frac = 0.0f; + vertex_t *v1, *v2; fdivline_t cutseg; // x, y, dx, dy as start of node_t struct - poly_t *temppoly; // for each seg of the subsector - for (; count--; lseg++) + for (; segcount--; lseg++) { // x, y, dx, dy (like a divline) const line_t *line = lseg->linedef; - // portal check - if (UNLIKELY(!gl_maphasportals && line->special == PORTALSPECIAL && lseg->side == 0)) - { - // Find the other side! - INT32 line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->tag, -1); + if (!line) + continue; - if (line == &lines[line2]) - line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->tag, line2); - - if (line2 >= 0) // found it! - gl_maphasportals = 1; - } - - if (!gl_maphashorizonlines && line->special == HORIZONSPECIAL) - gl_maphashorizonlines = true; + CheckForPortalsAndHorizonLines(lseg, line); if (line->sidenum[1] != NO_INDEX) { @@ -385,10 +411,21 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) } } - p1.x = FIXED_TO_FLOAT(lseg->side ? line->v2->x : line->v1->x); - p1.y = FIXED_TO_FLOAT(lseg->side ? line->v2->y : line->v1->y); - p2.x = FIXED_TO_FLOAT(lseg->side ? line->v1->x : line->v2->x); - p2.y = FIXED_TO_FLOAT(lseg->side ? line->v1->y : line->v2->y); + if (lseg->side) // side 1 + { + v1 = line->v2; + v2 = line->v1; + } + else // side 0 + { + v1 = line->v1; + v2 = line->v2; + } + + p1.x = FixedToFloat(v1->x); + p1.y = FixedToFloat(v1->y); + p2.x = FixedToFloat(v2->x); + p2.y = FixedToFloat(v2->y); cutseg.x = p1.x; cutseg.y = p1.y; @@ -401,125 +438,130 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) for (i = 0; i < poly->numpts; i++) { - j = i + 1; + // i, j are one side of the poly + j = i+1; if (j == poly->numpts) j = 0; - pv = fracdivline(&cutseg, &poly->pts[i], &poly->pts[j]); - - if (pv == NULL) + if (!fracdivline(&cutseg, &poly->pts[i], &poly->pts[j])) continue; + // have dividing pt if (ps < 0) { ps = i; - vs = *pv; - fracs = bspfrac; + vs = cutseg.divpt; + ps_frac = cutseg.divfrac; + continue; + } + + // frac 1 on previous segment, + // 0 on the next, + // the split line goes through one of the convex poly + // vertices, happens quite often since the convex + // poly is already adjacent to the subsector segs + // on most borders + if (SameVertex(&cutseg.divpt, &vs)) + continue; + + if (ps_frac <= cutseg.divfrac) + { + poly_num_pts = 2 + poly->numpts - (i-ps); + pe = ps; + ps = i; + ve = cutseg.divpt; } else { - //frac 1 on previous segment, - // 0 on the next, - //the split line goes through one of the convex poly - // vertices, happens quite often since the convex - // poly is already adjacent to the subsector segs - // on most borders - if (SameVertice(pv, &vs)) - continue; - - if (fracs <= bspfrac) - { - nump = 2 + poly->numpts - (i-ps); - pe = ps; - ps = i; - ve = *pv; - } - else - { - nump = 2 + (i-ps); - pe = i; - ve = vs; - vs = *pv; - } - - //found 2nd point - break; + poly_num_pts = 2 + (i-ps); + pe = i; + ve = vs; + vs = cutseg.divpt; } + + // found 2nd point + break; } // there was a split if (ps >= 0) { - //need 2 points + // need 2 points if (pe >= 0) { // generate FRONT poly - temppoly = HWR_AllocPoly(nump); + frontpoly = HWR_AllocPoly(poly_num_pts); - pv = temppoly->pts; + pv = frontpoly->pts; *pv++ = vs; *pv++ = ve; - do - { - if (++ps == poly->numpts) + do { + if (++ps == poly->numpts) // poly wrap ps = 0; *pv++ = poly->pts[ps]; } while (ps != pe); HWR_FreePoly(poly); - poly = temppoly; + poly = frontpoly; } #ifdef DEBUG_HWBSP - // hmmm... maybe we should NOT accept this, but this happens - // only when the cut is not needed it seems (when the cut - // line is aligned to one of the borders of the poly, and - // only some times..) else { + // hmmm... maybe we should NOT accept this, but this happens + // only when the cut is not needed it seems (when the cut + // line is aligned to one of the borders of the poly, and + // only some times..) + // [WDJ] This happens often (27 times in Doom2 map01). skipcut++; - I_Error("CutOutPoly: only one point for split line (%d %d) %d", ps, pe, debugpos); + //I_Error("CutOutPoly: only one point for split line (%d %d) %d", ps, pe, debugpos); } #endif } } - return poly; + + return frontpoly; } // At this point, the poly should be convex and the exact -// layout of the subsector, it is not always the case, +// layout of the subsector. It is not always the case, // so continue to cut off the poly into smaller parts with // each seg of the subsector. // -static inline void HWR_SubsecPoly(INT32 num, poly_t *poly) +// ssindex : subsec index, 0..(numsubsectors-1) +// poly : surrounding convex polygon, non-destructive +// Called from WalkBSPNode +static inline void HWR_SubsecPoly(INT32 ssindex, poly_t *poly) { - INT16 count; + INT16 segcount; subsector_t *sub; seg_t *lseg; - sub = &subsectors[num]; - count = sub->numlines; + sub = &subsectors[ssindex]; + segcount = sub->numlines; lseg = &segs[sub->firstline]; if (poly) { - poly = CutOutSubsecPoly(lseg,count,poly); + poly = CutOutSubsecPoly(lseg, segcount, poly); #ifdef DEBUG_HWBSP totalsubsecpolys++; #endif //extra data for this subsector - extrasubsectors[num].planepoly = poly; + extrasubsectors[ssindex].planepoly = poly; } } -// the bsp divline have not enouth presition -// search for the segs source of this divline -static inline void SearchDivline(node_t *bsp, fdivline_t *divline) +// The bsp divline does not have enough precision. +// Search for the segs source of this divline. +static inline void SetDivline(node_t *bsp, fdivline_t *divline) { - divline->x = FIXED_TO_FLOAT(bsp->x); - divline->y = FIXED_TO_FLOAT(bsp->y); - divline->dx = FIXED_TO_FLOAT(bsp->dx); - divline->dy = FIXED_TO_FLOAT(bsp->dy); + // MAR - If you don't use the same partition line that the BSP uses, + // the front/back polys won't match the subsectors in the BSP! + divline->x = FixedToFloat(bsp->x); + divline->y = FixedToFloat(bsp->y); + divline->dx = FixedToFloat(bsp->dx); + divline->dy = FixedToFloat(bsp->dy); } //Hurdler: implement a loading status @@ -532,20 +574,25 @@ static void loading_status(void) char s[16]; int x, y; + /*if (g_reloadinggamestate) + { + return; + }*/ + I_OsPolling(); CON_Drawer(); sprintf(s, "%d%%", (++ls_percent)<<1); x = BASEVIDWIDTH/2; y = BASEVIDHEIGHT/2; - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // Black background to match fade in effect + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); // Black background to match fade in effect //V_DrawPatchFill(srb2back); // SRB2 background, ehhh too bright. M_DrawTextBox(x-58, y-8, 13, 1); V_DrawString(x-50, y, V_YELLOWMAP, "Loading..."); V_DrawRightAlignedString(x+50, y, V_YELLOWMAP, s); // Is this really necessary at this point..? - V_DrawCenteredString(BASEVIDWIDTH/2, 40, V_YELLOWMAP, "OPENGL MODE IS INCOMPLETE AND MAY"); - V_DrawCenteredString(BASEVIDWIDTH/2, 50, V_YELLOWMAP, "NOT DISPLAY SOME SURFACES."); + V_DrawCenteredString(BASEVIDWIDTH/2, 40, V_YELLOWMAP, "OPENGL MODE IS INCOMPLETE AND SOME"); + V_DrawCenteredString(BASEVIDWIDTH/2, 50, V_YELLOWMAP, "VISUAL FEATURES ARE MISSING/BROKEN."); V_DrawCenteredString(BASEVIDWIDTH/2, 70, V_YELLOWMAP, "USE AT SONIC'S RISK."); I_UpdateNoVsync(); @@ -576,14 +623,14 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b { CONS_Debug(DBG_RENDER, "Adding a new subsector\n"); - if (UNLIKELY(addsubsector == numsubsectors + NEWSUBSECTORS)) - I_Error("WalkBSPNode: not enough addsubsectors\n"); - else if (UNLIKELY(addsubsector > 0x7fff)) - I_Error("WalkBSPNode: addsubsector > 0x7fff\n"); + if (num_extra_subsector == numsubsectors + NUM_EXTRA_SUBSECTORS) + I_Error("WalkBSPNode: not enough num_extra_subsectors\n"); + else if (num_extra_subsector > 0x7fff) + I_Error("WalkBSPNode: num_extra_subsector > 0x7fff\n"); - *leafnode = (UINT16)((UINT16)addsubsector | NF_SUBSECTOR); - extrasubsectors[addsubsector].planepoly = poly; - addsubsector++; + *leafnode = (UINT16)((UINT16)num_extra_subsector | NF_SUBSECTOR); + extrasubsectors[num_extra_subsector].planepoly = poly; + num_extra_subsector++; } //add subsectors without segs here? @@ -593,8 +640,8 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b { HWR_SubsecPoly(bspnum & ~NF_SUBSECTOR, poly); - //Hurdler: implement a loading status #ifdef HWR_LOADING_SCREEN + //Hurdler: implement a loading status if (ls_count-- <= 0) { ls_count = numsubsectors/50; @@ -613,7 +660,7 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b } bsp = &nodes[bspnum]; - SearchDivline(bsp, &fdivline); + SetDivline(bsp, &fdivline); SplitPoly(&fdivline, poly, &frontpoly, &backpoly); poly = NULL; @@ -656,12 +703,12 @@ void HWR_FreeExtraSubsectors(void) extrasubsectors = NULL; } -#define MAXDIST 1.5f +#define MAXDIST (1.5f) // BP: can't move vertex: DON'T change polygon geometry! (convex) //#define MOVEVERTEX // Is vertex va within the seg v1, v2 -static boolean PointInSeg(polyvertex_t *va,polyvertex_t *v1,polyvertex_t *v2) +static boolean PointInSeg(polyvertex_t *va, polyvertex_t *v1, polyvertex_t *v2) { register float ax, ay, bx, by, cx, cy, d, norm; @@ -736,8 +783,8 @@ static boolean PointInSeg(polyvertex_t *va,polyvertex_t *v1,polyvertex_t *v2) if (cx*cx+cy*cy <= MAXDIST*MAXDIST) { // ajust a little the point position - a->x = ax*d+v1->x; - a->y = ay*d+v1->y; + va->x = ax*d+v1->x; + va->y = ay*d+v1->y; // anyway the correction is not enouth return true; } @@ -749,10 +796,10 @@ static boolean PointInSeg(polyvertex_t *va,polyvertex_t *v1,polyvertex_t *v2) static INT32 numsplitpoly; -static void SearchSegInBSP(INT32 bspnum,polyvertex_t *p,poly_t *poly) +static void SearchSegInBSP(INT32 bspnum, polyvertex_t *p, poly_t *poly) { poly_t *q; - INT32 j,k; + INT32 j, k; if (bspnum & NF_SUBSECTOR) { @@ -772,12 +819,12 @@ static void SearchSegInBSP(INT32 bspnum,polyvertex_t *p,poly_t *poly) if (k == numpts) k = 0; - if (!SameVertice(p, &q->pts[j]) - && !SameVertice(p, &q->pts[k]) - && PointInSeg(p, &q->pts[j], &q->pts[k])) + if (!SameVertex(p, &q->pts[j]) && + !SameVertex(p, &q->pts[k]) && + PointInSeg(p, &q->pts[j], &q->pts[k])) { - poly_t *newpoly = HWR_AllocPoly(numpts+1); INT32 n; + poly_t *newpoly = HWR_AllocPoly(numpts+1); for (n = 0; n <= j; n++) newpoly->pts[n] = q->pts[n]; @@ -798,16 +845,17 @@ static void SearchSegInBSP(INT32 bspnum,polyvertex_t *p,poly_t *poly) return; } - if ((FIXED_TO_FLOAT(nodes[bspnum].bbox[0][BOXBOTTOM])-MAXDIST <= p->y) && - (FIXED_TO_FLOAT(nodes[bspnum].bbox[0][BOXTOP ])+MAXDIST >= p->y) && - (FIXED_TO_FLOAT(nodes[bspnum].bbox[0][BOXLEFT ])-MAXDIST <= p->x) && - (FIXED_TO_FLOAT(nodes[bspnum].bbox[0][BOXRIGHT ])+MAXDIST >= p->x)) + // Not a subsector, visit left and right children. + if ((FixedToFloat(nodes[bspnum].bbox[0][BOXBOTTOM])-MAXDIST <= p->y) && + (FixedToFloat(nodes[bspnum].bbox[0][BOXTOP ])+MAXDIST >= p->y) && + (FixedToFloat(nodes[bspnum].bbox[0][BOXLEFT ])-MAXDIST <= p->x) && + (FixedToFloat(nodes[bspnum].bbox[0][BOXRIGHT ])+MAXDIST >= p->x)) SearchSegInBSP(nodes[bspnum].children[0], p, poly); - if ((FIXED_TO_FLOAT(nodes[bspnum].bbox[1][BOXBOTTOM])-MAXDIST <= p->y) && - (FIXED_TO_FLOAT(nodes[bspnum].bbox[1][BOXTOP ])+MAXDIST >= p->y) && - (FIXED_TO_FLOAT(nodes[bspnum].bbox[1][BOXLEFT ])-MAXDIST <= p->x) && - (FIXED_TO_FLOAT(nodes[bspnum].bbox[1][BOXRIGHT ])+MAXDIST >= p->x)) + if ((FixedToFloat(nodes[bspnum].bbox[1][BOXBOTTOM])-MAXDIST <= p->y) && + (FixedToFloat(nodes[bspnum].bbox[1][BOXTOP ])+MAXDIST >= p->y) && + (FixedToFloat(nodes[bspnum].bbox[1][BOXLEFT ])-MAXDIST <= p->x) && + (FixedToFloat(nodes[bspnum].bbox[1][BOXRIGHT ])+MAXDIST >= p->x)) SearchSegInBSP(nodes[bspnum].children[1], p, poly); } @@ -816,38 +864,43 @@ static void SearchSegInBSP(INT32 bspnum,polyvertex_t *p,poly_t *poly) // but we must use a different structure : polygone pointing on segs // segs pointing on polygone and on vertex (too mush complicated, well not // realy but i am soo lasy), the methode discibed is also better for segs presition -static INT32 SolveTProblem(void) +static void SolveTProblem(void) { poly_t *p; - INT32 i; - size_t l; + INT32 i, numpts; + size_t ssnum; - if (cv_glsolvetjoin.value == 0) - return 0; + if (!cv_glsolvetjoin.value) + return; CONS_Debug(DBG_RENDER, "Solving T-joins. This may take a while. Please wait...\n"); +#ifdef HWR_LOADING_SCREEN + CON_Drawer(); //let the user know what we are doing + I_FinishUpdate(); // page flip or blit buffer +#endif + numsplitpoly = 0; - for (l = 0; l < addsubsector; l++) + for (ssnum = 0; ssnum < num_extra_subsector; ssnum++) { - p = extrasubsectors[l].planepoly; + p = extrasubsectors[ssnum].planepoly; - if (!p) + if (!p || p->numpts == 0) continue; - for (i = 0; i < p->numpts; i++) + numpts = p->numpts; + + for (i = 0; i < numpts; i++) SearchSegInBSP((INT32)numnodes-1, &p->pts[i], p); } #ifdef DEBUG_HWBSP CONS_Debug(DBG_RENDER, "numsplitpoly %d\n", numsplitpoly); + CONS_Debug(DBG_RENDER, "%d point divides a polygon line\n", numsplitpoly); #endif - - return numsplitpoly; } - // call this routine after the BSP of a Doom wad file is loaded, // and it will generate all the convex polys for the hardware renderer void HWR_CreatePlanePolygons(INT32 bspnum) @@ -865,7 +918,7 @@ void HWR_CreatePlanePolygons(INT32 bspnum) #endif // reset the portal and horizonline flag - gl_maphasportals = gl_maphashorizonlines = 0; + gl_maphasportals = gl_maphashorizonlines = false; // find min/max boundaries of map #ifdef DEBUG_HWBSP @@ -882,39 +935,35 @@ void HWR_CreatePlanePolygons(INT32 bspnum) HWR_FreeExtraSubsectors(); // allocate extra data for each subsector present in map - totsubsectors = numsubsectors + NEWSUBSECTORS; - extrasubsectors = calloc(totsubsectors, sizeof(*extrasubsectors)); + num_alloc_extra_subsector = numsubsectors + NUM_EXTRA_SUBSECTORS; + extrasubsectors = (extrasubsector_t*)calloc(num_alloc_extra_subsector, sizeof(*extrasubsectors)); if (UNLIKELY(!extrasubsectors)) - I_Error("couldn't malloc extrasubsectors totsubsectors %s\n", sizeu1(totsubsectors)); + I_Error("couldn't malloc extrasubsectors num_alloc_extra_subsector %s\n", sizeu1(num_alloc_extra_subsector)); // number of the first new subsector that might be added - addsubsector = numsubsectors; + num_extra_subsector = numsubsectors; // construct the initial convex poly that encloses the full map rootp = HWR_AllocPoly(4); rootpv = rootp->pts; - rootpv->x = FIXED_TO_FLOAT(rootbbox[BOXLEFT ]); - rootpv->y = FIXED_TO_FLOAT(rootbbox[BOXBOTTOM]); //lr + // clockwise polygon + rootpv->x = FixedToFloat(rootbbox[BOXLEFT ]); + rootpv->y = FixedToFloat(rootbbox[BOXBOTTOM]); //lr rootpv++; - rootpv->x = FIXED_TO_FLOAT(rootbbox[BOXLEFT ]); - rootpv->y = FIXED_TO_FLOAT(rootbbox[BOXTOP ]); //ur + rootpv->x = FixedToFloat(rootbbox[BOXLEFT ]); + rootpv->y = FixedToFloat(rootbbox[BOXTOP ]); //ur rootpv++; - rootpv->x = FIXED_TO_FLOAT(rootbbox[BOXRIGHT ]); - rootpv->y = FIXED_TO_FLOAT(rootbbox[BOXTOP ]); //ul + rootpv->x = FixedToFloat(rootbbox[BOXRIGHT ]); + rootpv->y = FixedToFloat(rootbbox[BOXTOP ]); //ul rootpv++; - rootpv->x = FIXED_TO_FLOAT(rootbbox[BOXRIGHT ]); - rootpv->y = FIXED_TO_FLOAT(rootbbox[BOXBOTTOM]); //ll + rootpv->x = FixedToFloat(rootbbox[BOXRIGHT ]); + rootpv->y = FixedToFloat(rootbbox[BOXBOTTOM]); //ll rootpv++; WalkBSPNode(bspnum, rootp, NULL, rootbbox); -#ifdef DEBUG_HWBSP - i = SolveTProblem(); - CONS_Debug(DBG_RENDER, "%d point divides a polygon line\n",i); -#else SolveTProblem(); -#endif #ifdef DEBUG_HWBSP //debug debug.. diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index fa8993b4c..0fd28dd4d 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -54,7 +54,7 @@ void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 // -------- extern extrasubsector_t *extrasubsectors; #ifdef PARANOIA -extern size_t addsubsector; +extern size_t num_extra_subsector; #endif void HWR_FreeExtraSubsectors(void); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 9be30db07..e30d5d0ef 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2779,9 +2779,9 @@ static void HWR_Subsector(size_t num) ffloor_t *rover; #ifdef PARANOIA // no risk while developing, enough debugging nights! - if (num >= addsubsector) + if (num >= num_extra_subsector) I_Error("HWR_Subsector: ss %s with numss = %s, addss = %s\n", - sizeu1(num), sizeu2(numsubsectors), sizeu3(addsubsector)); + sizeu1(num), sizeu2(numsubsectors), sizeu3(num_extra_subsector)); #endif if (num < numsubsectors) diff --git a/src/p_setup.c b/src/p_setup.c index ec1320aa5..74f4b876b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -117,6 +117,7 @@ line_t *spawnlines = NULL; side_t *spawnsides = NULL; INT32 numstarposts = 0; boolean levelloading = false; +UINT8 levelfadecol = 120; virtres_t *curmapvirt = NULL; @@ -2956,7 +2957,6 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // 99% of the things already did, so. // Map header should always be in place at this point INT32 i; - UINT8 levelfadecol; boolean ranspecialwipe = false; lumpnum_t encoreLump = LUMPERROR; const mapheader_t *mapheader = mapheaderinfo[gamemap - 1]; diff --git a/src/p_setup.h b/src/p_setup.h index 1d986d925..166c0ec2e 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -35,6 +35,7 @@ extern mapthing_t *deathmatchstarts[MAX_DM_STARTS]; extern INT32 numdmstarts, numcoopstarts, numredctfstarts, numbluectfstarts; extern boolean levelloading; +extern UINT8 levelfadecol; extern lumpnum_t lastloadedmaplumpnum; // for comparative savegame extern virtres_t *curmapvirt; From 90ab1f499467e6870a72ebc0552f192accee9c46 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 9 Jul 2026 06:45:03 +0200 Subject: [PATCH 493/589] cleanup opengl wipe stuff a little split it like srb2.2 --- src/hardware/hw_main.cpp | 52 +++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index e30d5d0ef..fbd9702ce 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5986,6 +5986,10 @@ static void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD static void HWR_DoPostProcessor(void) { + // no flashes or screen waving if we want less vfx! + if (cv_reducevfx.value) + return; + // Armageddon Blast Flash! // Could this even be considered postprocessor? if (!HWR_ShouldUsePaletteRendering()) @@ -6025,7 +6029,7 @@ static void HWR_DoPostProcessor(void) return; // Not supported in splitscreen - someone want to add support? - if (splitscreen || cv_reducevfx.value) + if (splitscreen) return; //UINT8 viewnum = R_GetViewNumber(); @@ -6083,44 +6087,60 @@ static void HWR_DoPostProcessor(void) // Flipping of the screen isn't done here anymore } -void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) +// +// wipes +// +static lumpnum_t wipelumpnum; + +// puts wipe lumpname in wipename[9] +static boolean HWR_WipeCheck(UINT8 wipenum, UINT8 scrnnum) { static char lumpname[9] = "FADEmmss"; - lumpnum_t lumpnum; size_t lsize; + // screen textures disabled completely if (cv_glscreentextures.value == 0) { - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // just draw a black screen instead of flashing and crap - return; + return false; } - if (wipenum > 99 || scrnnum > 99) // not a valid wipe number + // not a valid wipe number + if (wipenum > 99 || scrnnum > 99) { - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // just draw a black screen instead of flashing and crap - return; // shouldn't end up here really, the loop should've stopped running beforehand + return false; // shouldn't end up here really, the loop should've stopped running beforehand } // puts the numbers into the lumpname sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)wipenum, (UINT16)scrnnum); - lumpnum = W_CheckNumForName(lumpname); + wipelumpnum = W_CheckNumForName(lumpname); - if (lumpnum == LUMPERROR) // again, shouldn't be here really + // again, shouldn't be here really + if (wipelumpnum == LUMPERROR) { - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // just draw a black screen instead of flashing and crap - return; + return false; } - lsize = W_LumpLength(lumpnum); + lsize = W_LumpLength(wipelumpnum); if (!(lsize == 256000 || lsize == 64000 || lsize == 16000 || lsize == 4000)) { CONS_Alert(CONS_WARNING, "Fade mask lump %s of incorrect size, ignored\n", lumpname); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // just draw a black screen instead of flashing and crap - return; // again, shouldn't get here if it is a bad size + return false; // again, shouldn't get here if it is a bad size } - HWR_GetFadeMask(lumpnum); + return true; +} + +void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) +{ + if (!HWR_WipeCheck(wipenum, scrnnum)) + { + // just draw a black screen instead of rapidly flashing a white screen + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); + return; + } + + HWR_GetFadeMask(wipelumpnum); GL_DoScreenWipe(HWD_SCREENTEXTURE_WIPE_START, HWD_SCREENTEXTURE_WIPE_END); } From b408a098bda312c07a798a745a7f7c6135e548ac Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 9 Jul 2026 13:00:43 +0300 Subject: [PATCH 494/589] Fix netxcmdnames missing one name --- src/d_netcmd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4e217946e..66e4aad3a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -566,6 +566,7 @@ const char *netxcmdnames[MAXNETXCMD - 1] = "MODIFYVOTE", "PICKVOTE", "REMOVEPLAYER", + "DISCORD", "LUACMD", "LUAVAR" }; From b9ac91c74fb47d9028f01a639ad5b9c5d70b0e76 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 9 Jul 2026 23:49:07 +0200 Subject: [PATCH 495/589] fix eggbox crap :chaosleep: --- src/k_kart.c | 24 ------------------------ src/r_fps.cpp | 51 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 44aa70377..0196bb521 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3522,27 +3522,6 @@ static INT32 K_StairJankFlip(INT32 value) return K_AltFlip(value, 2); } -// reset banan and eggbox rollangle when they´re on the ground -// if not cv_bananthrowroll option "+Onground" -static void K_ResetBananaRollangle(mobj_t* mo) -{ - if (!mo->rollangle) - return; - - if (mo->type != MT_BANANA && mo->type != MT_EGGMANITEM) // always reset eggboxes - return; - - // keep banans "rotated" if we want them to - if (mo->type == MT_BANANA && cv_bananthrowroll.value == 2) - return; - - // only reset if on ground - if (!P_IsObjectOnGround(mo)) - return; - - mo->rollangle = 0; -} - #define SLOPEROLL_DIV 3 void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) { @@ -3556,9 +3535,6 @@ void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) I_Assert(mo->subsector != NULL); I_Assert(mo->subsector->sector != NULL); - // kinda stupid but idk where else to put this - K_ResetBananaRollangle(mo); - if (!K_ShouldSlopeRoll(mo)) { mo->pitch_sprite = mo->roll_sprite = 0; diff --git a/src/r_fps.cpp b/src/r_fps.cpp index 121a0df5f..b96c9de23 100644 --- a/src/r_fps.cpp +++ b/src/r_fps.cpp @@ -757,6 +757,45 @@ void R_UpdateMobjInterpolators(void) } } +// reset banan and eggbox rollangle when they´re on the ground +// if not cv_bananthrowroll option "+Onground" +static void R_ResetBananaRollangle(mobj_t* mobj) +{ + if (!mobj->rollangle) + return; + + if (mobj->type != MT_BANANA && mobj->type != MT_EGGMANITEM) // always reset eggboxes + return; + + // keep banans "rotated" if we want them to + if (mobj->type == MT_BANANA && cv_bananthrowroll.value == 2) + return; + + // only reset if on ground + if (!P_IsObjectOnGround(mobj)) + return; + + mobj->rollangle = 0; +} + +// Reset our Sprite scales and offsets +// at the start of the tic +// this is just to make things simpler +// as we dont have to reset it ourselves after use +// done at the start so lua can still overwrite everything +static void R_ResetMobjSpriteStuff(mobj_t *mobj) +{ + mobj->spritexscale = mobj->realxscale; + mobj->spriteyscale = mobj->realyscale; + mobj->spritexoffset = mobj->realxoffset; + mobj->spriteyoffset = mobj->realyoffset; + + mobj->temprollangle = 0; + + // kinda stupid but idk where else to put this + R_ResetBananaRollangle(mobj); +} + // // P_ResetMobjInterpolationState // @@ -795,19 +834,9 @@ void R_ResetMobjInterpolationState(mobj_t *mobj) mobj->player->old_frameangle = mobj->player->frameangle; } - // Reset our Sprite scales and offsets - // at the start of the tic - // this is just to make things simpler - // as we dont have to reset it ourselves after use - // done at the start so lua can still overwrite everything - // technically not interpolation related // but this saves us another thinkerloop and multiple checks lel - mobj->spritexscale = mobj->realxscale; - mobj->spriteyscale = mobj->realyscale; - mobj->spritexoffset = mobj->realxoffset; - mobj->spriteyoffset = mobj->realyoffset; - mobj->temprollangle = 0; + R_ResetMobjSpriteStuff(mobj); mobj->resetinterp = false; } From f5fdf917bd76506fcaed6a05cb4f73982833580b Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 11 Jul 2026 13:48:56 -0500 Subject: [PATCH 496/589] Support >4GB sys mem in memfree for linux, win32, macOS sys mem counts Also includes memory counts for the extended allocation functionality --- src/android/i_system.c | 10 +++---- src/core/memory.cpp | 3 +++ src/core/memory.h | 4 +++ src/dedicated/i_system.c | 56 +++++++++++++++++++++++++++++++++------- src/sdl/i_system.cpp | 54 +++++++++++++++++++++++++++++++------- src/z_zone.cpp | 10 +++++++ src/z_zone.h | 1 + 7 files changed, 113 insertions(+), 25 deletions(-) diff --git a/src/android/i_system.c b/src/android/i_system.c index ef10df5b5..c0f7cc11c 100644 --- a/src/android/i_system.c +++ b/src/android/i_system.c @@ -34,8 +34,8 @@ size_t I_GetFreeMem(size_t *total) /* return si.freeram; */ char buf[1024]; char *memTag; - UINT32 freeKBytes; - UINT32 totalKBytes; + size_t freeKBytes; + size_t totalKBytes; INT32 n; INT32 meminfo_fd = -1; @@ -46,7 +46,7 @@ size_t I_GetFreeMem(size_t *total) if (n < 0) { // Error - *total = 0L; + *total = 0; return 0; } @@ -54,7 +54,7 @@ size_t I_GetFreeMem(size_t *total) if (NULL == (memTag = strstr(buf, MEMTOTAL))) { // Error - *total = 0L; + *total = 0; return 0; } @@ -64,7 +64,7 @@ size_t I_GetFreeMem(size_t *total) if (NULL == (memTag = strstr(buf, MEMFREE))) { // Error - *total = 0L; + *total = 0; return 0; } diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 9e591e78c..81ba79d5d 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -114,6 +114,7 @@ void* PoolAllocator::allocate() FreeBlock* ret = head_; head_ = head_->next; + allocated_blocks_++; return ret; } @@ -125,6 +126,7 @@ void PoolAllocator::deallocate(void* p) FreeBlock* block = reinterpret_cast(p); block->next = head_; head_ = block; + allocated_blocks_--; } void PoolAllocator::release() @@ -144,6 +146,7 @@ void PoolAllocator::release() first_chunk_ = nullptr; head_ = nullptr; + allocated_blocks_ = 0; } static LinearMemory g_frame_memory {4 * 1024 * 1024}; diff --git a/src/core/memory.h b/src/core/memory.h index 77e7206b5..4aec917d7 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -37,6 +37,7 @@ class PoolAllocator final FreeBlock* head_; size_t block_size_; size_t blocks_; + size_t allocated_blocks_; int32_t tag_; ChunkFooter* allocate_chunk(); @@ -47,6 +48,7 @@ public: , head_(nullptr) , block_size_(block_size) , blocks_(blocks) + , allocated_blocks_(0) , tag_(tag) {} PoolAllocator(const PoolAllocator&) = delete; @@ -59,6 +61,8 @@ public: void* allocate(); void deallocate(void* p); constexpr size_t block_size() const noexcept { return block_size_; }; + constexpr size_t allocated_blocks() const noexcept { return allocated_blocks_; }; + constexpr size_t allocated_bytes() const noexcept { return allocated_blocks_ * block_size_; }; void release(); }; diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index fb3cc2731..fc38ffdef 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -68,6 +68,12 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include #if defined (__linux__) #include +#elif defined(__APPLE__) +#include +#include +#include +#include +#include #else #include #include @@ -2009,13 +2015,13 @@ size_t I_GetFreeMem(size_t *total) *total = 32 << 20; return 32 << 20; #elif defined (_WIN32) - MEMORYSTATUS info; + MEMORYSTATUSEX info; - info.dwLength = sizeof (MEMORYSTATUS); - GlobalMemoryStatus( &info ); + info.dwLength = sizeof (MEMORYSTATUSEX); + GlobalMemoryStatusEx( &info ); if (total) - *total = (size_t)info.dwTotalPhys; - return (size_t)info.dwAvailPhys; + *total = (size_t)info.ullTotalPhys; + return (size_t)info.ullAvailPhys; #elif defined (__OS2__) UINT32 pr_arena; @@ -2048,7 +2054,7 @@ size_t I_GetFreeMem(size_t *total) { // Error if (total) - *total = 0L; + *total = 0; return 0; } @@ -2057,12 +2063,12 @@ size_t I_GetFreeMem(size_t *total) { // Error if (total) - *total = 0L; + *total = 0; return 0; } memTag += sizeof (MEMTOTAL); - totalKBytes = (size_t)atoi(memTag); + totalKBytes = strtoul(memTag, NULL, 10); if ((memTag = strstr(buf, MEMAVAILABLE)) == NULL) { @@ -2076,7 +2082,7 @@ size_t I_GetFreeMem(size_t *total) { // Error if (total) - *total = 0L; + *total = 0; return 0; } freeKBytes = MemAvailable; @@ -2084,16 +2090,46 @@ size_t I_GetFreeMem(size_t *total) else { memTag += sizeof (MEMAVAILABLE); - freeKBytes = atoi(memTag); + freeKBytes = strtoul(memTag, NULL, 10); } if (total) *total = totalKBytes << 10; return freeKBytes << 10; +#elif defined(__APPLE__) + /* macOS */ + mach_port_t host = mach_host_self(); + kern_return_t kr; + mach_msg_type_number_t count; + vm_size_t v_page_size; + struct vm_statistics64 vm_stats; + uint64_t total_mem, free_mem; + size_t size; + + size = sizeof(total_mem); + if (sysctlbyname("hw.memsize", &total_mem, &size, NULL, 0) < 0) + total_mem = 0; + + kr = host_page_size(host, &v_page_size); + if (kr != KERN_SUCCESS) + v_page_size = 4096; + + count = HOST_VM_INFO64_COUNT; + kr = host_statistics64(host, HOST_VM_INFO64, (host_info64_t)&vm_stats, &count); + if (kr == KERN_SUCCESS) + free_mem = (uint64_t)(vm_stats.free_count + vm_stats.inactive_count) * v_page_size; + else + free_mem = 0; + + if (total) + *total = (size_t)total_mem; + return (size_t)free_mem; #else // Guess 48 MB. if (total) + { *total = 48<<20; + } return 48<<20; #endif } diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 4e9de24c2..fb4f0dcd5 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -83,6 +83,12 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #if defined (__unix__) || defined(__APPLE__) || (defined (UNIXCOMMON) && !defined (__HAIKU__)) #if defined (__linux__) #include +#elif defined(__APPLE__) +#include +#include +#include +#include +#include #else #include #include @@ -2635,13 +2641,13 @@ size_t I_GetFreeMem(size_t *total) *total = 32 << 20; return 32 << 20; #elif defined (_WIN32) - MEMORYSTATUS info; + MEMORYSTATUSEX info; - info.dwLength = sizeof (MEMORYSTATUS); - GlobalMemoryStatus( &info ); + info.dwLength = sizeof (MEMORYSTATUSEX); + GlobalMemoryStatusEx( &info ); if (total) - *total = (size_t)info.dwTotalPhys; - return (size_t)info.dwAvailPhys; + *total = (size_t)info.ullTotalPhys; + return (size_t)info.ullAvailPhys; #elif defined (__OS2__) UINT32 pr_arena; @@ -2674,7 +2680,7 @@ size_t I_GetFreeMem(size_t *total) { // Error if (total) - *total = 0L; + *total = 0; return 0; } @@ -2683,12 +2689,12 @@ size_t I_GetFreeMem(size_t *total) { // Error if (total) - *total = 0L; + *total = 0; return 0; } memTag += sizeof (MEMTOTAL); - totalKBytes = (size_t)atoi(memTag); + totalKBytes = strtoul(memTag, NULL, 10); if ((memTag = strstr(buf, MEMAVAILABLE)) == NULL) { @@ -2702,7 +2708,7 @@ size_t I_GetFreeMem(size_t *total) { // Error if (total) - *total = 0L; + *total = 0; return 0; } freeKBytes = MemAvailable; @@ -2710,12 +2716,40 @@ size_t I_GetFreeMem(size_t *total) else { memTag += sizeof (MEMAVAILABLE); - freeKBytes = atoi(memTag); + freeKBytes = strtoul(memTag, NULL, 10); } if (total) *total = totalKBytes << 10; return freeKBytes << 10; +#elif defined(__APPLE__) + /* macOS */ + mach_port_t host = mach_host_self(); + kern_return_t kr; + mach_msg_type_number_t count; + vm_size_t v_page_size; + struct vm_statistics64 vm_stats; + uint64_t total_mem, free_mem; + size_t size; + + size = sizeof(total_mem); + if (sysctlbyname("hw.memsize", &total_mem, &size, NULL, 0) < 0) + total_mem = 0; + + kr = host_page_size(host, &v_page_size); + if (kr != KERN_SUCCESS) + v_page_size = 4096; + + count = HOST_VM_INFO64_COUNT; + kr = host_statistics64(host, HOST_VM_INFO64, (host_info64_t)&vm_stats, &count); + if (kr == KERN_SUCCESS) + free_mem = (uint64_t)(vm_stats.free_count + vm_stats.inactive_count) * v_page_size; + else + free_mem = 0; + + if (total) + *total = (size_t)total_mem; + return (size_t)free_mem; #else // Guess 48 MB. if (total) diff --git a/src/z_zone.cpp b/src/z_zone.cpp index f25f99e43..f688dd831 100644 --- a/src/z_zone.cpp +++ b/src/z_zone.cpp @@ -114,6 +114,7 @@ void Z_Init(void) head.next = head.prev = &head; memfree = I_GetFreeMem(&total)>>20; + CONS_Printf("System memory: %sMB - Free: %sMB\n", sizeu1(total>>20), sizeu2(memfree)); // Note: This allocates memory. Watch out. @@ -745,6 +746,7 @@ static void Command_Memfree_f(void) CONS_Printf(M_GetText("HUD graphics : %7s KB\n"), sizeu1(Z_TagUsage(PU_HUDGFX)>>10)); CONS_Printf(M_GetText("Locked cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_CACHE)>>10)); CONS_Printf(M_GetText("Level : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVEL)>>10)); + CONS_Printf(M_GetText("Level (pooled) : %7s KB\n"), sizeu1(Z_LevelPoolUsage()>>10)); CONS_Printf(M_GetText("Special thinker : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVSPEC)>>10)); CONS_Printf(M_GetText("All purgable : %7s KB\n"), sizeu1(Z_TagsUsage(PU_PURGELEVEL, INT32_MAX)>>10)); @@ -804,6 +806,14 @@ char *Z_StrDup(const char *s) return strcpy((char*)ZZ_Alloc(strlen(s) + 1), s); } +size_t Z_LevelPoolUsage(void) +{ + return g_level_large_pool.allocated_bytes() + + g_level_med_pool.allocated_bytes() + + g_level_small_pool.allocated_bytes() + + g_level_tiny_pool.allocated_bytes(); +} + void* Z_LevelPoolMalloc(size_t size) { void* p = nullptr; diff --git a/src/z_zone.h b/src/z_zone.h index 38f00c48c..847e47291 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -167,6 +167,7 @@ char *Z_StrDup(const char *in); // // Specialty allocation functions // +size_t Z_LevelPoolUsage(void); void *Z_LevelPoolMalloc(size_t size); void *Z_LevelPoolCalloc(size_t size); void Z_LevelPoolFree(void *p, size_t size); From 8a62f4e9783ad6dcdcc7e66201b43f22fbfb7632 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 13 Jul 2026 07:40:13 +0200 Subject: [PATCH 497/589] software: move hom removal to R_RenderPlayerView gl also has it there so why not --- src/d_main.c | 14 -------------- src/r_main.cpp | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 2150b1e72..ed0e0199e 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -275,20 +275,6 @@ static void D_Renderview(void) R_ApplyLevelInterpolators(R_GetTimeFrac(RTF_LEVEL)); - if (rendermode == render_soft && cv_homremoval.value) - { - if (cv_homremoval.value == 1) - { - // Clear the software screen buffer to remove HOM - memset(vid.screens[0], 31, vid.width * vid.height); - } - else if (cv_homremoval.value == 2) - { - //'development' HOM removal -- makes it blindingly obvious if HOM is spotted. - memset(vid.screens[0], 32+(timeinmap&15), vid.width * vid.height); - } - } - for (i = 0; i <= splitscreen; i++) { if (!P_MobjWasRemoved(players[displayplayers[i]].mo) || players[displayplayers[i]].playerstate == PST_DEAD) diff --git a/src/r_main.cpp b/src/r_main.cpp index d2b6eed65..d6fe70c2d 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1389,6 +1389,21 @@ void R_RenderPlayerView(player_t *player) maskcount_t* masks = static_cast(malloc(sizeof(maskcount_t))); const boolean skybox = (skyboxmo[0] && cv_skybox.value); + // Only do it if it's the first screen being rendered + if (cv_homremoval.value && viewssnum == 0) + { + if (cv_homremoval.value == 1) + { + // Clear the software screen buffer to remove HOM + memset(vid.screens[0], 31, vid.width * vid.height); + } + else if (cv_homremoval.value == 2) + { + //'development' HOM removal -- makes it blindingly obvious if HOM is spotted. + memset(vid.screens[0], 32+(timeinmap&15), vid.width * vid.height); + } + } + // load previous saved value of skyVisible for the player skyVisible = skyVisiblePerPlayer[viewssnum]; @@ -1455,10 +1470,12 @@ void R_RenderPlayerView(player_t *player) NetUpdate(); R_SetColumnContext(COLUMNCONTEXT_FLUSH); + ps_numbspcalls.value.i = ps_numpolyobjects.value.i = ps_numdrawnodes.value.i = 0; PS_START_TIMING(ps_bsptime); R_RenderViewpoint(&masks[nummasks - 1], true); PS_STOP_TIMING(ps_bsptime); + PS_START_TIMING(ps_sw_spritecliptime); R_ClipSprites(drawsegs, NULL); PS_STOP_TIMING(ps_sw_spritecliptime); @@ -1466,8 +1483,8 @@ void R_RenderPlayerView(player_t *player) ps_numsprites.value.i = numvisiblesprites; - PS_START_TIMING(ps_sw_portaltime); // Portal rendering. Hijacks the BSP traversal. + PS_START_TIMING(ps_sw_portaltime); if (portal_base) { portal_t *portal; @@ -1517,6 +1534,7 @@ void R_RenderPlayerView(player_t *player) PS_START_TIMING(ps_sw_maskedtime); R_DrawMasked(masks, nummasks); PS_STOP_TIMING(ps_sw_maskedtime); + free(masks); // Check for new console commands. From 7048eeacc3834b5d5262e472530a526523748132 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 13 Jul 2026 07:41:01 +0200 Subject: [PATCH 498/589] Portal_AddSkybox can be static its unused anyways also adds plane bounds check which was missing --- src/r_portal.c | 5 ++++- src/r_portal.h | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/r_portal.c b/src/r_portal.c index d84a99be4..00baad528 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -272,7 +272,7 @@ static boolean TrimVisplaneBounds(const visplane_t* plane, INT16* start, INT16* * Applies the necessary offsets and rotation to give * a depth illusion to the skybox. */ -void Portal_AddSkybox(const visplane_t* plane) +static void Portal_AddSkybox(const visplane_t* plane) { INT16 start, end; mapheader_t *mh; @@ -337,6 +337,9 @@ void Portal_AddSkyboxPortals(void) { for (pl = visplanes[i]; pl; pl = pl->next) { + if (pl->minx >= pl->maxx) + continue; + if (pl->picnum == skyflatnum) { Portal_AddSkybox(pl); diff --git a/src/r_portal.h b/src/r_portal.h index 223dd83be..4c4583903 100644 --- a/src/r_portal.h +++ b/src/r_portal.h @@ -58,7 +58,6 @@ void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, con void Portal_ClipApply (const portal_t* portal); -void Portal_AddSkybox(const visplane_t* plane); void Portal_AddSkyboxPortals(void); #ifdef __cplusplus From 7971f768850ea8612ccfac8e5d4fa62554789853 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 13 Jul 2026 07:42:38 +0200 Subject: [PATCH 499/589] software: cleanup sky hacks still horrid, but atleast this wont give me braindamage each time i have to look at it this also read stale data from the previous frames and was just insanely messy this still sucks ass but oh well --- src/r_segs.cpp | 128 +++++++++++++++++++++++++++---------------------- 1 file changed, 71 insertions(+), 57 deletions(-) diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 8460d4679..8a2693c84 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -713,16 +713,11 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf rw_scalestep = drawseg->scalestep; spryscale = drawseg->scale1 + (x1 - drawseg->x1)*rw_scalestep; -#define CLAMPMAX INT32_MAX -#define CLAMPMIN (-INT32_MAX) // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out. auto overflow_clamp = [&](INT64 overflow_test) { - return (overflow_test > (INT64)CLAMPMAX) ? CLAMPMAX : - (overflow_test > (INT64)CLAMPMIN) ? (fixed_t)overflow_test : - CLAMPMIN; + // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out. + return (fixed_t)std::clamp(overflow_test, (-INT32_MAX), INT32_MAX); }; -#undef CLAMPMAX -#undef CLAMPMIN dc->numlights = 0; if (frontsector->numlights) @@ -2604,71 +2599,91 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (linedef->special == HORIZONSPECIAL) // HORIZON LINES { topstep = bottomstep = 0; - topfrac = bottomfrac = (centeryfrac>>4); + topfrac = bottomfrac = (centeryfrac >> 4); topfrac++; // Prevent 1px HOM } else { + topstep = -FixedMul(rw_scalestep, worldtop); + topfrac = (centeryfrac >> 4) - FixedMul(worldtop, rw_scale); + // for anyone that sees this // dont. // this is absolute shit-tier hacks // but i just cant determine this in any sane way // but this checks a shitton of things to make software handle skies better - auto set_topstep_normal = [&] - { - topstep = -FixedMul(rw_scalestep, worldtop); - topfrac = (centeryfrac>>4) - FixedMul(worldtop, rw_scale); - }; - // untextured seg - if (!segtextured && !curline->polyseg) + if (!segtextured && !curline->polyseg) // not for polyobjects..... { - const bool tophigh = (worldhigh <= worldtop && worldhighslope <= worldtopslope); + const boolean nofrontsky = (frontsector->floorpic != skyflatnum && frontsector->ceilingpic != skyflatnum); + const boolean inskybox = (skyboxmo[0] && cv_skybox.value && newview->sky); // dont mess with skyVisible within skybox rendering! - // if we cant see the goddamn skyplane, well there wont be any skybox - // we could kill skyVisible instead, but i want to keep the performance improvements it yields - // so we do this absolute trash - if ((tophigh - && (frontsector->floorpic != skyflatnum && frontsector->ceilingpic != skyflatnum)) // try to guess if its a "window" - && ((!backsector) // single sided - || ((backsector && (worldhigh != worldtop || worldhighslope != worldtopslope)) - && (backsector->floorheight >= frontsector->ceilingheight || backsector->ceilingheight <= frontsector->floorheight)))) // check if there is a "thok" sector behind it - skyVisible = true; - - // this is an attempt to fix issues with textureless single sided lines drawing nothing where they should just draw sky instead - if (tophigh && !backsector && frontsector->ceilingpic == skyflatnum) + // single sided line + if (!backsector) { - // account for slopes to try and get rid of sharp edges from the black void - if (frontsector->f_slope || (backsector && backsector->f_slope)) + // this is an attempt to fix issues with textureless single sided lines drawing nothing where they should just draw sky instead + + // there is a sky flat on the ceiling + // so we can assume this is supposed to draw the sky + if (frontsector->ceilingpic == skyflatnum) { - topstep = -FixedMul(rw_scalestep, worldbottomslope); - topfrac = (centeryfrac>>4) - FixedMul(worldbottomslope, rw_scale); + // just draw sky from top to bottom! + if (frontsector->f_slope) + { + topstep = -FixedMul(rw_scalestep, worldbottomslope); + topfrac = (centeryfrac >> 4) - FixedMul(worldbottomslope, rw_scale); + } + else + { + topstep = -FixedMul(rw_scalestep, worldbottom); + topfrac = (centeryfrac >> 4) - FixedMul(worldbottom, rw_scale); + } } - else + else if (nofrontsky && !inskybox) { - topstep = -FixedMul(rw_scalestep, worldbottom); - topfrac = (centeryfrac>>4) - FixedMul(worldbottom, rw_scale); + // completely empty wall without sky flats, just assume skybox is visible then + skyVisible = true; } } - else - set_topstep_normal(); + else if (nofrontsky && !inskybox) // if there was a skyflat, drawplane would already set skyvisible + { + // "thok walls" are double sided + // so we need to check a few things here + // to be rather conservative + // as skyrendering is pretty costly! + + // ideally we´d just dont care and always draw the skytexture + // or skybox at any time, like gl does + // wonder if there would be a fast way to draw atleast just the texture? + + // gotta shift those here for proper comparisons + const INT32 whigh = worldhigh >> 4; + const INT32 whslope = worldhighslope >> 4; + + // check if there is a window to force skybox to draw + if ((whigh <= worldtop && whslope <= worldtopslope) && (backsector->ceilingpic == skyflatnum)) // backsector has a skyflat? + skyVisible = true; + // otherwise check for thokwalls + else if ((whigh != worldtop || whslope != worldtopslope) && // FIXME: i forgor what this was for lol + (backsector->floorheight >= frontsector->ceilingheight || // thok walls usually are set up like that... + frontsector->floorheight >= backsector->ceilingheight)) // floor higher than the other sides ceiling + skyVisible = true; + } } - else - set_topstep_normal(); bottomstep = -FixedMul(rw_scalestep, worldbottom); - bottomfrac = (centeryfrac>>4) - FixedMul(worldbottom, rw_scale); + bottomfrac = (centeryfrac >> 4) - FixedMul(worldbottom, rw_scale); if (frontsector->c_slope) { - fixed_t topfracend = (centeryfrac>>4) - FixedMul(worldtopslope, ds_p->scale2); + fixed_t topfracend = (centeryfrac >> 4) - FixedMul(worldtopslope, ds_p->scale2); topstep = (topfracend-topfrac)/(range); } if (frontsector->f_slope) { - fixed_t bottomfracend = (centeryfrac>>4) - FixedMul(worldbottomslope, ds_p->scale2); + fixed_t bottomfracend = (centeryfrac >> 4) - FixedMul(worldbottomslope, ds_p->scale2); bottomstep = (bottomfracend-bottomfrac)/(range); } } @@ -2706,12 +2721,13 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (leftheight < worldbottom && rightheight < worldbottomslope) continue; - if (leftheight > worldtop && rightheight > worldtopslope && i+1 < dc.numlights && frontsector->lightlist[i+1].height > frontsector->ceilingheight) + if ((leftheight > worldtop) && (rightheight > worldtopslope) && + (i+1 < dc.numlights) && (frontsector->lightlist[i+1].height > frontsector->ceilingheight)) continue; } - rlight->height = (centeryfrac>>4) - FixedMul(leftheight, rw_scale); - rlight->heightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2); + rlight->height = (centeryfrac >> 4) - FixedMul(leftheight, rw_scale); + rlight->heightstep = (centeryfrac >> 4) - FixedMul(rightheight, ds_p->scale2); rlight->heightstep = (rlight->heightstep-rlight->height)/(range); rlight->flags = static_cast(light->flags); @@ -2730,10 +2746,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) leftheight >>= 4; rightheight >>= 4; - rlight->botheight = (centeryfrac>>4) - FixedMul(leftheight, rw_scale); - rlight->botheightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2); + rlight->botheight = (centeryfrac >> 4) - FixedMul(leftheight, rw_scale); + rlight->botheightstep = (centeryfrac >> 4) - FixedMul(rightheight, ds_p->scale2); rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range); - } rlight->lightlevel = *light->lightlevel; @@ -2754,13 +2769,14 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (linedef->special == HORIZONSPECIAL) // Horizon lines extend FOFs in contact with them too. { visffloor[i].f_step = 0; - visffloor[i].f_frac = (centeryfrac>>4); + visffloor[i].f_frac = (centeryfrac >> 4); topfrac++; // Prevent 1px HOM } else { - visffloor[i].f_frac = (centeryfrac>>4) - FixedMul(visffloor[i].f_pos, rw_scale); - visffloor[i].f_step = ((centeryfrac>>4) - FixedMul(visffloor[i].f_pos_slope, ds_p->scale2) - visffloor[i].f_frac)/(range); + visffloor[i].f_frac = (centeryfrac >> 4) - FixedMul(visffloor[i].f_pos, rw_scale); + visffloor[i].f_step = (centeryfrac >> 4) - FixedMul(visffloor[i].f_pos_slope, ds_p->scale2); + visffloor[i].f_step = (visffloor[i].f_step - visffloor[i].f_frac)/(range); } } } @@ -2774,9 +2790,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (toptexture) { - fixed_t topfracend = (centeryfrac>>4) - FixedMul(worldhighslope, ds_p->scale2); - - pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); + fixed_t topfracend = (centeryfrac >> 4) - FixedMul(worldhighslope, ds_p->scale2); + pixhigh = (centeryfrac >> 4) - FixedMul(worldhigh, rw_scale); pixhighstep = (topfracend-pixhigh)/(range); // If the lowest part of a ceiling stretching down covers the entire screen @@ -2786,9 +2801,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (bottomtexture) { - fixed_t bottomfracend = (centeryfrac>>4) - FixedMul(worldlowslope, ds_p->scale2); - - pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); + fixed_t bottomfracend = (centeryfrac >> 4) - FixedMul(worldlowslope, ds_p->scale2); + pixlow = (centeryfrac >> 4) - FixedMul(worldlow, rw_scale); pixlowstep = (bottomfracend-pixlow)/(range); // If the highest part of a floor stretching up covers the entire screen From b27b4bfd7a11b6913b8f9ed81320d0907c7624fa Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 13 Jul 2026 07:43:33 +0200 Subject: [PATCH 500/589] software: fix cv_spriteclip scaled sprites should be excluded from the simple viewwindow checks also R_CheckSpriteVisible should be done AFTER portal adjustments --- src/r_things.cpp | 95 +++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 46 deletions(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index ee517c11f..79c280ee5 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -87,6 +87,8 @@ static drawseg_xrange_item_t *drawsegs_xrange; static size_t drawsegs_xrange_size = 0; static INT32 drawsegs_xrange_count = 0; +#define CLIP_UNDEF -2 + // // Sprite rotation 0 is facing the viewer, // rotation 1 is one angle turn CLOCKWISE around the axis. @@ -2221,6 +2223,7 @@ static void R_SortVisSprites(vissprite_t* vsprsortedhead, UINT32 start, UINT32 e best = ds; } } + if (best) { best->next->prev = best->prev; @@ -2629,7 +2632,7 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port for (x = x1; x <= x2; x++) { - spr->clipbot[x] = spr->cliptop[x] = -2; + spr->clipbot[x] = spr->cliptop[x] = CLIP_UNDEF; } // Scan drawsegs from end to start for obscuring segs. @@ -2658,29 +2661,26 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port ds = curr->user; - if (ds->portalpass != 66) // unused? + if (ds->portalpass > 0 && ds->portalpass <= portalrender) + continue; // is a portal + + if (ds->scale1 > ds->scale2) { - if (ds->portalpass > 0 && ds->portalpass <= portalrender) - continue; // is a portal + lowscale = ds->scale2; + scale = ds->scale1; + } + else + { + lowscale = ds->scale1; + scale = ds->scale2; + } - if (ds->scale1 > ds->scale2) - { - lowscale = ds->scale2; - scale = ds->scale1; - } - else - { - lowscale = ds->scale1; - scale = ds->scale2; - } - - if (scale < spr->sortscale || - (lowscale < spr->sortscale && - !R_PointOnSegSide(spr->gx, spr->gy, ds->curline))) - { - // seg is behind sprite - continue; - } + if (scale < spr->sortscale || + (lowscale < spr->sortscale && + !R_PointOnSegSide(spr->gx, spr->gy, ds->curline))) + { + // seg is behind sprite + continue; } r1 = ds->x1 < x1 ? x1 : ds->x1; @@ -2699,14 +2699,14 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port { // bottom sil for (x = r1; x <= r2; x++) - if (spr->clipbot[x] == -2) + if (spr->clipbot[x] == CLIP_UNDEF) spr->clipbot[x] = ds->sprbottomclip[x]; } else if (silhouette == SIL_TOP) { // top sil for (x = r1; x <= r2; x++) - if (spr->cliptop[x] == -2) + if (spr->cliptop[x] == CLIP_UNDEF) spr->cliptop[x] = ds->sprtopclip[x]; } else if (silhouette == (SIL_TOP|SIL_BOTTOM)) @@ -2714,9 +2714,9 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port // both for (x = r1; x <= r2; x++) { - if (spr->clipbot[x] == -2) + if (spr->clipbot[x] == CLIP_UNDEF) spr->clipbot[x] = ds->sprbottomclip[x]; - if (spr->cliptop[x] == -2) + if (spr->cliptop[x] == CLIP_UNDEF) spr->cliptop[x] = ds->sprtopclip[x]; } } @@ -2735,13 +2735,13 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port if (mh <= 0 || (phs != -1 && viewz > sectors[phs].floorheight)) { // clip bottom for (x = x1; x <= x2; x++) - if (spr->clipbot[x] == -2 || h < spr->clipbot[x]) + if (spr->clipbot[x] == CLIP_UNDEF || h < spr->clipbot[x]) spr->clipbot[x] = (INT16)h; } else // clip top { for (x = x1; x <= x2; x++) - if (spr->cliptop[x] == -2 || h > spr->cliptop[x]) + if (spr->cliptop[x] == CLIP_UNDEF || h > spr->cliptop[x]) spr->cliptop[x] = (INT16)h; } } @@ -2753,13 +2753,13 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port if (phs != -1 && viewz >= sectors[phs].ceilingheight) { // clip bottom for (x = x1; x <= x2; x++) - if (spr->clipbot[x] == -2 || h < spr->clipbot[x]) + if (spr->clipbot[x] == CLIP_UNDEF || h < spr->clipbot[x]) spr->clipbot[x] = (INT16)h; } else // clip top { for (x = x1; x <= x2; x++) - if (spr->cliptop[x] == -2 || h > spr->cliptop[x]) + if (spr->cliptop[x] == CLIP_UNDEF || h > spr->cliptop[x]) spr->cliptop[x] = (INT16)h; } } @@ -2769,10 +2769,10 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port { for (x = x1; x <= x2; x++) { - if (spr->cliptop[x] == -2 || spr->szt > spr->cliptop[x]) + if (spr->cliptop[x] == CLIP_UNDEF || spr->szt > spr->cliptop[x]) spr->cliptop[x] = spr->szt; - if (spr->clipbot[x] == -2 || spr->sz < spr->clipbot[x]) + if (spr->clipbot[x] == CLIP_UNDEF || spr->sz < spr->clipbot[x]) spr->clipbot[x] = spr->sz; } } @@ -2780,7 +2780,7 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port { for (x = x1; x <= x2; x++) { - if (spr->cliptop[x] == -2 || spr->szt > spr->cliptop[x]) + if (spr->cliptop[x] == CLIP_UNDEF || spr->szt > spr->cliptop[x]) spr->cliptop[x] = spr->szt; } } @@ -2788,7 +2788,7 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port { for (x = x1; x <= x2; x++) { - if (spr->clipbot[x] == -2 || spr->sz < spr->clipbot[x]) + if (spr->clipbot[x] == CLIP_UNDEF || spr->sz < spr->clipbot[x]) spr->clipbot[x] = spr->sz; } } @@ -2798,21 +2798,13 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port // check for unclipped columns for (x = x1; x <= x2; x++) { - if (spr->clipbot[x] == -2) + if (spr->clipbot[x] == CLIP_UNDEF) spr->clipbot[x] = (INT16)viewheight; - if (spr->cliptop[x] == -2) + if (spr->cliptop[x] == CLIP_UNDEF) spr->cliptop[x] = -1; } - // Check if it'll be visible - // Not done for floorsprites. - if (cv_spriteclip.value) - { - if (!R_CheckSpriteVisible(spr, x1, x2)) - spr->cut = static_cast(spr->cut | SC_NOTVISIBLE); - } - if (portal) { INT32 start_index = std::max(portal->start, x1); @@ -2823,6 +2815,7 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port spr->clipbot[x] = -1; spr->cliptop[x] = -1; } + for (x = start_index; x <= end_index; x++) { if (spr->clipbot[x] > portal->floorclip[x - portal->start]) @@ -2830,12 +2823,21 @@ static void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* port if (spr->cliptop[x] < portal->ceilingclip[x - portal->start]) spr->cliptop[x] = portal->ceilingclip[x - portal->start]; } + for (x = end_index + 1; x <= x2; x++) { spr->clipbot[x] = -1; spr->cliptop[x] = -1; } } + + // Check if it'll be visible + // Not done for floorsprites. + if (cv_spriteclip.value) + { + if (!R_CheckSpriteVisible(spr, x1, x2)) + spr->cut = static_cast(spr->cut | SC_NOTVISIBLE); + } } void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) @@ -2908,8 +2910,9 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) { vissprite_t *spr = R_GetVisSprite(clippedvissprites); - if (cv_spriteclip.value - && (spr->szt > vid.height || spr->sz < 0)) + if (cv_spriteclip.value && + (spr->szt > vid.height || spr->sz < 0) && + !spr->scalestep) { spr->cut = static_cast(spr->cut | SC_NOTVISIBLE); continue; From ba0b414062c67e3d4955499b6208286bf754c3c2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 13 Jul 2026 20:31:20 +0200 Subject: [PATCH 501/589] fix paletterender toggle calling setpalette during startup --- src/st_stuff.c | 4 +++- src/v_video.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 57a7c6e29..c8bdd5d51 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -14,6 +14,7 @@ /// Does palette indicators as well (red pain/berserk, bright pickup) #include "doomdef.h" +#include "d_main.h" #include "g_game.h" #include "g_input.h" #include "k_director.h" @@ -172,7 +173,8 @@ INT32 st_palette = 0; void ST_ResetPaletteStuff(void) { st_palette = 0; - V_SetPalette(0); + if (loaded_config) + V_SetPalette(0); } static void ST_doPaletteStuff(void) diff --git a/src/v_video.c b/src/v_video.c index fc84a0cdc..109eac171 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -676,6 +676,7 @@ static void CV_palette_OnChange(void) { if (!loaded_config) return; + // reload palette // recalculate Color Cube V_ReloadPalette(); From 587f24ae859f157f10a3225dbb3b609c6338ddad Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 13 Jul 2026 23:56:47 +0300 Subject: [PATCH 502/589] Add empty I_OpenURL into dedicated server build --- src/dedicated/i_system.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index fc38ffdef..d4a1397b9 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1419,6 +1419,11 @@ static void I_Fork(void) } #endif/*NEWSIGNALHANDLER*/ +int I_OpenURL(const char *url) +{ + return -1; +} + INT32 I_StartupSystem(void) { I_StartupConsole(); From 53fbbecbcdc6cafaeff13aee3db9821ee58df48f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 14 Jul 2026 01:32:51 +0200 Subject: [PATCH 503/589] fix incrementing garbage in Portal_AddSkyboxPortals --- src/r_portal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_portal.c b/src/r_portal.c index 00baad528..f403c17c7 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -333,7 +333,7 @@ void Portal_AddSkyboxPortals(void) INT32 i; UINT16 count = 0; - for (i = 0; i < MAXVISPLANES; i++, pl++) + for (i = 0; i < MAXVISPLANES; i++) { for (pl = visplanes[i]; pl; pl = pl->next) { From d0f02f15308e1a5ebfc7a25d281f00be6f889a77 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 14 Jul 2026 09:40:20 +0200 Subject: [PATCH 504/589] remove pointless skybox check here if skybox then newview->sky will be false there which R_DrawSkyPlanes will check for --- src/r_main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index d6fe70c2d..ad8f1aa0a 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1525,8 +1525,7 @@ void R_RenderPlayerView(player_t *player) R_SetColumnContext(COLUMNCONTEXT_DIRECT); PS_START_TIMING(ps_sw_planetime); - if (!skybox) - R_DrawSkyPlanes(); + R_DrawSkyPlanes(); R_DrawPlanes(); PS_STOP_TIMING(ps_sw_planetime); // draw mid texture and sprite From 28c4061a26f067c6a70b13c4acddc1856bd45740 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 14 Jul 2026 09:39:14 +0200 Subject: [PATCH 505/589] remove viewsky which doesent exist lol --- src/r_state.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_state.h b/src/r_state.h index 0431525e7..5e226103b 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -90,7 +90,7 @@ extern side_t *sides; extern fixed_t viewx, viewy, viewz; extern angle_t viewangle, aimingangle, viewroll; extern UINT8 viewssnum; // splitscreen view number -extern boolean viewsky, skyVisible; +extern boolean skyVisible; extern boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible of each splitscreen player extern sector_t *viewsector; extern player_t *viewplayer; From ee9c9e283945e4cd461c2f06da337688e6dd890b Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 14 Jul 2026 11:28:40 +0200 Subject: [PATCH 506/589] hack: fix paletterender stuff not applying to screenshots/gifs when using downsampling fbo this sucks but the final screen texture with the palette render postprocess step will not be in the downsample fbo so we have to redraw it there with the postprocess step...... this is still better than drawing another screen texture when using paletterender which costs perf --- src/hardware/r_opengl/r_opengl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index aff722773..0c04beb09 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1465,6 +1465,19 @@ void GL_ReadScreenTexture(int tex, UINT8 *restrict dest, INT32 scale) if (tex != HWD_SCREENTEXTURE_GENERIC2) GL_DrawScreenTexture(tex, NULL, 0); +#ifdef USE_FBO_OGL + // FIXME: this is incredibly stupid + // but the final screen texture will NOT be drawn in the downsample fbo + if (tex == HWD_SCREENTEXTURE_GENERIC2 && + UseScreenFBO() && HWR_ShouldUsePaletteRendering()) + { + GL_SetShader(HWR_GetShaderFromTarget(SHADER_PALETTE_POSTPROCESS)); + GL_EnableShader(); + GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC2, NULL, 0); + GL_UnSetShader(); + } +#endif + image = malloc(screen_width*screen_height*3); pglPixelStorei(GL_PACK_ALIGNMENT, 1); pglReadPixels(0, 0, screen_width, screen_height, GL_RGB, GL_UNSIGNED_BYTE, image); From 7ee93d889eb41f16dc4c7670ca1b8c1332cb8fdb Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 16 Jul 2026 20:16:33 +0200 Subject: [PATCH 507/589] remove this from polyvertex_t was used for optimization but not used anymore --- src/hardware/hw_defs.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 6a8649099..ed4bff5a2 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -96,7 +96,6 @@ typedef struct typedef struct { float x, y, z; - fixed_t x2, y2, z2; } polyvertex_t; // a convex 'plane' polygon, clockwise order From a1127068df439077a6ad3cc8a86db78008d29503 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Jul 2026 22:42:24 +0200 Subject: [PATCH 508/589] fix wireframe potentially not disabling on toggle netupdate sucks ass --- src/hardware/hw_main.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index fbd9702ce..562be50bb 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3483,6 +3483,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) fixed_t v1x, v1y, v2x, v2y; INT32 shader = SHADER_NONE; + const boolean billboarding = (cv_glspritebillboarding.value && !cv_glshearing.value && !papersprite); + gpatch = spr->gpatch; // cache the patch in the graphics card memory @@ -3680,7 +3682,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) wallVerts[1].y = endbot; // The x and y only need to be adjusted in the case that it's not a papersprite - if (cv_glspritebillboarding.value && !cv_glshearing.value && !papersprite) + if (billboarding) { // Get the x and z of the vertices so billboarding draws correctly realheight = realbot - realtop; @@ -5451,6 +5453,8 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool { gl_portallist_t portallist; + const boolean wireframe = HWR_IsWireframeMode(); + player_t *viewplayer = &players[displayplayers[viewssnum]]; const float fpov = FixedToFloat(R_GetPlayerFov(viewplayer)); @@ -5511,7 +5515,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool } } - if (HWR_IsWireframeMode()) + if (wireframe) GL_SetSpecialState(HWD_SET_WIREFRAME, 1); // FIXME: perfstats does not account for portal rendering! @@ -5597,7 +5601,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool HWR_RenderDrawNodes(); - if (HWR_IsWireframeMode()) + if (wireframe) GL_SetSpecialState(HWD_SET_WIREFRAME, 0); HWR_FreePortalList(portallist); // always call this just in case From 6892c212d1483b1fb5a151480d0b571f6585315d Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 19 Jul 2026 03:31:09 +0300 Subject: [PATCH 509/589] Comment out stairjank particles for now, since spawning mobjs during P_TryMove may mess up some global variables --- src/p_map.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index ce43c2235..646e88708 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2613,7 +2613,9 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (cv_stairjanksfx.value) S_StartSoundAtVolume(thing, (thing->player->stairjank >= 8 ? sfx_s23b : sfx_s268), 192); // dont blast this at full volume lul - //if (!thing->player->stairjank) + // Can't spawn things during P_TryMove, because global variables :) + // TODO - move this elsewhere later, should probably be safe in K_KartPlayerThink or something + /*if (!thing->player->stairjank) { // 90 degrees to direction you're facing fixed_t dirx = -FINESINE(thing->angle>>ANGLETOFINESHIFT); @@ -2639,7 +2641,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) P_SetTarget(&spark->target, thing); //P_SetTarget(&spark->owner, thing); //spark->renderflags |= RF_REDUCEVFX; - } + }*/ thing->player->stairjank = 9; //thing->player->stairjank = 17; From 267a7584471d948e0ea3d7bac3a45f129b25ff75 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 19 Jul 2026 02:36:08 +0200 Subject: [PATCH 510/589] fix up dedi i_system --- src/dedicated/i_system.c | 53 +++++++++++++++++++++++----------------- src/sdl/i_system.cpp | 16 ++++++------ 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index d4a1397b9..b6d50a712 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -162,8 +162,7 @@ const char *wadSearchPaths[] = { /** \brief WAD file to look for */ -#define WADKEYWORD1 "srb2.srb" -#define WADKEYWORD2 "srb2.wad" +#define WADKEYWORD "srb2.srb" /** \brief holds wad path */ static char returnWadPath[256]; @@ -526,16 +525,23 @@ void I_OutputMsg(const char *fmt, ...) { size_t len; char *txt; - va_list argptr; + va_list argptr; - va_start(argptr,fmt); + if (!fmt) + return; + + va_start(argptr, fmt); len = vsnprintf(NULL, 0, fmt, argptr); va_end(argptr); if (len == 0) return; - txt = malloc(len+1); - va_start(argptr,fmt); + txt = (char*)(malloc(len+1)); + + if (!txt) + I_Error("I_OutputMsg: Out of memory!\n"); + + va_start(argptr, fmt); vsprintf(txt, fmt, argptr); va_end(argptr); @@ -1421,6 +1427,7 @@ static void I_Fork(void) int I_OpenURL(const char *url) { + (void)url; return -1; } @@ -1813,20 +1820,12 @@ const char *I_ClipboardPaste(void) */ static boolean isWadPathOk(const char *path) { - char *wad3path = malloc(256); + char *wad3path = (char*)(malloc(256)); if (!wad3path) return false; - sprintf(wad3path, pandf, path, WADKEYWORD1); - - if (FIL_ReadFileOK(wad3path)) - { - free(wad3path); - return true; - } - - sprintf(wad3path, pandf, path, WADKEYWORD2); + sprintf(wad3path, pandf, path, WADKEYWORD); if (FIL_ReadFileOK(wad3path)) { @@ -1843,12 +1842,17 @@ static void pathonly(char *s) size_t j; for (j = strlen(s); j != (size_t)-1; j--) + { if ((s[j] == '\\') || (s[j] == ':') || (s[j] == '/')) { - if (s[j] == ':') s[j+1] = 0; - else s[j] = 0; + if (s[j] == ':') + s[j+1] = 0; + else + s[j] = 0; + return; } + } } /** \brief search for srb2.srb in the given path @@ -1864,7 +1868,7 @@ static const char *searchWad(const char *searchDir) static char tempsw[256] = ""; filestatus_t fstemp; - strcpy(tempsw, WADKEYWORD1); + strcpy(tempsw, WADKEYWORD); fstemp = filesearch(tempsw, searchDir, NULL, true, 20); if (fstemp == FS_FOUND) { @@ -1985,17 +1989,22 @@ const char *I_LocateWad(void) static long get_entry(const char* name, const char* buf) { long val; - char* hit = strstr(buf, name); - if (hit == NULL) { + const char* hit = strstr(buf, name); + + if (hit == NULL) + { return -1; } errno = 0; val = strtol(hit + strlen(name), NULL, 10); - if (errno != 0) { + + if (errno != 0) + { CONS_Alert(CONS_ERROR, M_GetText("get_entry: strtol() failed: %s\n"), strerror(errno)); return -1; } + return val; } #endif diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index fb4f0dcd5..dd3508efd 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -178,8 +178,7 @@ const char *wadSearchPaths[] = { /** \brief WAD file to look for */ -#define WADKEYWORD1 "srb2.srb" -#define WADKEYWORD2 "srb2.wad" +#define WADKEYWORD "srb2.srb" /** \brief holds wad path */ static char returnWadPath[256]; @@ -561,12 +560,12 @@ void I_OutputMsg(const char *fmt, ...) { size_t len; char *txt; - va_list argptr; + va_list argptr; if (!fmt) return; - va_start(argptr,fmt); + va_start(argptr, fmt); len = vsnprintf(NULL, 0, fmt, argptr); va_end(argptr); if (len == 0) @@ -577,7 +576,7 @@ void I_OutputMsg(const char *fmt, ...) if (!txt) I_Error("I_OutputMsg: Out of memory!\n"); - va_start(argptr,fmt); + va_start(argptr, fmt); vsprintf(txt, fmt, argptr); va_end(argptr); @@ -2265,7 +2264,6 @@ void I_ShutdownSystem(void) logstream = NULL; } #endif - } void I_GetDiskFreeSpace(INT64 *freespace) @@ -2437,7 +2435,7 @@ static boolean isWadPathOk(const char *path) if (!wad3path) return false; - sprintf(wad3path, pandf, path, WADKEYWORD1); + sprintf(wad3path, pandf, path, WADKEYWORD); if (FIL_ReadFileOK(wad3path)) { @@ -2477,10 +2475,10 @@ static void pathonly(char *s) */ static const char *searchWad(const char *searchDir) { - static char tempsw[255] = ""; + static char tempsw[256] = ""; filestatus_t fstemp; - strcpy(tempsw, WADKEYWORD1); + strcpy(tempsw, WADKEYWORD); fstemp = filesearch(tempsw, searchDir, NULL, true, 20); if (fstemp == FS_FOUND) { From 735c4b67dc6f154c295b8033f7c4aa32d4e424ff Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 19 Jul 2026 02:35:47 +0200 Subject: [PATCH 511/589] move stairjank particles into K_MoveKartPlayer to where we also rotate the player also means we now use K_AltFlip :p also means the visual toggle now actually does prevent spawning them --- src/k_kart.c | 22 ++++++++++++++++++++++ src/p_map.c | 28 ---------------------------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 0196bb521..e77c0b5ee 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7055,6 +7055,28 @@ void K_MoveKartPlayer(player_t *player, boolean onground) // "Stair jank" visuals akin to RR if (cv_stairjank.value && player->stairjank > 0) { + // only spawn em once + if (player->stairjank > 8) + { + // 90 degrees to direction you're facing + fixed_t dirx = -FINESINE(player->mo->angle>>ANGLETOFINESHIFT); + fixed_t diry = FINECOSINE(player->mo->angle>>ANGLETOFINESHIFT); + fixed_t offset = player->mo->radius; + + dirx = K_AltFlip(-dirx, 4); + diry = K_AltFlip(-diry, 4); + + mobj_t * spark = P_SpawnMobj(player->mo->x + FixedMul(dirx, offset), player->mo->y + FixedMul(diry, offset), player->mo->z, MT_DRIFTDUST); + spark->momx = FixedMul(dirx, FRACUNIT) + (6 + ((int)leveltime % 5))*(player->mo->momx)/10; + spark->momy = FixedMul(diry, FRACUNIT) + (6 + ((int)leveltime % 5))*(player->mo->momy)/10; + spark->momz = 5*FRACUNIT; + spark->scale = mapobjectscale/5; + spark->destscale = mapobjectscale/2; + spark->islocal = true; + spark->color = SKINCOLOR_WHITE; + P_SetTarget(&spark->target, player->mo); + } + player->mo->temprollangle += K_StairJankFlip(ANGLE_11hh / 2 / (17 / player->stairjank)); // TODO: make strength adjustable? } diff --git a/src/p_map.c b/src/p_map.c index 646e88708..5436e144c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2614,34 +2614,6 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) S_StartSoundAtVolume(thing, (thing->player->stairjank >= 8 ? sfx_s23b : sfx_s268), 192); // dont blast this at full volume lul // Can't spawn things during P_TryMove, because global variables :) - // TODO - move this elsewhere later, should probably be safe in K_KartPlayerThink or something - /*if (!thing->player->stairjank) - { - // 90 degrees to direction you're facing - fixed_t dirx = -FINESINE(thing->angle>>ANGLETOFINESHIFT); - fixed_t diry = FINECOSINE(thing->angle>>ANGLETOFINESHIFT); - fixed_t offset = thing->radius; - - if (leveltime % 8 < 4) - { - dirx = -dirx; - diry = -diry; - } - - mobj_t * spark = P_SpawnMobj(thing->x + FixedMul(dirx, offset), thing->y + FixedMul(diry, offset), thing->z, MT_DRIFTDUST); - spark->momx = FixedMul(dirx, FRACUNIT) + (6 + ((int)leveltime % 5))*(thing->momx)/10; - spark->momy = FixedMul(diry, FRACUNIT) + (6 + ((int)leveltime % 5))*(thing->momy)/10; - spark->momz = 5*FRACUNIT; - spark->scale = mapobjectscale/5; - spark->destscale = mapobjectscale/2; - spark->islocal = true; - //spark->fuse = 9; - spark->color = SKINCOLOR_WHITE; - //spark->cusval = K_StairJankFlip(ANGLE_90); - P_SetTarget(&spark->target, thing); - //P_SetTarget(&spark->owner, thing); - //spark->renderflags |= RF_REDUCEVFX; - }*/ thing->player->stairjank = 9; //thing->player->stairjank = 17; From f09c61cee98d12171621bc82b345e2b1b92036da Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 19 Jul 2026 02:42:10 +0200 Subject: [PATCH 512/589] only play stairjank sound if we have its visuals enabled --- src/p_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index 5436e144c..4ebc9a124 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2610,7 +2610,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) // sound does not work out all that well for kart maps // best i can do... - if (cv_stairjanksfx.value) + if (cv_stairjank.value && cv_stairjanksfx.value) S_StartSoundAtVolume(thing, (thing->player->stairjank >= 8 ? sfx_s23b : sfx_s268), 192); // dont blast this at full volume lul // Can't spawn things during P_TryMove, because global variables :) From 0acfc96812fc5736930347ff7e99d28109edce11 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 19 Jul 2026 04:32:29 +0200 Subject: [PATCH 513/589] attempt to fix kick/ban commands causing dedicated servers to self destruct if a player was specified which was not being in game this is what caused dedis to sometimes go to the main menu --- src/d_clisrv.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8efc2a1cd..1401d3bf0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -110,7 +110,7 @@ SINT8 joinnode = 0; // used for CL_VIEWSERVER boolean player_muted[MAXPLAYERS] = {}; // Server specific vars -UINT8 playernode[MAXPLAYERS] = {}; +UINT8 playernode[MAXPLAYERS] = {UINT8_MAX}; // Minimum timeout for sending the savegame // The actual timeout will be longer depending on the savegame length @@ -3767,6 +3767,10 @@ static void Command_Ban(void) if (pn == -1 || pn == 0) return; + // player does not exist + if (!playeringame[pn]) + return; + WRITEUINT8(p, pn); if (COM_Argc() == 2) @@ -3884,6 +3888,10 @@ static void Command_Kick(void) if (pn == -1 || pn == 0) return; + // player does not exist + if (!playeringame[pn]) + return; + // Special case if we are trying to kick a player who is downloading the game state: // trigger a timeout instead of kicking them, because a kick would only // take effect after they have finished downloading @@ -3933,6 +3941,13 @@ static void Got_KickCmd(const UINT8 **p, INT32 playernum) pnum = READUINT8(*p); msg = READUINT8(*p); + if (pnum >= MAXPLAYERS) + { + CONS_Alert(CONS_WARNING, M_GetText("Illegal kick command received from %s for player %d\n"), player_names[playernum], pnum); + return; + } + + // FIXME: this does not work at all on dedi, servernode == 0 which is prevented from kick/ban command if (pnum == serverplayer && IsPlayerAdmin(playernum)) { CONS_Printf(M_GetText("Server is being shut down remotely. Goodbye!\n")); @@ -3987,6 +4002,16 @@ static void Got_KickCmd(const UINT8 **p, INT32 playernum) msg = KICK_MSG_CON_FAIL; } + // without this the server will remove itself and thus self destruct on dedicated + if (server && (playernode[pnum] == UINT8_MAX || !nodeingame[playernode[pnum]])) + { + CONS_Alert(CONS_WARNING, M_GetText("Attempting to kick player %d which is not in game received from %s\n"), pnum, player_names[playernum]); + return; + } + + // make sure we dont read garbage anywhere + memset(reason, 0, sizeof(buf)); + if (msg == KICK_MSG_CUSTOM_BAN || msg == KICK_MSG_CUSTOM_KICK) { READSTRINGN(*p, reason, MAX_REASONLENGTH+1); From a132db9e6ea030adcbc2ef8c2e6d469cf4fa16dd Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 19 Jul 2026 23:41:19 +0300 Subject: [PATCH 514/589] Attempt to fix server locking up when trying to kick player that has left already --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1401d3bf0..0491b2c3f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4003,7 +4003,7 @@ static void Got_KickCmd(const UINT8 **p, INT32 playernum) } // without this the server will remove itself and thus self destruct on dedicated - if (server && (playernode[pnum] == UINT8_MAX || !nodeingame[playernode[pnum]])) + if (server && !playeringame[pnum]) { CONS_Alert(CONS_WARNING, M_GetText("Attempting to kick player %d which is not in game received from %s\n"), pnum, player_names[playernum]); return; From 5a966aa317293a2a6af52c7d91d69d243836e755 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 20 Jul 2026 01:54:47 +0300 Subject: [PATCH 515/589] Re-add playernode check --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0491b2c3f..a19e916cb 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4003,7 +4003,7 @@ static void Got_KickCmd(const UINT8 **p, INT32 playernum) } // without this the server will remove itself and thus self destruct on dedicated - if (server && !playeringame[pnum]) + if (server && (playernode[pnum] == UINT8_MAX || !playeringame[pnum])) { CONS_Alert(CONS_WARNING, M_GetText("Attempting to kick player %d which is not in game received from %s\n"), pnum, player_names[playernum]); return; From df3a64339c7800a82448e77dee86ad2c8079b23e Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jul 2026 01:00:57 +0200 Subject: [PATCH 516/589] fix skin search command overflow when using localskins and going over the skinlimit this should use numskins not numallskins there no i dont feel like supporting localskins here the other skin commands also dont care --- src/d_netcmd.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 66e4aad3a..452263b75 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1806,7 +1806,7 @@ INT32 D_LookupPlayer(const char *s) if ((playernum = atoi(s))) { - playernum = max(min(playernum, MAXPLAYERS-1), 0);/* not out of range */ + playernum = max(min(playernum, MAXPLAYERS-1), 0); /* not out of range */ return playernum; } @@ -5691,19 +5691,22 @@ static void Command_SkinSearch(void) size_t i; UINT16 s; UINT16 ic = 0; - //skin_t *skininput = &skins[s]; - for (i = 1; i < COM_Argc(); i++){ - for( s = 0 ; s < numallskins ; s++ ) + + for (i = 1; i < COM_Argc(); i++) + { + for (s = 0; s < numskins; s++) { skin_t *skininput = &skins[s]; - if (strcasestr(skininput->realname,COM_Argv(i))) + + if (strcasestr(skininput->realname, COM_Argv(i))) { ic++; - CONS_Printf("%d. %s%s:\x80 %s\n", ic,HU_SkinColorToConsoleColor(skininput->prefcolor),skininput->realname,skininput->name); + CONS_Printf("%d. %s%s:\x80 %s\n", ic, HU_SkinColorToConsoleColor(skininput->prefcolor), skininput->realname, skininput->name); } } } - CONS_Printf("Total %d skins.\n", ic); + + CONS_Printf("Total %d skins.\n", ic); } /** Sends a color change for the console player, unless that player is moving. From 9692484d2e1a75a5a52b9e1e332e2c8a82b2fabc Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jul 2026 11:29:19 +0200 Subject: [PATCH 517/589] fix issues with sound freeslotting this "works" with a skinlimit of 255 but would cause hard to debug crashes with raised skinlimits and was generally really unsafe and could cause soundnames to not be null terminated aswell as buffer overflows from blind strcpy the sprintf fix is from Indev originally for neptune NOTE: if the skinlimit is ever raised above 1024 then freeslotnames NEEDS to be atleast one byte bigger to not truncuate stuff NOTE2: pretty sure localskins are fucked if any are loaded in servers with 255 skins loaded, but i dont care atm --- src/sounds.c | 23 ++++++++++++----------- src/sounds.h | 2 ++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/sounds.c b/src/sounds.c index 3769bf65b..e17e79512 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -972,7 +972,7 @@ sfxinfo_t S_sfx[NUMSFX] = // initialized to NULL }; -char freeslotnames[sfx_freeslot0 + NUMSFXFREESLOTS + NUMSKINSFXSLOTS][7] = {}; +static char freeslotnames[sfx_freeslot0 + NUMSFXFREESLOTS + NUMSKINSFXSLOTS][MAXSOUNDNAME] = {}; // Prepare free sfx slots to add sfx at run time void S_InitRuntimeSounds(void) @@ -985,16 +985,13 @@ void S_InitRuntimeSounds(void) { value = (i+1) - sfx_freeslot0; - if (value < 10) - sprintf(soundname, "fre00%d", value); - else if (value < 100) - sprintf(soundname, "fre0%d", value); - else if (value < 1000) - sprintf(soundname, "fre%d", value); - else - sprintf(soundname, "fr%d", value); + sprintf(soundname, "fr%04x", value); - strcpy(freeslotnames[value-1], soundname); + // this might happen when raising skinlimit + I_Assert(strlen(soundname) < MAXSOUNDNAME); + + strncpy(freeslotnames[value-1], soundname, MAXSOUNDNAME-1); + freeslotnames[value-1][MAXSOUNDNAME-1] = '\0'; S_sfx[i].name = freeslotnames[value-1]; S_sfx[i].singularity = false; @@ -1024,7 +1021,11 @@ sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean { if (!S_sfx[i].priority) { - strncpy(freeslotnames[i-sfx_freeslot0], name, 6); + I_Assert(strlen(name) < MAXSOUNDNAME); + + strncpy(freeslotnames[i - sfx_freeslot0], name, MAXSOUNDNAME-1); + freeslotnames[i - sfx_freeslot0][MAXSOUNDNAME-1] = '\0'; + S_sfx[i].singularity = singular; S_sfx[i].priority = 60; S_sfx[i].pitch = flags; diff --git a/src/sounds.h b/src/sounds.h index ea530da05..a8522f1c6 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -59,6 +59,8 @@ typedef enum #define NUMSFXFREESLOTS 1600 // Matches SOC Editor. #define NUMSKINSFXSLOTS (MAXSKINS*NUMSKINSOUNDS) +#define MAXSOUNDNAME 7 + // // SoundFX struct. // From 8880057ff22022955cdd68ec3aaf9d53906d76f9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jul 2026 15:35:36 +0200 Subject: [PATCH 518/589] fix and cleanup P_SpawnMapThings -split emeraldhunt handling into its own function -merge hoop spawn loop into the main mapthing spawnloop -continue early for things like rings and coins - reduce the amount of R_PointInSubsector on maps with nights hoops hopefully reduces levelload time slightly --- src/p_maputl.cpp | 2 +- src/p_setup.c | 143 ++++++++++++++++++++++++----------------------- 2 files changed, 74 insertions(+), 71 deletions(-) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 041bad1db..7d5c95feb 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -842,7 +842,7 @@ void P_SetThingPosition(mobj_t *thing) // at sector_t->touching_thinglist) are broken. When a node is // added, new sector links are created. - P_CreateSecNodeList(thing,thing->x,thing->y); + P_CreateSecNodeList(thing, thing->x, thing->y); thing->touching_sectorlist = sector_list; // Attach to Thing's mobj_t sector_list = NULL; // clear for next time } diff --git a/src/p_setup.c b/src/p_setup.c index 74f4b876b..affc6b53f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -921,6 +921,47 @@ static void P_LoadThings(UINT8 *data) } } +static void P_SpawnEmeraldHunt(void) +{ + INT32 i; + INT32 emer[3] = {0, 0, 0}; + INT32 timeout = 0; // keeps from getting stuck + fixed_t x, y, z; + + // increment spawn numbers because zero is valid. + emer[0] = (P_RandomKey(numhuntemeralds)) + 1; + while (timeout++ < 100) + { + emer[1] = (P_RandomKey(numhuntemeralds)) + 1; + + if (emer[1] != emer[0]) + break; + } + + timeout = 0; + while (timeout++ < 100) + { + emer[2] = (P_RandomKey(numhuntemeralds)) + 1; + + if (emer[2] != emer[1] && emer[2] != emer[0]) + break; + } + + for (i = 0; i < 3; i++) + { + if (!emer[i]) + continue; + + // decrement spawn values to the actual number because zero is valid. + x = huntemeralds[emer[i] - 1]->x<y<z<type) + if (mt->type == 1700 || // MT_AXIS + mt->type == 1701 || // MT_AXISTRANSFER + mt->type == 1702) // MT_AXISTRANSFERLINE { - case 1700: // MT_AXIS - case 1701: // MT_AXISTRANSFER - case 1702: // MT_AXISTRANSFERLINE - mt->mobj = NULL; - P_SpawnMapThing(mt); - break; - default: - break; + mt->mobj = NULL; + P_SpawnMapThing(mt); } } @@ -951,77 +988,43 @@ static void P_SpawnMapThings(void) // Z for objects mt->z = (INT16)(P_GetSectorFloorZAt(mtsector, (mt->x << FRACBITS), (mt->y << FRACBITS))) >> FRACBITS; - if (mt->type == 1700 // MT_AXIS - || mt->type == 1701 // MT_AXISTRANSFER - || mt->type == 1702) // MT_AXISTRANSFERLINE + if (mt->type == 1700 || // MT_AXIS + mt->type == 1701 || // MT_AXISTRANSFER + mt->type == 1702) // MT_AXISTRANSFERLINE + { continue; // These were already spawned + } + + mt->mobj = NULL; + + // srb2kart - ignore rings, coins and item patterns! + if (mt->type == 300 || mt->type == 308 || mt->type == 309 || + (mt->type >= 600 && mt->type <= 609) || + mt->type == 1706 || mt->type == 1800) + { + continue; + } + + // spawn hoops + if (mt->type == 1705 || mt->type == 1713) + { + // Z for objects Tails 05-26-2002 + mt->z = (INT16)(mtsector->floorheight >> FRACBITS); + + P_SpawnHoops(mt); + continue; + } if (mt->type == mobjinfo[MT_RANDOMITEM].doomednum) nummapboxes++; - mt->mobj = NULL; + // Everything else P_SpawnMapThing(mt); } // random emeralds for hunt if (numhuntemeralds) - { - INT32 emer1, emer2, emer3; - INT32 timeout = 0; // keeps from getting stuck - - emer1 = emer2 = emer3 = 0; - - //increment spawn numbers because zero is valid. - emer1 = (P_RandomKey(numhuntemeralds)) + 1; - while (timeout++ < 100) - { - emer2 = (P_RandomKey(numhuntemeralds)) + 1; - - if (emer2 != emer1) - break; - } - - timeout = 0; - while (timeout++ < 100) - { - emer3 = (P_RandomKey(numhuntemeralds)) + 1; - - if (emer3 != emer2 && emer3 != emer1) - break; - } - - //decrement spawn values to the actual number because zero is valid. - if (emer1) - P_SpawnMobj(huntemeralds[emer1 - 1]->x<y<z<x<y<z<x<y<z<type == 300 || mt->type == 308 || mt->type == 309 - || mt->type == 1706 || (mt->type >= 600 && mt->type <= 609) - || mt->type == 1705 || mt->type == 1713 || mt->type == 1800) - { - mt->mobj = NULL; - - // Z for objects Tails 05-26-2002 - mt->z = (INT16)(R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)->sector->floorheight>>FRACBITS); - - P_SpawnHoops(mt); - } - } + P_SpawnEmeraldHunt(); } static void P_SpawnEmblems(boolean loademblems) From 19e9eedce3e0d89ac056be4d767e9ae3a83ffa49 Mon Sep 17 00:00:00 2001 From: MIDIMan Date: Sun, 19 Jul 2026 16:54:58 -0400 Subject: [PATCH 519/589] Fix NiGHTS hoops crashing the game for mid-level netgame joiners --- src/p_inter.c | 16 +++++++++------- src/p_setup.c | 16 +++++++++++----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 856050959..0cf70f7a0 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -883,18 +883,20 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) break; case MT_HOOPCOLLIDE: // This produces a kind of 'domino effect' with the hoop's pieces. - for (; special->hprev != NULL; special = special->hprev); // Move to the first sprite in the hoop - + for (; special != NULL && special->hprev != NULL; special = special->hprev); // Move to the first sprite in the hoop i = 0; - for (; special->hnext != NULL && special->type == MT_HOOP; special = special->hnext) + for (; special != NULL && special->type == MT_HOOP; special = special->hnext) { - if (!P_MobjWasRemoved(special->target)) + if (!P_MobjWasRemoved(special)) { special->fuse = 11; special->movedir = i; - special->extravalue1 = special->target->extravalue1; - special->extravalue2 = special->target->extravalue2; - special->target->threshold = 4242; + if (!P_MobjWasRemoved(special->target)) + { + special->extravalue1 = special->target->extravalue1; + special->extravalue2 = special->target->extravalue2; + special->target->threshold = 4242; + } } i++; } diff --git a/src/p_setup.c b/src/p_setup.c index affc6b53f..4d7eed838 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -962,7 +962,7 @@ static void P_SpawnEmeraldHunt(void) } } -static void P_SpawnMapThings(void) +static void P_SpawnMapThings(boolean spawnhoops) { size_t i; mapthing_t *mt; @@ -1008,10 +1008,16 @@ static void P_SpawnMapThings(void) // spawn hoops if (mt->type == 1705 || mt->type == 1713) { - // Z for objects Tails 05-26-2002 - mt->z = (INT16)(mtsector->floorheight >> FRACBITS); + // Check for spawnhoops here so the hoops don't spawn ghost variants for players joining a netgame mid-level + // ...It's a long story. + if (spawnhoops) + { + // Z for objects Tails 05-26-2002 + mt->z = (INT16)(mtsector->floorheight >> FRACBITS); + + P_SpawnHoops(mt); + } - P_SpawnHoops(mt); continue; } @@ -3082,7 +3088,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // a shit ton of time loading mobj thinkers. CalculateDoomednumToMobjtype(); - P_SpawnMapThings(); + P_SpawnMapThings(!fromnetsave); P_SpawnEmblems(!fromnetsave); From d73f79509e05f3e1e99eea9e6c18af80e41b188a Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jul 2026 16:04:55 +0200 Subject: [PATCH 520/589] actually reduce pointinsubsector in P_SpawnMapThings in some cases lol bunch of vanilla maps have rings and stuff present lul --- src/p_setup.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 4d7eed838..28c02d52d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -983,7 +983,18 @@ static void P_SpawnMapThings(boolean spawnhoops) for (i = 0, mt = mapthings; i < nummapthings; i++, mt++) { - sector_t *mtsector = R_PointInSubsector((mt->x << FRACBITS), (mt->y << FRACBITS))->sector; + sector_t *mtsector; + + // srb2kart - ignore rings, coins and item patterns! + if (mt->type == 300 || mt->type == 308 || mt->type == 309 || + (mt->type >= 600 && mt->type <= 609) || + mt->type == 1706 || mt->type == 1800) + { + mt->mobj = NULL; + continue; + } + + mtsector = R_PointInSubsector((mt->x << FRACBITS), (mt->y << FRACBITS))->sector; // Z for objects mt->z = (INT16)(P_GetSectorFloorZAt(mtsector, (mt->x << FRACBITS), (mt->y << FRACBITS))) >> FRACBITS; @@ -997,14 +1008,6 @@ static void P_SpawnMapThings(boolean spawnhoops) mt->mobj = NULL; - // srb2kart - ignore rings, coins and item patterns! - if (mt->type == 300 || mt->type == 308 || mt->type == 309 || - (mt->type >= 600 && mt->type <= 609) || - mt->type == 1706 || mt->type == 1800) - { - continue; - } - // spawn hoops if (mt->type == 1705 || mt->type == 1713) { From 3ae968f0606a3f8f6e575402bc20144f62060b06 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jul 2026 16:08:48 +0200 Subject: [PATCH 521/589] smol random cleanups --- src/g_demo.c | 2 +- src/p_setup.c | 14 +++++++------- src/r_skins.c | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 17ed25d85..f4240a42d 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -934,7 +934,7 @@ void G_ConsAllGhostTics(void) void G_ConsGhostTic(INT32 playernum) { UINT8 ziptic; - fixed_t px,py,pz,gx,gy,gz; + fixed_t px, py, pz, gx, gy, gz; mobj_t *testmo; fixed_t syncleeway; boolean nightsfail = false; diff --git a/src/p_setup.c b/src/p_setup.c index 28c02d52d..54b461665 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1047,22 +1047,22 @@ static void P_SpawnEmblems(boolean loademblems) for (i = 0; i < numemblems; i++) { - if (emblemlocations[i].level != gamemap || emblemlocations[i].type > ET_SKIN) + const emblem_t *emblemlocation = &emblemlocations[i]; + + if (emblemlocation->level != gamemap || emblemlocation->type > ET_SKIN) continue; - emblemmobj = P_SpawnMobj(emblemlocations[i].x<x<y<z<= 'A' && emblemlocations[i].sprite <= 'Z'); - P_SetMobjStateNF(emblemmobj, emblemmobj->info->spawnstate + (emblemlocations[i].sprite - 'A')); + I_Assert(emblemlocation->sprite >= 'A' && emblemlocation->sprite <= 'Z'); + P_SetMobjStateNF(emblemmobj, emblemmobj->info->spawnstate + (emblemlocation->sprite - 'A')); emblemmobj->health = i+1; color = M_GetEmblemColor(&emblemlocations[i]); emblemmobj->color = (UINT8)color; - if (emblemlocations[i].collected - || (emblemlocations[i].type == ET_SKIN && emblemlocations[i].var != players[0].skin)) + if (emblemlocation->collected || (emblemlocation->type == ET_SKIN && emblemlocation->var != players[0].skin)) { P_UnsetThingPosition(emblemmobj); emblemmobj->flags |= MF_NOCLIP; diff --git a/src/r_skins.c b/src/r_skins.c index b45dd0d58..181fd3319 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -817,7 +817,6 @@ void R_AddSkins(UINT16 wadnum, boolean local) } #undef lnumskins - //sortSkinGrid(); return; } From d5f68bf2aadc89bcf9d73ab051b9989e117035d2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 20 Jul 2026 16:32:55 +0200 Subject: [PATCH 522/589] fix compiler warning for sound stuff..... :chaosleep: --- src/sounds.c | 1850 +++++++++++++++++++++++++------------------------- 1 file changed, 921 insertions(+), 929 deletions(-) diff --git a/src/sounds.c b/src/sounds.c index e17e79512..26d4ead57 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -28,948 +28,947 @@ sfxinfo_t S_sfx[NUMSFX] = { - /***** Legacy doesn't use the PITCH variable, so now it is used for various flags. See soundflags_t. *****/ - // S_sfx[0] needs to be a dummy for odd reasons. (don't modify this comment) -// name, singularity, priority, pitch, data, length, skinsound, lumpnum - {"none" , false, 0, 0, NULL, 0, -1, LUMPERROR}, + // S_sfx[0] needs to be a dummy for odd reasons. (don't modify this comment) + // name, singularity, priority, pitch, data, length, skinsound, lumpnum + {"none" , false, 0, 0, NULL, 0, -1, LUMPERROR}, - // Skin Sounds - {"altdi1", false, 192, 16, NULL, 0, SKSPLDET1, LUMPERROR}, - {"altdi2", false, 192, 16, NULL, 0, SKSPLDET2, LUMPERROR}, - {"altdi3", false, 192, 16, NULL, 0, SKSPLDET3, LUMPERROR}, - {"altdi4", false, 192, 16, NULL, 0, SKSPLDET4, LUMPERROR}, - {"altow1", false, 192, 16, NULL, 0, SKSPLPAN1, LUMPERROR}, - {"altow2", false, 192, 16, NULL, 0, SKSPLPAN2, LUMPERROR}, - {"altow3", false, 192, 16, NULL, 0, SKSPLPAN3, LUMPERROR}, - {"altow4", false, 192, 16, NULL, 0, SKSPLPAN4, LUMPERROR}, - {"victr1", false, 64, 16, NULL, 0, SKSPLVCT1, LUMPERROR}, - {"victr2", false, 64, 16, NULL, 0, SKSPLVCT2, LUMPERROR}, - {"victr3", false, 64, 16, NULL, 0, SKSPLVCT3, LUMPERROR}, - {"victr4", false, 64, 16, NULL, 0, SKSPLVCT4, LUMPERROR}, - {"gasp" , false, 64, 0, NULL, 0, SKSGASP, LUMPERROR}, - {"jump" , false, 140, 0, NULL, 0, SKSJUMP, LUMPERROR}, - {"pudpud", false, 64, 0, NULL, 0, SKSPUDPUD, LUMPERROR}, - {"putput", false, 64, 0, NULL, 0, SKSPUTPUT, LUMPERROR}, // not as high a priority - {"spin" , false, 100, 0, NULL, 0, SKSSPIN, LUMPERROR}, - {"spndsh", false, 64, 1, NULL, 0, SKSSPNDSH, LUMPERROR}, - {"thok" , false, 96, 0, NULL, 0, SKSTHOK, LUMPERROR}, - {"zoom" , false, 120, 1, NULL, 0, SKSZOOM, LUMPERROR}, - {"skid", false, 64, 32, NULL, 0, SKSSKID, LUMPERROR}, + // Skin Sounds + {"altdi1", false, 192, 16, NULL, 0, SKSPLDET1, LUMPERROR}, + {"altdi2", false, 192, 16, NULL, 0, SKSPLDET2, LUMPERROR}, + {"altdi3", false, 192, 16, NULL, 0, SKSPLDET3, LUMPERROR}, + {"altdi4", false, 192, 16, NULL, 0, SKSPLDET4, LUMPERROR}, + {"altow1", false, 192, 16, NULL, 0, SKSPLPAN1, LUMPERROR}, + {"altow2", false, 192, 16, NULL, 0, SKSPLPAN2, LUMPERROR}, + {"altow3", false, 192, 16, NULL, 0, SKSPLPAN3, LUMPERROR}, + {"altow4", false, 192, 16, NULL, 0, SKSPLPAN4, LUMPERROR}, + {"victr1", false, 64, 16, NULL, 0, SKSPLVCT1, LUMPERROR}, + {"victr2", false, 64, 16, NULL, 0, SKSPLVCT2, LUMPERROR}, + {"victr3", false, 64, 16, NULL, 0, SKSPLVCT3, LUMPERROR}, + {"victr4", false, 64, 16, NULL, 0, SKSPLVCT4, LUMPERROR}, + {"gasp" , false, 64, 0, NULL, 0, SKSGASP, LUMPERROR}, + {"jump" , false, 140, 0, NULL, 0, SKSJUMP, LUMPERROR}, + {"pudpud", false, 64, 0, NULL, 0, SKSPUDPUD, LUMPERROR}, + {"putput", false, 64, 0, NULL, 0, SKSPUTPUT, LUMPERROR}, // not as high a priority + {"spin" , false, 100, 0, NULL, 0, SKSSPIN, LUMPERROR}, + {"spndsh", false, 64, 1, NULL, 0, SKSSPNDSH, LUMPERROR}, + {"thok" , false, 96, 0, NULL, 0, SKSTHOK, LUMPERROR}, + {"zoom" , false, 120, 1, NULL, 0, SKSZOOM, LUMPERROR}, + {"skid", false, 64, 32, NULL, 0, SKSSKID, LUMPERROR}, - // Ambience/background objects/etc - {"ambint", true, 32, 0, NULL, 0, -1, LUMPERROR}, + // Ambience/background objects/etc + {"ambint", true, 32, 0, NULL, 0, -1, LUMPERROR}, - {"alarm", false, 32, 0, NULL, 0, -1, LUMPERROR}, - {"buzz1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"buzz2", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"buzz3", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"buzz4", false, 8, 0, NULL, 0, -1, LUMPERROR}, - {"crumbl", true, 127, 0, NULL, 0, -1, LUMPERROR}, // Platform Crumble Tails 03-16-2001 - {"fire", false, 8, 32, NULL, 0, -1, LUMPERROR}, - {"grind", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"laser", true, 16, 2, NULL, 0, -1, LUMPERROR}, - {"mswing", false, 16, 0, NULL, 0, -1, LUMPERROR}, - {"pstart", false, 100, 0, NULL, 0, -1, LUMPERROR}, - {"pstop", false, 100, 0, NULL, 0, -1, LUMPERROR}, - {"steam1", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Tails 06-19-2001 - {"steam2", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Tails 06-19-2001 - {"wbreak", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"alarm", false, 32, 0, NULL, 0, -1, LUMPERROR}, + {"buzz1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"buzz2", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"buzz3", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"buzz4", false, 8, 0, NULL, 0, -1, LUMPERROR}, + {"crumbl", true, 127, 0, NULL, 0, -1, LUMPERROR}, // Platform Crumble Tails 03-16-2001 + {"fire", false, 8, 32, NULL, 0, -1, LUMPERROR}, + {"grind", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"laser", true, 16, 2, NULL, 0, -1, LUMPERROR}, + {"mswing", false, 16, 0, NULL, 0, -1, LUMPERROR}, + {"pstart", false, 100, 0, NULL, 0, -1, LUMPERROR}, + {"pstop", false, 100, 0, NULL, 0, -1, LUMPERROR}, + {"steam1", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Tails 06-19-2001 + {"steam2", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Tails 06-19-2001 + {"wbreak", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"rainin", true, 24, 4, NULL, 0, -1, LUMPERROR}, - {"litng1", false, 16, 2, NULL, 0, -1, LUMPERROR}, - {"litng2", false, 16, 2, NULL, 0, -1, LUMPERROR}, - {"litng3", false, 16, 2, NULL, 0, -1, LUMPERROR}, - {"litng4", false, 16, 2, NULL, 0, -1, LUMPERROR}, - {"athun1", false, 16, 2, NULL, 0, -1, LUMPERROR}, - {"athun2", false, 16, 2, NULL, 0, -1, LUMPERROR}, + {"rainin", true, 24, 4, NULL, 0, -1, LUMPERROR}, + {"litng1", false, 16, 2, NULL, 0, -1, LUMPERROR}, + {"litng2", false, 16, 2, NULL, 0, -1, LUMPERROR}, + {"litng3", false, 16, 2, NULL, 0, -1, LUMPERROR}, + {"litng4", false, 16, 2, NULL, 0, -1, LUMPERROR}, + {"athun1", false, 16, 2, NULL, 0, -1, LUMPERROR}, + {"athun2", false, 16, 2, NULL, 0, -1, LUMPERROR}, - {"amwtr1", false, 12, 0, NULL, 0, -1, LUMPERROR}, - {"amwtr2", false, 12, 0, NULL, 0, -1, LUMPERROR}, - {"amwtr3", false, 12, 0, NULL, 0, -1, LUMPERROR}, - {"amwtr4", false, 12, 0, NULL, 0, -1, LUMPERROR}, - {"amwtr5", false, 12, 0, NULL, 0, -1, LUMPERROR}, - {"amwtr6", false, 12, 0, NULL, 0, -1, LUMPERROR}, - {"amwtr7", false, 12, 0, NULL, 0, -1, LUMPERROR}, - {"amwtr8", false, 12, 0, NULL, 0, -1, LUMPERROR}, - {"bubbl1", false, 11, 0, NULL, 0, -1, LUMPERROR}, - {"bubbl2", false, 11, 0, NULL, 0, -1, LUMPERROR}, - {"bubbl3", false, 11, 0, NULL, 0, -1, LUMPERROR}, - {"bubbl4", false, 11, 0, NULL, 0, -1, LUMPERROR}, - {"bubbl5", false, 11, 0, NULL, 0, -1, LUMPERROR}, - {"floush", false, 16, 0, NULL, 0, -1, LUMPERROR}, - {"splash", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"splish", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Splish Tails 12-08-2000 - {"wdrip1", false, 8, 0, NULL, 0, -1, LUMPERROR}, - {"wdrip2", false, 8 , 0, NULL, 0, -1, LUMPERROR}, - {"wdrip3", false, 8, 0, NULL, 0, -1, LUMPERROR}, - {"wdrip4", false, 8, 0, NULL, 0, -1, LUMPERROR}, - {"wdrip5", false, 8, 0, NULL, 0, -1, LUMPERROR}, - {"wdrip6", false, 8, 0, NULL, 0, -1, LUMPERROR}, - {"wdrip7", false, 8, 0, NULL, 0, -1, LUMPERROR}, - {"wdrip8", false, 8, 0, NULL, 0, -1, LUMPERROR}, - {"wslap", false, 32, 0, NULL, 0, -1, LUMPERROR}, // Water Slap Tails 12-13-2000 + {"amwtr1", false, 12, 0, NULL, 0, -1, LUMPERROR}, + {"amwtr2", false, 12, 0, NULL, 0, -1, LUMPERROR}, + {"amwtr3", false, 12, 0, NULL, 0, -1, LUMPERROR}, + {"amwtr4", false, 12, 0, NULL, 0, -1, LUMPERROR}, + {"amwtr5", false, 12, 0, NULL, 0, -1, LUMPERROR}, + {"amwtr6", false, 12, 0, NULL, 0, -1, LUMPERROR}, + {"amwtr7", false, 12, 0, NULL, 0, -1, LUMPERROR}, + {"amwtr8", false, 12, 0, NULL, 0, -1, LUMPERROR}, + {"bubbl1", false, 11, 0, NULL, 0, -1, LUMPERROR}, + {"bubbl2", false, 11, 0, NULL, 0, -1, LUMPERROR}, + {"bubbl3", false, 11, 0, NULL, 0, -1, LUMPERROR}, + {"bubbl4", false, 11, 0, NULL, 0, -1, LUMPERROR}, + {"bubbl5", false, 11, 0, NULL, 0, -1, LUMPERROR}, + {"floush", false, 16, 0, NULL, 0, -1, LUMPERROR}, + {"splash", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"splish", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Splish Tails 12-08-2000 + {"wdrip1", false, 8, 0, NULL, 0, -1, LUMPERROR}, + {"wdrip2", false, 8 , 0, NULL, 0, -1, LUMPERROR}, + {"wdrip3", false, 8, 0, NULL, 0, -1, LUMPERROR}, + {"wdrip4", false, 8, 0, NULL, 0, -1, LUMPERROR}, + {"wdrip5", false, 8, 0, NULL, 0, -1, LUMPERROR}, + {"wdrip6", false, 8, 0, NULL, 0, -1, LUMPERROR}, + {"wdrip7", false, 8, 0, NULL, 0, -1, LUMPERROR}, + {"wdrip8", false, 8, 0, NULL, 0, -1, LUMPERROR}, + {"wslap", false, 32, 0, NULL, 0, -1, LUMPERROR}, // Water Slap Tails 12-13-2000 - {"doora1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"doorb1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"doorc1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"doorc2", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"doord1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"doord2", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"eleva1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"eleva2", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"eleva3", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"elevb1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"elevb2", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"elevb3", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"doora1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"doorb1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"doorc1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"doorc2", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"doord1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"doord2", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"eleva1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"eleva2", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"eleva3", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"elevb1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"elevb2", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"elevb3", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"ambin2", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"lavbub", false, 64, 8, NULL, 0, -1, LUMPERROR}, - {"rocks1", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"rocks2", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"rocks3", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"rocks4", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"rumbam", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"rumble", false, 64, 24, NULL, 0, -1, LUMPERROR}, + {"ambin2", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"lavbub", false, 64, 8, NULL, 0, -1, LUMPERROR}, + {"rocks1", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"rocks2", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"rocks3", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"rocks4", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"rumbam", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"rumble", false, 64, 24, NULL, 0, -1, LUMPERROR}, - // Game objects, etc - {"appear", false, 127, 0, NULL, 0, -1, LUMPERROR}, - {"bkpoof", false, 70, 8, NULL, 0, -1, LUMPERROR}, - {"bnce1", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Boing! - {"bnce2", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Boing! - {"cannon", false, 64, 8, NULL, 0, -1, LUMPERROR}, - {"cgot" , true, 120, 0, NULL, 0, -1, LUMPERROR}, // Got Emerald! Tails 09-02-2001 - {"cybdth", false, 32, 0, NULL, 0, -1, LUMPERROR}, - {"deton", true, 64, 0, NULL, 0, -1, LUMPERROR}, - {"ding", false, 127, 8, NULL, 0, -1, LUMPERROR}, - {"dmpain", false, 96, 0, NULL, 0, -1, LUMPERROR}, - {"drown", false, 192, 0, NULL, 0, -1, LUMPERROR}, - {"fizzle", false, 127, 8, NULL, 0, -1, LUMPERROR}, - {"gbeep", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Grenade beep - {"ghit" , false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"gloop", false, 60, 0, NULL, 0, -1, LUMPERROR}, - {"gspray", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"gravch", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"itemup", true, 255, 0, NULL, 0, -1, LUMPERROR}, - {"jet", false, 8, 0, NULL, 0, -1, LUMPERROR}, - {"jshard", true, 167, 0, NULL, 0, -1, LUMPERROR}, - {"lose" , false, 127, 0, NULL, 0, -1, LUMPERROR}, - {"lvpass", false, 96, 0, NULL, 0, -1, LUMPERROR}, - {"mindig", false, 8, 64, NULL, 0, -1, LUMPERROR}, - {"mixup", true, 127, 0, NULL, 0, -1, LUMPERROR}, - {"pogo" , false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"pop" , false, 78, 0, NULL, 0, -1, LUMPERROR}, - {"rail1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"rail2", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"rlaunc", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"shield", false, 60, 0, NULL, 0, -1, LUMPERROR}, - {"shldls", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"spdpad", false, 127, 0, NULL, 0, -1, LUMPERROR}, - {"spkdth", false, 127, 0, NULL, 0, -1, LUMPERROR}, - {"spring", false, 112, 0, NULL, 0, -1, LUMPERROR}, - {"statu1", true, 64, 2, NULL, 0, -1, LUMPERROR}, - {"statu2", true, 64, 2, NULL, 0, -1, LUMPERROR}, - {"strpst", true, 192, 0, NULL, 0, -1, LUMPERROR}, // Starpost Sound Tails 07-04-2002 - {"supert", true, 127, 2, NULL, 0, -1, LUMPERROR}, - {"telept", false, 32, 0, NULL, 0, -1, LUMPERROR}, - {"tink" , false, 60, 0, NULL, 0, -1, LUMPERROR}, - {"token" , true, 224, 0, NULL, 0, -1, LUMPERROR}, // SS token - {"trfire", true, 60, 8, NULL, 0, -1, LUMPERROR}, - {"trpowr", true, 127, 8, NULL, 0, -1, LUMPERROR}, - {"turhit", false, 40, 8, NULL, 0, -1, LUMPERROR}, - {"wdjump", false, 60, 0, NULL, 0, -1, LUMPERROR}, - {"mswarp", false, 60, 16, NULL, 0, -1, LUMPERROR}, - {"mspogo", false, 60, 8, NULL, 0, -1, LUMPERROR}, + // Game objects, etc + {"appear", false, 127, 0, NULL, 0, -1, LUMPERROR}, + {"bkpoof", false, 70, 8, NULL, 0, -1, LUMPERROR}, + {"bnce1", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Boing! + {"bnce2", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Boing! + {"cannon", false, 64, 8, NULL, 0, -1, LUMPERROR}, + {"cgot" , true, 120, 0, NULL, 0, -1, LUMPERROR}, // Got Emerald! Tails 09-02-2001 + {"cybdth", false, 32, 0, NULL, 0, -1, LUMPERROR}, + {"deton", true, 64, 0, NULL, 0, -1, LUMPERROR}, + {"ding", false, 127, 8, NULL, 0, -1, LUMPERROR}, + {"dmpain", false, 96, 0, NULL, 0, -1, LUMPERROR}, + {"drown", false, 192, 0, NULL, 0, -1, LUMPERROR}, + {"fizzle", false, 127, 8, NULL, 0, -1, LUMPERROR}, + {"gbeep", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Grenade beep + {"ghit" , false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"gloop", false, 60, 0, NULL, 0, -1, LUMPERROR}, + {"gspray", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"gravch", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"itemup", true, 255, 0, NULL, 0, -1, LUMPERROR}, + {"jet", false, 8, 0, NULL, 0, -1, LUMPERROR}, + {"jshard", true, 167, 0, NULL, 0, -1, LUMPERROR}, + {"lose" , false, 127, 0, NULL, 0, -1, LUMPERROR}, + {"lvpass", false, 96, 0, NULL, 0, -1, LUMPERROR}, + {"mindig", false, 8, 64, NULL, 0, -1, LUMPERROR}, + {"mixup", true, 127, 0, NULL, 0, -1, LUMPERROR}, + {"pogo" , false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"pop" , false, 78, 0, NULL, 0, -1, LUMPERROR}, + {"rail1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"rail2", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"rlaunc", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"shield", false, 60, 0, NULL, 0, -1, LUMPERROR}, + {"shldls", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"spdpad", false, 127, 0, NULL, 0, -1, LUMPERROR}, + {"spkdth", false, 127, 0, NULL, 0, -1, LUMPERROR}, + {"spring", false, 112, 0, NULL, 0, -1, LUMPERROR}, + {"statu1", true, 64, 2, NULL, 0, -1, LUMPERROR}, + {"statu2", true, 64, 2, NULL, 0, -1, LUMPERROR}, + {"strpst", true, 192, 0, NULL, 0, -1, LUMPERROR}, // Starpost Sound Tails 07-04-2002 + {"supert", true, 127, 2, NULL, 0, -1, LUMPERROR}, + {"telept", false, 32, 0, NULL, 0, -1, LUMPERROR}, + {"tink" , false, 60, 0, NULL, 0, -1, LUMPERROR}, + {"token" , true, 224, 0, NULL, 0, -1, LUMPERROR}, // SS token + {"trfire", true, 60, 8, NULL, 0, -1, LUMPERROR}, + {"trpowr", true, 127, 8, NULL, 0, -1, LUMPERROR}, + {"turhit", false, 40, 8, NULL, 0, -1, LUMPERROR}, + {"wdjump", false, 60, 0, NULL, 0, -1, LUMPERROR}, + {"mswarp", false, 60, 16, NULL, 0, -1, LUMPERROR}, + {"mspogo", false, 60, 8, NULL, 0, -1, LUMPERROR}, - // Menu, interface - {"chchng", false, 120, 0, NULL, 0, -1, LUMPERROR}, - {"dwnind", false, 212, 0, NULL, 0, -1, LUMPERROR}, - {"emfind", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"flgcap", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"menu1", true, 64, 0, NULL, 0, -1, LUMPERROR}, - {"oneup", true, 192, 0, NULL, 0, -1, LUMPERROR}, - {"ptally", true, 64, 0, NULL, 0, -1, LUMPERROR}, // Point tally is identical to menu for now - {"radio", false, 60, 0, NULL, 0, -1, LUMPERROR}, - {"wepchg", true, 64, 0, NULL, 0, -1, LUMPERROR}, // Weapon switch is identical to menu for now - {"wtrdng", true, 212, 0, NULL, 0, -1, LUMPERROR}, // make sure you can hear the DING DING! Tails 03-08-2000 - {"zelda", false, 120, 0, NULL, 0, -1, LUMPERROR}, + // Menu, interface + {"chchng", false, 120, 0, NULL, 0, -1, LUMPERROR}, + {"dwnind", false, 212, 0, NULL, 0, -1, LUMPERROR}, + {"emfind", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"flgcap", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"menu1", true, 64, 0, NULL, 0, -1, LUMPERROR}, + {"oneup", true, 192, 0, NULL, 0, -1, LUMPERROR}, + {"ptally", true, 64, 0, NULL, 0, -1, LUMPERROR}, // Point tally is identical to menu for now + {"radio", false, 60, 0, NULL, 0, -1, LUMPERROR}, + {"wepchg", true, 64, 0, NULL, 0, -1, LUMPERROR}, // Weapon switch is identical to menu for now + {"wtrdng", true, 212, 0, NULL, 0, -1, LUMPERROR}, // make sure you can hear the DING DING! Tails 03-08-2000 + {"zelda", false, 120, 0, NULL, 0, -1, LUMPERROR}, - // NiGHTS - {"ideya", false, 127, 0, NULL, 0, -1, LUMPERROR}, - {"xideya", false, 127, 0, NULL, 0, -1, LUMPERROR}, // Xmas - {"nbmper", false, 96, 0, NULL, 0, -1, LUMPERROR}, - {"nxbump", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Xmas - {"ncitem", false, 204, 0, NULL, 0, -1, LUMPERROR}, - {"nxitem", false, 204, 0, NULL, 0, -1, LUMPERROR}, // Xmas - {"ngdone", true, 127, 0, NULL, 0, -1, LUMPERROR}, - {"nxdone", true, 127, 0, NULL, 0, -1, LUMPERROR}, // Xmas - {"drill1", false, 48, 0, NULL, 0, -1, LUMPERROR}, - {"drill2", false, 48, 0, NULL, 0, -1, LUMPERROR}, - {"ncspec", false, 204, 0, NULL, 0, -1, LUMPERROR}, // Tails 12-15-2003 - {"nghurt", false, 96, 0, NULL, 0, -1, LUMPERROR}, - {"ngskid", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"hoop1", false, 192, 0, NULL, 0, -1, LUMPERROR}, - {"hoop2", false, 192, 0, NULL, 0, -1, LUMPERROR}, - {"hoop3", false, 192, 0, NULL, 0, -1, LUMPERROR}, - {"hidden", false, 204, 0, NULL, 0, -1, LUMPERROR}, - {"prloop", false, 104, 0, NULL, 0, -1, LUMPERROR}, - {"timeup", true, 256, 0, NULL, 0, -1, LUMPERROR}, + // NiGHTS + {"ideya", false, 127, 0, NULL, 0, -1, LUMPERROR}, + {"xideya", false, 127, 0, NULL, 0, -1, LUMPERROR}, // Xmas + {"nbmper", false, 96, 0, NULL, 0, -1, LUMPERROR}, + {"nxbump", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Xmas + {"ncitem", false, 204, 0, NULL, 0, -1, LUMPERROR}, + {"nxitem", false, 204, 0, NULL, 0, -1, LUMPERROR}, // Xmas + {"ngdone", true, 127, 0, NULL, 0, -1, LUMPERROR}, + {"nxdone", true, 127, 0, NULL, 0, -1, LUMPERROR}, // Xmas + {"drill1", false, 48, 0, NULL, 0, -1, LUMPERROR}, + {"drill2", false, 48, 0, NULL, 0, -1, LUMPERROR}, + {"ncspec", false, 204, 0, NULL, 0, -1, LUMPERROR}, // Tails 12-15-2003 + {"nghurt", false, 96, 0, NULL, 0, -1, LUMPERROR}, + {"ngskid", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"hoop1", false, 192, 0, NULL, 0, -1, LUMPERROR}, + {"hoop2", false, 192, 0, NULL, 0, -1, LUMPERROR}, + {"hoop3", false, 192, 0, NULL, 0, -1, LUMPERROR}, + {"hidden", false, 204, 0, NULL, 0, -1, LUMPERROR}, + {"prloop", false, 104, 0, NULL, 0, -1, LUMPERROR}, + {"timeup", true, 256, 0, NULL, 0, -1, LUMPERROR}, - // Mario - {"koopfr" , true, 127, 8, NULL, 0, -1, LUMPERROR}, - {"mario1", false, 60, 0, NULL, 0, -1, LUMPERROR}, - {"mario2", false, 127, 0, NULL, 0, -1, LUMPERROR}, - {"mario3", false, 60, 0, NULL, 0, -1, LUMPERROR}, - {"mario4", true, 78, 0, NULL, 0, -1, LUMPERROR}, - {"mario5", false, 78, 0, NULL, 0, -1, LUMPERROR}, - {"mario6", false, 60, 0, NULL, 0, -1, LUMPERROR}, - {"mario7", false, 32, 0, NULL, 0, -1, LUMPERROR}, - {"mario8", false, 48, 8, NULL, 0, -1, LUMPERROR}, - {"mario9", true, 120, 0, NULL, 0, -1, LUMPERROR}, - {"marioa", true, 127, 0, NULL, 0, -1, LUMPERROR}, - {"thwomp", true, 127, 8, NULL, 0, -1, LUMPERROR}, + // Mario + {"koopfr" , true, 127, 8, NULL, 0, -1, LUMPERROR}, + {"mario1", false, 60, 0, NULL, 0, -1, LUMPERROR}, + {"mario2", false, 127, 0, NULL, 0, -1, LUMPERROR}, + {"mario3", false, 60, 0, NULL, 0, -1, LUMPERROR}, + {"mario4", true, 78, 0, NULL, 0, -1, LUMPERROR}, + {"mario5", false, 78, 0, NULL, 0, -1, LUMPERROR}, + {"mario6", false, 60, 0, NULL, 0, -1, LUMPERROR}, + {"mario7", false, 32, 0, NULL, 0, -1, LUMPERROR}, + {"mario8", false, 48, 8, NULL, 0, -1, LUMPERROR}, + {"mario9", true, 120, 0, NULL, 0, -1, LUMPERROR}, + {"marioa", true, 127, 0, NULL, 0, -1, LUMPERROR}, + {"thwomp", true, 127, 8, NULL, 0, -1, LUMPERROR}, - // Black Eggman - {"bebomb", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bechrg", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"becrsh", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bedeen", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bedie1", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bedie2", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"beeyow", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"befall", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"befire", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"beflap", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"begoop", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"begrnd", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"behurt", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bejet1", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"belnch", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"beoutb", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"beragh", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"beshot", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bestep", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bestp2", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bewar1", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bewar2", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bewar3", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bewar4", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bexpld", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"bgxpld", false, 64, 64, NULL, 0, -1, LUMPERROR}, + // Black Eggman + {"bebomb", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bechrg", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"becrsh", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bedeen", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bedie1", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bedie2", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"beeyow", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"befall", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"befire", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"beflap", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"begoop", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"begrnd", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"behurt", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bejet1", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"belnch", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"beoutb", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"beragh", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"beshot", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bestep", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bestp2", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bewar1", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bewar2", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bewar3", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bewar4", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bexpld", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"bgxpld", false, 64, 64, NULL, 0, -1, LUMPERROR}, - // Cybrakdemon - {"beelec", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"brakrl", false, 64, 64, NULL, 0, -1, LUMPERROR}, - {"brakrx", false, 64, 64, NULL, 0, -1, LUMPERROR}, + // Cybrakdemon + {"beelec", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"brakrl", false, 64, 64, NULL, 0, -1, LUMPERROR}, + {"brakrx", false, 64, 64, NULL, 0, -1, LUMPERROR}, - // Sonic 1 sounds - {"s1a0", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1a1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1a2", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Monty Mole attach - {"s1a3", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1a4", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1a5", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1a6", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1a7", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1a8", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1a9", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1aa", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1ab", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Monty Mole twitch - {"s1ac", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Misc. obstacle destroyed - {"s1ad", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1ae", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1af", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1b0", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1b1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1b2", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1b3", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1b4", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Toggle all items - {"s1b5", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1b6", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1b7", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1b8", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1b9", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1ba", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Toggle item - {"s1bb", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Thwomp drop - {"s1bc", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1bd", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Ballhog bounce - {"s1be", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1bf", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1c0", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1c1", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Monokuma death - {"s1c2", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1c3", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1c4", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1c5", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1c6", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1c7", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1c8", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1c9", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Item hit w/ voices off - {"s1ca", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1cb", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1cc", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1cd", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1ce", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s1cf", false, 64, 0, NULL, 0, -1, LUMPERROR}, + // Sonic 1 sounds + {"s1a0", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1a1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1a2", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Monty Mole attach + {"s1a3", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1a4", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1a5", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1a6", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1a7", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1a8", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1a9", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1aa", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1ab", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Monty Mole twitch + {"s1ac", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Misc. obstacle destroyed + {"s1ad", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1ae", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1af", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1b0", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1b1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1b2", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1b3", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1b4", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Toggle all items + {"s1b5", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1b6", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1b7", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1b8", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1b9", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1ba", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Toggle item + {"s1bb", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Thwomp drop + {"s1bc", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1bd", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Ballhog bounce + {"s1be", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1bf", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1c0", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1c1", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Monokuma death + {"s1c2", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1c3", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1c4", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1c5", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1c6", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1c7", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1c8", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1c9", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Item hit w/ voices off + {"s1ca", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1cb", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1cc", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1cd", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1ce", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s1cf", false, 64, 0, NULL, 0, -1, LUMPERROR}, - // Sonic 2 sounds - {"s220", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s221", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Lap sound - {"s222", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s223", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s224", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s225", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s226", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s227", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s228", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s229", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s22a", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s22b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s22c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s22d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s22e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s22f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s230", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s231", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s232", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s233", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s234", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s235", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s236", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s237", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s238", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s239", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s23a", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s23b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s23c", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Drift boost - {"s23d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s23e", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Title screen opening - {"s23f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s240", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s241", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s242", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s243", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s244", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s245", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s246", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s247", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s248", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s249", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s24a", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s24b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s24c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s24d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s24e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s24f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s250", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s251", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s252", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s253", false, 255, 0, NULL, 0, -1, LUMPERROR}, // 1st place finish - {"s254", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s255", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s256", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s257", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s258", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s259", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Item clashing - {"s25a", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s25b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s25c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s25d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s25e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s25f", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Perfect start boost - {"s260", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s261", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s262", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s263", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s264", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s265", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s266", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s267", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s268", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s269", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s26a", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s26b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s26c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s26d", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Missed checkpoint - {"s26e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s26f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s270", false, 64, 0, NULL, 0, -1, LUMPERROR}, + // Sonic 2 sounds + {"s220", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s221", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Lap sound + {"s222", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s223", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s224", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s225", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s226", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s227", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s228", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s229", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s22a", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s22b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s22c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s22d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s22e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s22f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s230", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s231", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s232", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s233", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s234", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s235", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s236", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s237", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s238", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s239", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s23a", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s23b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s23c", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Drift boost + {"s23d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s23e", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Title screen opening + {"s23f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s240", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s241", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s242", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s243", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s244", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s245", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s246", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s247", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s248", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s249", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s24a", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s24b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s24c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s24d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s24e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s24f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s250", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s251", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s252", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s253", false, 255, 0, NULL, 0, -1, LUMPERROR}, // 1st place finish + {"s254", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s255", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s256", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s257", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s258", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s259", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Item clashing + {"s25a", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s25b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s25c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s25d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s25e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s25f", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Perfect start boost + {"s260", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s261", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s262", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s263", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s264", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s265", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s266", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s267", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s268", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s269", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s26a", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s26b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s26c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s26d", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Missed checkpoint + {"s26e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s26f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s270", false, 64, 0, NULL, 0, -1, LUMPERROR}, - // S3&K sounds - {"s3k33", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k34", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k35", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k36", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k37", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k38", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k39", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k3a", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Kart item shield - {"s3k3b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k3c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k3d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k3e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k3f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k40", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k41", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k42", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart Thunder Shield spawned - {"s3k43", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k44", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k45", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k46", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k47", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart AIZ dust - {"s3k48", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k49", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart bump sound - {"s3k4a", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k4b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k4c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k4d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k4e", false, 64, 8, NULL, 0, -1, LUMPERROR}, // Kart explosion - {"s3k4f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k50", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k51", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k52", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k53", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k54", false, 64, 64, NULL, 0, -1, LUMPERROR}, // MetalSonic shot fire - {"s3k55", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k56", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k57", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k58", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k59", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k5a", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k5b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k5c", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Kart Mine tick - {"s3k5d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k5e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k5f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k60", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k61", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k62", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k63", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k64", false, 64, 2, NULL, 0, -1, LUMPERROR}, - {"s3k65", false, 255, 0, NULL, 0, -1, LUMPERROR}, // Blue Spheres - {"s3k66", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k67", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k68", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart final lap - {"s3k69", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k6a", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart finish - {"s3k6b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k6c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k6d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k6e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k6f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k70", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k71", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k72", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k73", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k74", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k75", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k76", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k77", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k78", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k79", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k7a", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k7b", false, 96, 16, NULL, 0, -1, LUMPERROR}, // Kart successful hit - {"s3k7c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k7d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k7e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k7f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k80", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k81", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k82", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k83", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Overcharged start boost - {"s3k84", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k85", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k86", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k87", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k88", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k89", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart Jawz target - {"s3k8a", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k8b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k8c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k8d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k8e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k8f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k90", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k91", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k92", false, 64, 8, NULL, 0, -1, LUMPERROR}, // Kart Hyudoro use - {"s3k93", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k94", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k95", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k96", false, 128, 0, NULL, 0, -1, LUMPERROR}, // Kart Orbinaut - {"s3k97", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k98", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k99", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k9a", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k9b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k9c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k9d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k9e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3k9f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3ka0", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3ka1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3ka2", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart drift spark gain - {"s3ka3", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3ka4", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3ka5", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3ka6", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3ka7", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart 3,2,1 - {"s3ka8", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3ka9", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kaa", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kab", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kac", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kad", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart GO! - {"s3kae", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kaf", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kb0", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kb1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kb2", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kb3", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kb4", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kb5", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kb6", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kb7", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kb8", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kb9", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kba", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kbb", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kbcs", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kbcl", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kbds", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kbdl", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kbes", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kbel", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kbfs", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kbfl", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc0s", false, 192, 8, NULL, 0, -1, LUMPERROR}, // Kart Jawz - {"s3kc0l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc1s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc1l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc2s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc2l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc3s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc3l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc4s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc4l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc5s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc5l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc6s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc6l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc7s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc7l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc8s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc8l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc9s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kc9l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kcas", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart respawn - {"s3kcal", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kcbs", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kcbl", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kccs", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kccl", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kcds", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kcdl", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kces", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kcel", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kcfs", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kcfl", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd0s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd0l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd1s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd1l", false, 48, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd2s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd2l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd3s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd3l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd4s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd4l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd5s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd5l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd6s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd6l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd7s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd7l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd8s", false, 64, 64, NULL, 0, -1, LUMPERROR}, // Sharp Spin (maybe use the long/L version?) - {"s3kd8l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd9s", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kd9l", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kdas", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kdal", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kdbs", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"s3kdbl", false, 64, 0, NULL, 0, -1, LUMPERROR}, + // S3&K sounds + {"s3k33", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k34", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k35", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k36", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k37", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k38", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k39", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k3a", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Kart item shield + {"s3k3b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k3c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k3d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k3e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k3f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k40", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k41", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k42", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart Thunder Shield spawned + {"s3k43", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k44", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k45", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k46", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k47", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart AIZ dust + {"s3k48", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k49", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart bump sound + {"s3k4a", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k4b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k4c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k4d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k4e", false, 64, 8, NULL, 0, -1, LUMPERROR}, // Kart explosion + {"s3k4f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k50", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k51", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k52", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k53", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k54", false, 64, 64, NULL, 0, -1, LUMPERROR}, // MetalSonic shot fire + {"s3k55", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k56", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k57", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k58", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k59", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k5a", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k5b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k5c", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Kart Mine tick + {"s3k5d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k5e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k5f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k60", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k61", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k62", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k63", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k64", false, 64, 2, NULL, 0, -1, LUMPERROR}, + {"s3k65", false, 255, 0, NULL, 0, -1, LUMPERROR}, // Blue Spheres + {"s3k66", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k67", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k68", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart final lap + {"s3k69", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k6a", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart finish + {"s3k6b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k6c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k6d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k6e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k6f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k70", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k71", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k72", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k73", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k74", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k75", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k76", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k77", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k78", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k79", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k7a", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k7b", false, 96, 16, NULL, 0, -1, LUMPERROR}, // Kart successful hit + {"s3k7c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k7d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k7e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k7f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k80", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k81", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k82", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k83", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Overcharged start boost + {"s3k84", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k85", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k86", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k87", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k88", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k89", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart Jawz target + {"s3k8a", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k8b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k8c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k8d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k8e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k8f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k90", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k91", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k92", false, 64, 8, NULL, 0, -1, LUMPERROR}, // Kart Hyudoro use + {"s3k93", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k94", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k95", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k96", false, 128, 0, NULL, 0, -1, LUMPERROR}, // Kart Orbinaut + {"s3k97", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k98", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k99", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k9a", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k9b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k9c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k9d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k9e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3k9f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3ka0", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3ka1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3ka2", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart drift spark gain + {"s3ka3", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3ka4", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3ka5", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3ka6", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3ka7", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart 3,2,1 + {"s3ka8", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3ka9", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kaa", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kab", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kac", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kad", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart GO! + {"s3kae", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kaf", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kb0", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kb1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kb2", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kb3", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kb4", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kb5", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kb6", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kb7", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kb8", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kb9", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kba", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kbb", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kbcs", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kbcl", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kbds", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kbdl", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kbes", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kbel", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kbfs", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kbfl", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc0s", false, 192, 8, NULL, 0, -1, LUMPERROR}, // Kart Jawz + {"s3kc0l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc1s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc1l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc2s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc2l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc3s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc3l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc4s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc4l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc5s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc5l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc6s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc6l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc7s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc7l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc8s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc8l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc9s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kc9l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kcas", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart respawn + {"s3kcal", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kcbs", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kcbl", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kccs", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kccl", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kcds", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kcdl", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kces", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kcel", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kcfs", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kcfl", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd0s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd0l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd1s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd1l", false, 48, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd2s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd2l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd3s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd3l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd4s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd4l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd5s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd5l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd6s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd6l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd7s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd7l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd8s", false, 64, 64, NULL, 0, -1, LUMPERROR}, // Sharp Spin (maybe use the long/L version?) + {"s3kd8l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd9s", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kd9l", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kdas", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kdal", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kdbs", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"s3kdbl", false, 64, 0, NULL, 0, -1, LUMPERROR}, - // 3D Blast sounds (the "missing" ones are direct copies of S3K's, no minor differences what-so-ever) - {"3db06", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Bumper stolen - {"3db09", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"3db14", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"3db16", false, 64, 0, NULL, 0, -1, LUMPERROR}, + // 3D Blast sounds (the "missing" ones are direct copies of S3K's, no minor differences what-so-ever) + {"3db06", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Bumper stolen + {"3db09", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"3db14", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"3db16", false, 64, 0, NULL, 0, -1, LUMPERROR}, - // Sonic CD sounds - {"cdfm00", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Undercharged start boost - {"cdfm01", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Sneaker boost - {"cdfm02", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm03", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm04", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm05", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm06", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm07", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm08", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm09", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm10", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm11", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm12", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm13", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm14", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm15", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm16", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm17", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Brake drift ambient - {"cdfm18", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm19", false, 64, 0, NULL, 0, -1, LUMPERROR}, // CD SS1 UFO death - {"cdfm20", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm21", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm22", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm23", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm24", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm25", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm26", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm27", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm28", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Eggman item landing - {"cdfm29", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm30", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm31", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm32", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm33", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm34", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm35", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm36", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm37", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm38", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm39", false, 128, 8, NULL, 0, -1, LUMPERROR}, // Mine deployed - {"cdfm40", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm41", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm42", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm43", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm44", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm45", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm46", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm47", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm48", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm49", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm50", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm51", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm52", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm53", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm54", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm55", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm56", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm57", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm58", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm59", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm60", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm61", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm62", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm63", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm64", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm65", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm66", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm67", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm68", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm69", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm70", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Trail item dragging - {"cdfm71", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm72", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm73", false, 64, 0, NULL, 0, -1, LUMPERROR}, // CD SS1 UFO hit - {"cdfm74", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm75", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm76", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm77", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm78", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdfm79", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdpcm0", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdpcm1", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdpcm2", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdpcm3", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdpcm4", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdpcm5", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdpcm6", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdpcm7", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdpcm8", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"cdpcm9", false, 96, 8, NULL, 0, -1, LUMPERROR}, // No damage taken + // Sonic CD sounds + {"cdfm00", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Undercharged start boost + {"cdfm01", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Sneaker boost + {"cdfm02", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm03", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm04", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm05", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm06", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm07", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm08", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm09", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm10", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm11", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm12", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm13", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm14", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm15", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm16", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm17", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Brake drift ambient + {"cdfm18", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm19", false, 64, 0, NULL, 0, -1, LUMPERROR}, // CD SS1 UFO death + {"cdfm20", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm21", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm22", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm23", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm24", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm25", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm26", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm27", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm28", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Eggman item landing + {"cdfm29", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm30", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm31", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm32", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm33", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm34", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm35", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm36", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm37", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm38", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm39", false, 128, 8, NULL, 0, -1, LUMPERROR}, // Mine deployed + {"cdfm40", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm41", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm42", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm43", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm44", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm45", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm46", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm47", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm48", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm49", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm50", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm51", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm52", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm53", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm54", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm55", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm56", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm57", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm58", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm59", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm60", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm61", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm62", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm63", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm64", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm65", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm66", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm67", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm68", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm69", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm70", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Trail item dragging + {"cdfm71", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm72", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm73", false, 64, 0, NULL, 0, -1, LUMPERROR}, // CD SS1 UFO hit + {"cdfm74", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm75", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm76", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm77", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm78", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdfm79", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdpcm0", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdpcm1", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdpcm2", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdpcm3", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdpcm4", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdpcm5", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdpcm6", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdpcm7", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdpcm8", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"cdpcm9", false, 96, 8, NULL, 0, -1, LUMPERROR}, // No damage taken - // Knuckles Chaotix sound - {"kc2a", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc2b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc2c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc2d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc2e", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Item box gotten - {"kc2f", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Spring pad - {"kc30", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc31", false, 64, 64, NULL, 0, -1, LUMPERROR}, // NO CONTEST explosion - {"kc32", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc33", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc34", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc35", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc36", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc37", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc38", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc39", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Voting roulette - {"kc3a", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc3b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc3c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc3d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc3e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc3f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc40", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc41", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc42", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Unlock everything cheat - {"kc43", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc44", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc45", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc46", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Shrink use - {"kc47", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc48", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Vote picked - {"kc49", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc4a", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Voting beep - {"kc4b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc4c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc4d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc4e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc4f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc50", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc51", false, 64, 64, NULL, 0, -1, LUMPERROR}, // NO CONTEST debris ambience - {"kc52", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc53", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc54", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc55", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc56", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc57", false, 128, 8, NULL, 0, -1, LUMPERROR}, // SPB locked in - {"kc58", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc59", false, 128, 8, NULL, 0, -1, LUMPERROR}, // Shrink - {"kc5a", false, 128, 8, NULL, 0, -1, LUMPERROR}, // Grow - {"kc5b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc5c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc5d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc5e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc5f", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc60", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc61", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc62", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc63", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc64", false, 96, 0, NULL, 0, -1, LUMPERROR}, // SPB ambient - {"kc65", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc66", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc67", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc68", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc69", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc6b", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc6c", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc6d", false, 64, 0, NULL, 0, -1, LUMPERROR}, - {"kc6e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + // Knuckles Chaotix sound + {"kc2a", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc2b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc2c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc2d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc2e", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Item box gotten + {"kc2f", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Spring pad + {"kc30", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc31", false, 64, 64, NULL, 0, -1, LUMPERROR}, // NO CONTEST explosion + {"kc32", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc33", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc34", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc35", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc36", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc37", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc38", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc39", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Voting roulette + {"kc3a", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc3b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc3c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc3d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc3e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc3f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc40", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc41", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc42", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Unlock everything cheat + {"kc43", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc44", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc45", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc46", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Shrink use + {"kc47", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc48", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Vote picked + {"kc49", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc4a", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Voting beep + {"kc4b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc4c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc4d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc4e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc4f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc50", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc51", false, 64, 64, NULL, 0, -1, LUMPERROR}, // NO CONTEST debris ambience + {"kc52", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc53", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc54", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc55", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc56", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc57", false, 128, 8, NULL, 0, -1, LUMPERROR}, // SPB locked in + {"kc58", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc59", false, 128, 8, NULL, 0, -1, LUMPERROR}, // Shrink + {"kc5a", false, 128, 8, NULL, 0, -1, LUMPERROR}, // Grow + {"kc5b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc5c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc5d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc5e", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc5f", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc60", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc61", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc62", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc63", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc64", false, 96, 0, NULL, 0, -1, LUMPERROR}, // SPB ambient + {"kc65", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc66", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc67", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc68", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc69", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc6b", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc6c", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc6d", false, 64, 0, NULL, 0, -1, LUMPERROR}, + {"kc6e", false, 64, 0, NULL, 0, -1, LUMPERROR}, - // SRB2kart - {"slip", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Spinout - {"screec", false, 48, 0, NULL, 0, -1, LUMPERROR}, // Tight turning screech - {"drift", false, 48, 0, NULL, 0, -1, LUMPERROR}, // Drifting ambient - {"ruburn", false, 48, 0, NULL, 0, -1, LUMPERROR}, // Rubber-burn turn ambient - {"ddash", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Respawn Drop Dash - {"tossed", false, 192, 8, NULL, 0, -1, LUMPERROR}, // Item fired - {"itpick", false, 128, 8, NULL, 0, -1, LUMPERROR}, // Pick up HUD drop - {"peel", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Edited S25A for banana landing - {"hogbom", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Ballhog explosions - {"zio3", false, 128, 8, NULL, 0, -1, LUMPERROR}, // Thunder Shield use - {"kpogos", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Pogo Spring use - {"alarmi", false, 255, 8, NULL, 0, -1, LUMPERROR}, // Invincibility alarm - {"alarmg", false, 255, 8, NULL, 0, -1, LUMPERROR}, // Grow alarm - {"kinvnc", false, 255, 8, NULL, 0, -1, LUMPERROR}, // Invincibility music - {"kgrow", false, 255, 8, NULL, 0, -1, LUMPERROR}, // Grow music - {"itrol1", true, 96, 0, NULL, 0, -1, LUMPERROR}, // Roulette spinning - {"itrol2", true, 96, 0, NULL, 0, -1, LUMPERROR}, - {"itrol3", true, 96, 0, NULL, 0, -1, LUMPERROR}, - {"itrol4", true, 96, 0, NULL, 0, -1, LUMPERROR}, - {"itrol5", true, 96, 0, NULL, 0, -1, LUMPERROR}, - {"itrol6", true, 96, 0, NULL, 0, -1, LUMPERROR}, - {"itrol7", true, 96, 0, NULL, 0, -1, LUMPERROR}, - {"itrol8", true, 96, 0, NULL, 0, -1, LUMPERROR}, - {"itrolf", true, 96, 0, NULL, 0, -1, LUMPERROR}, // Roulette end - {"itrolm", true, 96, 0, NULL, 0, -1, LUMPERROR}, // Roulette end (mashed) - {"itrolk", true, 96, 0, NULL, 0, -1, LUMPERROR}, // Roulette end (karma enhanced) - {"itrole", true, 96, 0, NULL, 0, -1, LUMPERROR}, // Roulette end (Eggman) - {"vroom", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart Krew opening vroom - {"chaooo", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Chao audience cheer - {"yeeeah", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Voting picks you - {"noooo1", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Voting picks hell (by chance) - {"noooo2", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Voting picks hell (on purpose) - {"ruby1", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Phantom Ruby charge up - {"ruby2", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Phantom Ruby teleport - {"tcart", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Twinkle Cart - {"bfare", false, 128, 0, NULL, 0, -1, LUMPERROR}, // Pleasure Castle fanfare - {"merry", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Pleasure Castle merry-go-round ambient - {"bowlh", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Pleasure Castle pins - {"tppop", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Pleasure Castle bombs - {"hsdoor", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Red Barrage Area door - {"hstrn", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Red Barrage Area train - {"aspkb", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Red Barrage Area spikeballs - {"wind1", false, 64, 8, NULL, 0, -1, LUMPERROR}, // Midnight Channel monsters - {"fire2", false, 64, 8, NULL, 0, -1, LUMPERROR}, - {"chain", false, 255, 8, NULL, 0, -1, LUMPERROR}, // Mementos Reaper - {"mkuma", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Trigger Happy Havoc Monokuma - {"toada", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Arid Sands Toad scream - {"gemhit", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Opulence gem/coin tumbling - {"wrink", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Some sort of ghoulie? - {"bsnipe", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Banana sniping - {"join", true, 96, 8, NULL, 0, -1, LUMPERROR}, // Player joined server - {"leave", true, 96, 8, NULL, 0, -1, LUMPERROR}, // Player left server - {"requst", true, 96, 8, NULL, 0, -1, LUMPERROR}, // Got a Discord join request - {"syfail", true, 96, 8, NULL, 0, -1, LUMPERROR}, // Funny sync failure - {"itfree", false, 64, 0, NULL, 0, -1, LUMPERROR}, // :shitsfree: - {"dbgsal", false, 255, 8, NULL, 0, -1, LUMPERROR}, // Debug notification + // SRB2kart + {"slip", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Spinout + {"screec", false, 48, 0, NULL, 0, -1, LUMPERROR}, // Tight turning screech + {"drift", false, 48, 0, NULL, 0, -1, LUMPERROR}, // Drifting ambient + {"ruburn", false, 48, 0, NULL, 0, -1, LUMPERROR}, // Rubber-burn turn ambient + {"ddash", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Respawn Drop Dash + {"tossed", false, 192, 8, NULL, 0, -1, LUMPERROR}, // Item fired + {"itpick", false, 128, 8, NULL, 0, -1, LUMPERROR}, // Pick up HUD drop + {"peel", false, 96, 0, NULL, 0, -1, LUMPERROR}, // Edited S25A for banana landing + {"hogbom", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Ballhog explosions + {"zio3", false, 128, 8, NULL, 0, -1, LUMPERROR}, // Thunder Shield use + {"kpogos", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Pogo Spring use + {"alarmi", false, 255, 8, NULL, 0, -1, LUMPERROR}, // Invincibility alarm + {"alarmg", false, 255, 8, NULL, 0, -1, LUMPERROR}, // Grow alarm + {"kinvnc", false, 255, 8, NULL, 0, -1, LUMPERROR}, // Invincibility music + {"kgrow", false, 255, 8, NULL, 0, -1, LUMPERROR}, // Grow music + {"itrol1", true, 96, 0, NULL, 0, -1, LUMPERROR}, // Roulette spinning + {"itrol2", true, 96, 0, NULL, 0, -1, LUMPERROR}, + {"itrol3", true, 96, 0, NULL, 0, -1, LUMPERROR}, + {"itrol4", true, 96, 0, NULL, 0, -1, LUMPERROR}, + {"itrol5", true, 96, 0, NULL, 0, -1, LUMPERROR}, + {"itrol6", true, 96, 0, NULL, 0, -1, LUMPERROR}, + {"itrol7", true, 96, 0, NULL, 0, -1, LUMPERROR}, + {"itrol8", true, 96, 0, NULL, 0, -1, LUMPERROR}, + {"itrolf", true, 96, 0, NULL, 0, -1, LUMPERROR}, // Roulette end + {"itrolm", true, 96, 0, NULL, 0, -1, LUMPERROR}, // Roulette end (mashed) + {"itrolk", true, 96, 0, NULL, 0, -1, LUMPERROR}, // Roulette end (karma enhanced) + {"itrole", true, 96, 0, NULL, 0, -1, LUMPERROR}, // Roulette end (Eggman) + {"vroom", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Kart Krew opening vroom + {"chaooo", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Chao audience cheer + {"yeeeah", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Voting picks you + {"noooo1", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Voting picks hell (by chance) + {"noooo2", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Voting picks hell (on purpose) + {"ruby1", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Phantom Ruby charge up + {"ruby2", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Phantom Ruby teleport + {"tcart", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Twinkle Cart + {"bfare", false, 128, 0, NULL, 0, -1, LUMPERROR}, // Pleasure Castle fanfare + {"merry", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Pleasure Castle merry-go-round ambient + {"bowlh", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Pleasure Castle pins + {"tppop", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Pleasure Castle bombs + {"hsdoor", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Red Barrage Area door + {"hstrn", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Red Barrage Area train + {"aspkb", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Red Barrage Area spikeballs + {"wind1", false, 64, 8, NULL, 0, -1, LUMPERROR}, // Midnight Channel monsters + {"fire2", false, 64, 8, NULL, 0, -1, LUMPERROR}, + {"chain", false, 255, 8, NULL, 0, -1, LUMPERROR}, // Mementos Reaper + {"mkuma", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Trigger Happy Havoc Monokuma + {"toada", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Arid Sands Toad scream + {"gemhit", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Opulence gem/coin tumbling + {"wrink", false, 64, 0, NULL, 0, -1, LUMPERROR}, // Some sort of ghoulie? + {"bsnipe", false, 96, 8, NULL, 0, -1, LUMPERROR}, // Banana sniping + {"join", true, 96, 8, NULL, 0, -1, LUMPERROR}, // Player joined server + {"leave", true, 96, 8, NULL, 0, -1, LUMPERROR}, // Player left server + {"requst", true, 96, 8, NULL, 0, -1, LUMPERROR}, // Got a Discord join request + {"syfail", true, 96, 8, NULL, 0, -1, LUMPERROR}, // Funny sync failure + {"itfree", false, 64, 0, NULL, 0, -1, LUMPERROR}, // :shitsfree: + {"dbgsal", false, 255, 8, NULL, 0, -1, LUMPERROR}, // Debug notification - // SRB2Kart - Engine sounds - // Engine class A - {"krta00", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krta01", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krta02", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krta03", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krta04", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krta05", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krta06", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krta07", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krta08", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krta09", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krta10", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krta11", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krta12", false, 48, 65, NULL, 0, -1, LUMPERROR}, - // Engine class B - {"krtb00", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtb01", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtb02", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtb03", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtb04", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtb05", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtb06", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtb07", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtb08", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtb09", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtb10", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtb11", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtb12", false, 48, 65, NULL, 0, -1, LUMPERROR}, - // Engine class C - {"krtc00", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtc01", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtc02", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtc03", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtc04", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtc05", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtc06", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtc07", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtc08", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtc09", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtc10", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtc11", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtc12", false, 48, 65, NULL, 0, -1, LUMPERROR}, - // Engine class D - {"krtd00", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtd01", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtd02", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtd03", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtd04", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtd05", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtd06", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtd07", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtd08", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtd09", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtd10", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtd11", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtd12", false, 48, 65, NULL, 0, -1, LUMPERROR}, - // Engine class E - {"krte00", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krte01", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krte02", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krte03", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krte04", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krte05", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krte06", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krte07", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krte08", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krte09", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krte10", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krte11", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krte12", false, 48, 65, NULL, 0, -1, LUMPERROR}, - // Engine class F - {"krtf00", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtf01", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtf02", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtf03", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtf04", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtf05", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtf06", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtf07", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtf08", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtf09", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtf10", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtf11", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtf12", false, 48, 65, NULL, 0, -1, LUMPERROR}, - // Engine class G - {"krtg00", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtg01", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtg02", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtg03", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtg04", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtg05", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtg06", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtg07", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtg08", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtg09", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtg10", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtg11", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krtg12", false, 48, 65, NULL, 0, -1, LUMPERROR}, - // Engine class H - {"krth00", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krth01", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krth02", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krth03", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krth04", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krth05", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krth06", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krth07", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krth08", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krth09", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krth10", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krth11", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krth12", false, 48, 65, NULL, 0, -1, LUMPERROR}, - // Engine class I - {"krti00", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krti01", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krti02", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krti03", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krti04", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krti05", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krti06", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krti07", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krti08", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krti09", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krti10", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krti11", false, 48, 65, NULL, 0, -1, LUMPERROR}, - {"krti12", false, 48, 65, NULL, 0, -1, LUMPERROR}, + // SRB2Kart - Engine sounds + // Engine class A + {"krta00", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krta01", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krta02", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krta03", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krta04", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krta05", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krta06", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krta07", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krta08", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krta09", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krta10", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krta11", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krta12", false, 48, 65, NULL, 0, -1, LUMPERROR}, + // Engine class B + {"krtb00", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtb01", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtb02", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtb03", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtb04", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtb05", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtb06", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtb07", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtb08", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtb09", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtb10", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtb11", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtb12", false, 48, 65, NULL, 0, -1, LUMPERROR}, + // Engine class C + {"krtc00", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtc01", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtc02", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtc03", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtc04", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtc05", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtc06", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtc07", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtc08", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtc09", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtc10", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtc11", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtc12", false, 48, 65, NULL, 0, -1, LUMPERROR}, + // Engine class D + {"krtd00", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtd01", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtd02", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtd03", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtd04", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtd05", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtd06", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtd07", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtd08", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtd09", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtd10", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtd11", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtd12", false, 48, 65, NULL, 0, -1, LUMPERROR}, + // Engine class E + {"krte00", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krte01", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krte02", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krte03", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krte04", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krte05", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krte06", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krte07", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krte08", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krte09", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krte10", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krte11", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krte12", false, 48, 65, NULL, 0, -1, LUMPERROR}, + // Engine class F + {"krtf00", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtf01", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtf02", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtf03", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtf04", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtf05", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtf06", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtf07", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtf08", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtf09", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtf10", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtf11", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtf12", false, 48, 65, NULL, 0, -1, LUMPERROR}, + // Engine class G + {"krtg00", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtg01", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtg02", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtg03", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtg04", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtg05", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtg06", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtg07", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtg08", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtg09", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtg10", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtg11", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krtg12", false, 48, 65, NULL, 0, -1, LUMPERROR}, + // Engine class H + {"krth00", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krth01", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krth02", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krth03", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krth04", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krth05", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krth06", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krth07", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krth08", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krth09", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krth10", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krth11", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krth12", false, 48, 65, NULL, 0, -1, LUMPERROR}, + // Engine class I + {"krti00", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krti01", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krti02", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krti03", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krti04", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krti05", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krti06", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krti07", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krti08", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krti09", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krti10", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krti11", false, 48, 65, NULL, 0, -1, LUMPERROR}, + {"krti12", false, 48, 65, NULL, 0, -1, LUMPERROR}, - // SRB2kart - Skin sounds - {"kwin", false, 64, 96, NULL, 0, SKSKWIN, LUMPERROR}, - {"klose", false, 64, 96, NULL, 0, SKSKLOSE, LUMPERROR}, - {"khurt1", false, 64, 96, NULL, 0, SKSKPAN1, LUMPERROR}, - {"khurt2", false, 64, 96, NULL, 0, SKSKPAN2, LUMPERROR}, - {"kattk1", false, 64, 96, NULL, 0, SKSKATK1, LUMPERROR}, - {"kattk2", false, 64, 96, NULL, 0, SKSKATK2, LUMPERROR}, - {"kbost1", false, 64, 96, NULL, 0, SKSKBST1, LUMPERROR}, - {"kbost2", false, 64, 96, NULL, 0, SKSKBST2, LUMPERROR}, - {"kslow", false, 64, 32, NULL, 0, SKSKSLOW, LUMPERROR}, - {"khitem", false, 128, 32, NULL, 0, SKSKHITM, LUMPERROR}, - {"kgloat", false, 64, 48, NULL, 0, SKSKPOWR, LUMPERROR}, + // SRB2kart - Skin sounds + {"kwin", false, 64, 96, NULL, 0, SKSKWIN, LUMPERROR}, + {"klose", false, 64, 96, NULL, 0, SKSKLOSE, LUMPERROR}, + {"khurt1", false, 64, 96, NULL, 0, SKSKPAN1, LUMPERROR}, + {"khurt2", false, 64, 96, NULL, 0, SKSKPAN2, LUMPERROR}, + {"kattk1", false, 64, 96, NULL, 0, SKSKATK1, LUMPERROR}, + {"kattk2", false, 64, 96, NULL, 0, SKSKATK2, LUMPERROR}, + {"kbost1", false, 64, 96, NULL, 0, SKSKBST1, LUMPERROR}, + {"kbost2", false, 64, 96, NULL, 0, SKSKBST2, LUMPERROR}, + {"kslow", false, 64, 32, NULL, 0, SKSKSLOW, LUMPERROR}, + {"khitem", false, 128, 32, NULL, 0, SKSKHITM, LUMPERROR}, + {"kgloat", false, 64, 48, NULL, 0, SKSKPOWR, LUMPERROR}, - // skin sounds free slots to add sounds at run time (Boris HACK!!!) - // initialized to NULL + // skin sounds free slots to add sounds at run time (Boris HACK!!!) + // initialized to NULL }; static char freeslotnames[sfx_freeslot0 + NUMSFXFREESLOTS + NUMSKINSFXSLOTS][MAXSOUNDNAME] = {}; @@ -979,26 +978,22 @@ void S_InitRuntimeSounds(void) { sfxenum_t i; INT32 value; - char soundname[10]; for (i = sfx_freeslot0; i <= sfx_lastskinsoundslot; i++) { value = (i+1) - sfx_freeslot0; - sprintf(soundname, "fr%04x", value); + // can happen if skinlimit is too high, then this would truncate + I_Assert(value <= 0xffff); - // this might happen when raising skinlimit - I_Assert(strlen(soundname) < MAXSOUNDNAME); - - strncpy(freeslotnames[value-1], soundname, MAXSOUNDNAME-1); - freeslotnames[value-1][MAXSOUNDNAME-1] = '\0'; + snprintf(freeslotnames[value-1], MAXSOUNDNAME, "fr%04x", value); S_sfx[i].name = freeslotnames[value-1]; S_sfx[i].singularity = false; S_sfx[i].priority = 0; S_sfx[i].pitch = 0; S_sfx[i].data = NULL; - S_sfx[i].length = 0; + S_sfx[i].length = 0; S_sfx[i].skinsound = -1; S_sfx[i].lumpnum = LUMPERROR; } @@ -1015,22 +1010,19 @@ sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean else slot = sfx_freeslot0; - const int precache = S_CacheSound(); + const int precache = S_CacheSound(); for (i = slot; i < NUMSFX; i++) { if (!S_sfx[i].priority) { - I_Assert(strlen(name) < MAXSOUNDNAME); - - strncpy(freeslotnames[i - sfx_freeslot0], name, MAXSOUNDNAME-1); - freeslotnames[i - sfx_freeslot0][MAXSOUNDNAME-1] = '\0'; + snprintf(freeslotnames[i - sfx_freeslot0], MAXSOUNDNAME, "%s", name); S_sfx[i].singularity = singular; S_sfx[i].priority = 60; S_sfx[i].pitch = flags; S_sfx[i].lumpnum = LUMPERROR; - S_sfx[i].length = 0; + S_sfx[i].length = 0; S_sfx[i].skinsound = -1; if (precache == SOUNDCACHE_PRECACHE) From 3668c2c4f3e38f86bdf97cd17062d38ef883780e Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Jul 2026 14:40:09 +0200 Subject: [PATCH 523/589] more code cleanups + remove duped slopelanding stuff mostly just unnesting stuffs, some mobj checks, etc --- src/m_menu.c | 12 +- src/p_enemy.c | 10 +- src/p_map.c | 13 +- src/p_maputl.cpp | 42 +++-- src/p_mobj.c | 426 ++++++++++++++++++++++++++--------------------- src/p_spec.c | 12 ++ src/p_spec.h | 2 + 7 files changed, 292 insertions(+), 225 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index ae5bfed18..9f621af6a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9048,15 +9048,15 @@ static boolean M_QuitMultiPlayerMenu(void) if (!fastcmp(setupm_name, setupm_cvname->string)) { // remove trailing whitespaces - for (l = strlen(setupm_name)-1; - (signed)l >= 0 && setupm_name[l] ==' '; l--) - setupm_name[l] =0; - COM_BufAddText(va("%s \"%s\"\n",setupm_cvname->name,setupm_name)); + l = strlen(setupm_name)-1; + for (;(signed)l >= 0 && setupm_name[l] ==' '; l--) + setupm_name[l] = 0; + COM_BufAddText(va("%s \"%s\"\n", setupm_cvname->name, setupm_name)); } // you know what? always putting these in the buffer won't hurt anything. - COM_BufAddText(va("%s \"%s\"\n",setupm_cvskin->name,skins[setupm_fakeskin].name)); - COM_BufAddText(va("%s %d\n",setupm_cvcolor->name,setupm_fakecolor)); + COM_BufAddText(va("%s \"%s\"\n", setupm_cvskin->name, skins[setupm_fakeskin].name)); + COM_BufAddText(va("%s %d\n", setupm_cvcolor->name, setupm_fakecolor)); return true; } diff --git a/src/p_enemy.c b/src/p_enemy.c index f3fb1761c..013ae4705 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -10879,10 +10879,7 @@ void A_BrakLobShot(void *thing) return; // Don't even bother if we've got nothing to aim at. // Look up actor's current gravity situation - if (actor->subsector->sector->gravity) - g = FixedMul(gravity,(FixedDiv(*actor->subsector->sector->gravity>>FRACBITS, 1000))); - else - g = gravity; + g = P_GetSectorGravity(actor->subsector->sector); // Look up distance between actor and its target x = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); @@ -10997,10 +10994,7 @@ void A_NapalmScatter(void *thing) airtime = 16<subsector->sector->gravity) - g = FixedMul(gravity,(FixedDiv(*actor->subsector->sector->gravity>>FRACBITS, 1000))); - else - g = gravity; + g = P_GetSectorGravity(actor->subsector->sector); // vy = (g*(airtime-1))/2 vy = FixedMul(g,(airtime-(1<>1; diff --git a/src/p_map.c b/src/p_map.c index 4ebc9a124..753d576b6 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1828,14 +1828,14 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) delta1 = abs(thing->z - midheight); delta2 = abs(thingtop - midheight); - if (topheight > tmfloorz && delta1 < delta2 + if ((topheight > tmfloorz) && (delta1 < delta2) && !(rover->flags & FF_REVERSEPLATFORM)) { tmfloorz = tmdropoffz = topheight; tmfloorslope = *rover->t_slope; } - if (bottomheight < tmceilingz && delta1 >= delta2 + if ((bottomheight < tmceilingz) && (delta1 >= delta2) && !(rover->flags & FF_PLATFORM) && !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE))) { @@ -1890,8 +1890,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) po->validcount = validcount; - if (!P_BBoxInsidePolyobj(po, tmbbox) - || !(po->flags & POF_SOLID)) + if (!(po->flags & POF_SOLID) || !P_BBoxInsidePolyobj(po, tmbbox)) { plink = (polymaplink_t *)(plink->link.next); continue; @@ -2136,7 +2135,7 @@ static boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) po->validcount = validcount; - if (!P_PointInsidePolyobj(po, x, y) || !(po->flags & POF_SOLID)) + if (!(po->flags & POF_SOLID) || !P_PointInsidePolyobj(po, x, y)) { plink = (polymaplink_t *)(plink->link.next); continue; @@ -3767,7 +3766,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) delta1 = abs(thing->z - midheight); delta2 = abs(thingtop - midheight); - if (bottomheight <= thing->ceilingz && delta1 >= delta2) + if ((bottomheight <= thing->ceilingz) && (delta1 >= delta2)) { if (thing->flags & MF_PUSHABLE) { @@ -4277,7 +4276,7 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) delta1 = abs(z - midheight); delta2 = abs(thingtop - midheight); - if (topheight > floorz && delta1 < delta2) + if ((topheight > floorz) && (delta1 < delta2)) floorz = topheight; } } diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 7d5c95feb..6e7f926b3 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -326,7 +326,7 @@ void P_CameraLineOpening(line_t *linedef) { for (rover = front->ffloors; rover; rover = rover->next) { - fixed_t topheight, bottomheight; + fixed_t topheight, bottomheight, midheight; if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || UNLIKELY(GETSECSPECIAL(rover->master->frontsector->special, 4) == 12)) continue; @@ -334,8 +334,10 @@ void P_CameraLineOpening(line_t *linedef) topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); - delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + midheight = (bottomheight + ((topheight - bottomheight) / 2)); + + delta1 = abs(mapcampointer->z - midheight); + delta2 = abs(thingtop - midheight); if (bottomheight < lowestceiling && delta1 >= delta2) lowestceiling = bottomheight; @@ -354,7 +356,7 @@ void P_CameraLineOpening(line_t *linedef) { for (rover = back->ffloors; rover; rover = rover->next) { - fixed_t topheight, bottomheight; + fixed_t topheight, bottomheight, midheight; if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || UNLIKELY(GETSECSPECIAL(rover->master->frontsector->special, 4) == 12)) continue; @@ -362,8 +364,10 @@ void P_CameraLineOpening(line_t *linedef) topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); - delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + midheight = (bottomheight + ((topheight - bottomheight) / 2)); + + delta1 = abs(mapcampointer->z - midheight); + delta2 = abs(thingtop - midheight); if (bottomheight < lowestceiling && delta1 >= delta2) lowestceiling = bottomheight; @@ -524,7 +528,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // Check for frontsector's fake floors for (rover = front->ffloors; rover; rover = rover->next) { - fixed_t topheight, bottomheight; + fixed_t topheight, bottomheight, midheight; if (!(rover->flags & FF_EXISTS)) continue; @@ -538,8 +542,10 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) topheight = P_GetFOFTopZ(mobj, front, rover, tmx, tmy, linedef); bottomheight = P_GetFOFBottomZ(mobj, front, rover, tmx, tmy, linedef); - delta1 = abs(mobj->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + midheight = (bottomheight + ((topheight - bottomheight) / 2)); + + delta1 = abs(mobj->z - midheight); + delta2 = abs(thingtop - midheight); if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF { @@ -567,7 +573,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // Check for backsectors fake floors for (rover = back->ffloors; rover; rover = rover->next) { - fixed_t topheight, bottomheight; + fixed_t topheight, bottomheight, midheight; if (!(rover->flags & FF_EXISTS)) continue; @@ -580,8 +586,10 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) topheight = P_GetFOFTopZ(mobj, back, rover, tmx, tmy, linedef); bottomheight = P_GetFOFBottomZ(mobj, back, rover, tmx, tmy, linedef); - delta1 = abs(mobj->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + midheight = (bottomheight + ((topheight - bottomheight) / 2)); + + delta1 = abs(mobj->z - midheight); + delta2 = abs(thingtop - midheight); if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF { @@ -611,8 +619,10 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) { const sector_t *polysec = linedef->backsector; - delta1 = abs(mobj->z - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); - delta2 = abs(thingtop - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); + const fixed_t polymid = (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight) / 2)); + + delta1 = abs(mobj->z - polymid); + delta2 = abs(thingtop - polymid); if (polysec->floorheight < lowestceiling && delta1 >= delta2) { @@ -620,7 +630,9 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) ceilingslope = NULL; } else if (polysec->floorheight < highestceiling && delta1 >= delta2) + { highestceiling = polysec->floorheight; + } if (polysec->ceilingheight > highestfloor && delta1 < delta2) { @@ -628,7 +640,9 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) floorslope = NULL; } else if (polysec->ceilingheight > lowestfloor && delta1 < delta2) + { lowestfloor = polysec->ceilingheight; + } } if (highestceiling < highceiling) diff --git a/src/p_mobj.c b/src/p_mobj.c index 14ba3a93d..840364b71 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -969,8 +969,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (!(rover->master->frontsector->gravity)) continue; - gravityadd = -FixedMul(gravity, - (FixedDiv(*rover->master->frontsector->gravity>>FRACBITS, 1000))); + gravityadd = -P_GetSectorGravity(rover->master->frontsector); if (rover->master->frontsector->verticalflip && gravityadd > 0) mo->eflags |= MFE_VERTICALFLIP; @@ -982,11 +981,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (no3dfloorgrav) { - if (mo->subsector->sector->gravity) - gravityadd = -FixedMul(gravity, - (FixedDiv(*mo->subsector->sector->gravity>>FRACBITS, 1000))); - else - gravityadd = -gravity; + gravityadd = -P_GetSectorGravity(mo->subsector->sector); if (mo->subsector->sector->verticalflip && gravityadd > 0) mo->eflags |= MFE_VERTICALFLIP; @@ -1006,8 +1001,10 @@ fixed_t P_GetMobjGravity(mobj_t *mo) gravityadd = -gravityadd; mo->eflags ^= MFE_VERTICALFLIP; } + if (wasflip == !(mo->eflags & MFE_VERTICALFLIP)) // note!! == ! is not equivalent to != here - turns numeric into bool this way P_PlayerFlip(mo); + if (mo->player->kartstuff[k_pogospring]) gravityadd = (5*gravityadd)/2; } @@ -1017,12 +1014,17 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (mo->flags2 & MF2_OBJECTFLIP) { mo->eflags |= MFE_VERTICALFLIP; + if (mo->z + mo->height >= mo->ceilingz) + { gravityadd = 0; + } else if (gravityadd < 0) // Don't sink, only rise up - gravityadd *= -1; + { + gravityadd = -gravityadd; + } } - else //Otherwise, sort through the other exceptions. + else // Otherwise, sort through the other exceptions. { switch (mo->type) { @@ -1083,7 +1085,9 @@ fixed_t P_GetMobjGravity(mobj_t *mo) // Goop has slower, reversed gravity if (goopgravity) + { gravityadd = -gravityadd/5; + } gravityadd = FixedMul(gravityadd, mo->scale); @@ -1121,10 +1125,8 @@ static void P_SceneryXYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) { I_Assert(!P_MobjWasRemoved(mo)); - const fixed_t fric_scale = FixedMul(FRACUNIT/32, mo->scale); - - if (abs(mo->momx) < fric_scale - && abs(mo->momy) < fric_scale) + if (abs(mo->momx) < FixedMul(FRACUNIT/32, mo->scale) + && abs(mo->momy) < FixedMul(FRACUNIT/32, mo->scale)) { mo->momx = 0; mo->momy = 0; @@ -1183,7 +1185,10 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) { // if in a walking frame, stop moving if (player->panim == PA_WALK && player->kartstuff[k_spinouttimer] == 0) + { P_SetPlayerMobjState(mo, S_KART_STND1); // SRB2kart - was S_PLAY_STND + } + mo->momx = player->cmomx; mo->momy = player->cmomy; } @@ -1204,7 +1209,9 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) } } else + { P_SceneryXYFriction(mo, oldx, oldy); + } } static void P_PushableCheckBustables(mobj_t *mo) @@ -1228,15 +1235,15 @@ static void P_PushableCheckBustables(mobj_t *mo) for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { + ffloor_t *rover; + fixed_t topheight, bottomheight; + if (!node->m_sector) break; if (!node->m_sector->ffloors) continue; - ffloor_t *rover; - fixed_t topheight, bottomheight; - for (rover = node->m_sector->ffloors; rover; rover = rover->next) { if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BUSTUP)) @@ -1322,6 +1329,29 @@ static boolean P_CheckSkyHit(mobj_t *mo) return false; } +// +// P_SkullFlyReset +// +// Resets the Skull Fly to its spawn state after it collides with something. +// +static boolean P_SkullFlyReset(mobj_t *mo) +{ + if (!mo->momx && !mo->momy && (mo->flags2 & MF2_SKULLFLY)) + { + // the skull slammed into something + mo->flags2 &= ~MF2_SKULLFLY; + mo->momx = mo->momy = mo->momz = 0; + + // set in 'search new direction' state? + if (mo->type != MT_EGGMOBILE) + P_SetMobjState(mo, mo->info->spawnstate); + + return true; + } + + return false; +} + // // P_XYMovement // @@ -1338,23 +1368,12 @@ void P_XYMovement(mobj_t *mo) I_Assert(!P_MobjWasRemoved(mo)); // if it's stopped - if (!mo->momx && !mo->momy) + if (P_SkullFlyReset(mo)) { - if (mo->flags2 & MF2_SKULLFLY) - { - // the skull slammed into something - mo->flags2 &= ~MF2_SKULLFLY; - mo->momx = mo->momy = mo->momz = 0; - - // set in 'search new direction' state? - if (mo->type != MT_EGGMOBILE) - P_SetMobjState(mo, mo->info->spawnstate); - - return; - } + return; } - player = mo->player; //valid only if player avatar + player = mo->player; // valid only if player avatar xmove = mo->momx; ymove = mo->momy; @@ -1412,7 +1431,9 @@ void P_XYMovement(mobj_t *mo) } } //} - if (!P_TryMove(mo, mo->x + xmove, mo->y + ymove, true) && !(mo->eflags & MFE_SPRUNG)) + + if (!P_TryMove(mo, mo->x + xmove, mo->y + ymove, true) + && !(P_MobjWasRemovedCompat(mo) || mo->eflags & MFE_SPRUNG)) { // blocked move moved = false; @@ -1538,29 +1559,6 @@ void P_XYMovement(mobj_t *mo) return; } - // draw damage on wall - //SPLAT TEST ---------------------------------------------------------- -#ifdef WALLSPLATS - if (blockingline && mo->type != MT_REDRING && mo->type != MT_FIREBALL - && !(mo->flags2 & (MF2_AUTOMATIC|MF2_RAILRING|MF2_BOUNCERING|MF2_EXPLOSION|MF2_SCATTER))) - // set by last P_TryMove() that failed - { - divline_t divl; - divline_t misl; - fixed_t frac; - - P_MakeDivline(blockingline, &divl); - misl.x = mo->x; - misl.y = mo->y; - misl.dx = mo->momx; - misl.dy = mo->momy; - frac = P_InterceptVector(&divl, &misl); - R_AddWallSplat(blockingline, P_PointOnLineSide(mo->x,mo->y,blockingline), - "A_DMG3", mo->z, frac, SPLATDRAWMODE_SHADE); - } -#endif - // --------------------------------------------------------- SPLAT TEST - P_ExplodeMissile(mo); return; } @@ -1709,6 +1707,9 @@ static void P_SceneryXYMovement(mobj_t *mo) if (!P_SceneryTryMove(mo, mo->x + mo->momx, mo->y + mo->momy)) P_SlideMove(mo, false); + if (P_MobjWasRemovedCompat(mo)) + return; + if ((!(mo->eflags & MFE_VERTICALFLIP) && mo->z > mo->floorz) || (mo->eflags & MFE_VERTICALFLIP && mo->z+mo->height < mo->ceilingz)) return; // no friction when airborne @@ -1736,7 +1737,7 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp { ffloor_t *rover; fixed_t delta1, delta2, thingtop; - fixed_t topheight, bottomheight; + fixed_t topheight, bottomheight, midheight; I_Assert(!P_MobjWasRemoved(mo)); @@ -1781,18 +1782,19 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp } } - const fixed_t mid = (bottomheight + ((topheight - bottomheight) / 2)); + midheight = (bottomheight + ((topheight - bottomheight) / 2)); - delta1 = abs(mo->z - mid); - delta2 = abs(thingtop - mid); + delta1 = abs(mo->z - midheight); + delta2 = abs(thingtop - midheight); - if (topheight > mo->floorz && delta1 < delta2 + if (topheight > mo->floorz && (delta1 < delta2) && !(rover->flags & FF_REVERSEPLATFORM) && ((P_MobjFlip(mo)*mo->momz >= 0) || (!(rover->flags & FF_PLATFORM)))) // In reverse gravity, only clip for FOFs that are intangible from their bottom (the "top" you're falling through) if you're coming from above ("below" in your frame of reference) { mo->floorz = topheight; } - if (bottomheight < mo->ceilingz && delta1 >= delta2 + + if (bottomheight < mo->ceilingz && (delta1 >= delta2) && !(rover->flags & FF_PLATFORM) && ((P_MobjFlip(mo)*mo->momz >= 0) || (!(rover->flags & FF_REVERSEPLATFORM)))) // In normal gravity, only clip for FOFs that are intangible from the top if you're coming from below { @@ -1812,7 +1814,7 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec) polyobj_t *po = subsec->polyList; sector_t *polysec; fixed_t delta1, delta2, thingtop; - fixed_t polytop, polybottom; + fixed_t polytop, polybottom, polymid; I_Assert(!P_MobjWasRemoved(mo)); @@ -1840,15 +1842,15 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec) polybottom = INT32_MIN; } - const fixed_t mid = polybottom + ((polytop - polybottom) / 2); + polymid = (polybottom + ((polytop - polybottom) / 2)); - delta1 = abs(mo->z - mid); - delta2 = abs(thingtop - mid); + delta1 = abs(mo->z - polymid); + delta2 = abs(thingtop - polymid); - if (polytop > mo->floorz && delta1 < delta2) + if (polytop > mo->floorz && (delta1 < delta2)) mo->floorz = polytop; - if (polybottom < mo->ceilingz && delta1 >= delta2) + if (polybottom < mo->ceilingz && (delta1 >= delta2)) mo->ceilingz = polybottom; po = (polyobj_t *)(po->link.next); @@ -1895,12 +1897,17 @@ boolean P_CheckDeathPitCollide(mobj_t *mo) const INT32 secspecial = GETSECSPECIAL(mo->subsector->sector->special, 1); - if (((mo->z <= mo->subsector->sector->floorheight - && !(mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_FLOOR)) - || (mo->z + mo->height >= mo->subsector->sector->ceilingheight - && (mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_CEILING))) - && (secspecial == 6 || secspecial == 7)) - return true; + // Death Pit + if (secspecial == 6 || secspecial == 7) + { + const boolean flipped = (mo->eflags & MFE_VERTICALFLIP); + + if (!flipped && (mo->subsector->sector->flags & SF_FLIPSPECIAL_FLOOR)) + return (mo->z <= mo->subsector->sector->floorheight); + + if (flipped && (mo->subsector->sector->flags & SF_FLIPSPECIAL_CEILING)) + return (mo->z + mo->height >= mo->subsector->sector->ceilingheight); + } return false; } @@ -1909,10 +1916,14 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover) { I_Assert(!P_MobjWasRemoved(mo)); - if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3 - && !(rover->master->flags & ML_BLOCKMONSTERS) - && ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > P_GetFFloorTopZAt(rover, mo->x, mo->y) - FixedMul(16*FRACUNIT, mo->scale))) + if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3) + { + if (!(rover->master->flags & ML_BLOCKMONSTERS) && + ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > P_GetFFloorTopZAt(rover, mo->x, mo->y) - FixedMul(16*FRACUNIT, mo->scale))) + { return true; + } + } return false; } @@ -2121,13 +2132,12 @@ static boolean P_ZMovement(mobj_t *mo) if (mo->type == MT_JETJAW && mo->z + mo->height > mo->watertop) mo->z = mo->watertop - mo->height; } - } // clip movement if (((mo->z <= mo->floorz && !(mo->eflags & MFE_VERTICALFLIP)) || (mo->z + mo->height >= mo->ceilingz && mo->eflags & MFE_VERTICALFLIP)) - && !(mo->flags & MF_NOCLIPHEIGHT)) + && !(mo->flags & MF_NOCLIPHEIGHT)) { vector3_t mom; mom.x = mo->momx; @@ -2146,6 +2156,10 @@ static boolean P_ZMovement(mobj_t *mo) } P_CheckPosition(mo, mo->x, mo->y); // Sets mo->standingslope correctly + + if (P_MobjWasRemovedCompat(mo)) // mobjs can be removed by P_CheckPosition -- Monster Iestyn 31/07/21 + return false; + if (((mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope) && (mo->type != MT_STEAM)) { mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope; @@ -2183,6 +2197,7 @@ static boolean P_ZMovement(mobj_t *mo) // Otherwise bounce up at half speed. else mom.z = -mom.z/2; + S_StartSound(mo, mo->info->activesound); } } @@ -2300,7 +2315,9 @@ static boolean P_ZMovement(mobj_t *mo) || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER)) mom.z = tmfloorthing->momz; - if (mo->standingslope) { // MT_STEAM will never have a standingslope, see above. + // MT_STEAM will never have a standingslope, see above. + if (mo->standingslope) + { P_QuantizeMomentumToSlope(&mom, mo->standingslope); } @@ -2321,7 +2338,7 @@ static boolean P_ZMovement(mobj_t *mo) if (((mo->z + mo->height > mo->ceilingz && !(mo->eflags & MFE_VERTICALFLIP)) || (mo->z < mo->floorz && mo->eflags & MFE_VERTICALFLIP)) - && !(mo->flags & MF_NOCLIPHEIGHT)) + && !(mo->flags & MF_NOCLIPHEIGHT)) { if (mo->eflags & MFE_VERTICALFLIP) mo->z = mo->floorz; @@ -2377,6 +2394,103 @@ static boolean P_ZMovement(mobj_t *mo) return true; } +// Check for "Mario" blocks to hit and bounce them +static void P_CheckMarioBlocks(mobj_t *mo) +{ + msecnode_t *node; + + // Only let the player punch + if (netgame && mo->player->spectator) + return; + + // Search the touching sectors, from side-to-side... + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + ffloor_t *rover; + + if (!node->m_sector->ffloors) + continue; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + // Come on, it's time to go... + if (!(rover->flags & FF_MARIO)) + continue; + + if (mo->eflags & MFE_VERTICALFLIP) + continue; // if you were flipped, your head isn't actually hitting your ceilingz is it? + + if (*rover->bottomheight != mo->ceilingz) + continue; // The player's head hit the bottom! + + // DO THE MARIO! + EV_MarioBlock(rover->master->frontsector, node->m_sector, *rover->topheight, mo); + } + } // Ugly ugly billions of braces! Argh! +} + +// Check if we're on a polyobject that triggers a linedef executor. +static boolean P_PlayerPolyObjectZMovement(mobj_t *mo) +{ + msecnode_t *node; + boolean stopmovecut = false; + + // no polyobjects on the map + if (!numPolyObjects) + { + return false; + } + + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + sector_t *sec = node->m_sector; + subsector_t *newsubsec; + size_t i; + + for (i = 0; i < numsubsectors; i++) + { + polyobj_t *po; + sector_t *polysec; + newsubsec = &subsectors[i]; + + if (newsubsec->sector != sec) + continue; + + for (po = newsubsec->polyList; po; po = (polyobj_t *)(po->link.next)) + { + if (!(po->flags & POF_SOLID)) + continue; + + if (!P_MobjInsidePolyobj(po, mo)) + continue; + + // We're inside it! Yess... + polysec = po->lines[0]->backsector; + + // Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red + if ((mo->z == polysec->ceilingheight || mo->z + mo->height == polysec->floorheight) && po->thinker) + stopmovecut = true; + + if (!(po->flags & POF_LDEXEC)) + continue; + + if (mo->z != polysec->ceilingheight) + continue; + + // We're landing on a PO, so check for + // a linedef executor. + // Trigger tags are 32000 + the PO's ID number. + P_LinedefExecute((INT16)(32000 + po->id), mo, NULL); + } + } + } + + return stopmovecut; +} + static void P_PlayerZMovement(mobj_t *mo) { I_Assert(!P_MobjWasRemoved(mo)); @@ -2410,8 +2524,8 @@ static void P_PlayerZMovement(mobj_t *mo) mo->z += mo->momz; // Have player fall through floor? - if (mo->player->playerstate == PST_DEAD - || mo->player->playerstate == PST_REBORN) + if (mo->player->playerstate == PST_DEAD || + mo->player->playerstate == PST_REBORN) return; if (mo->standingslope) @@ -2426,15 +2540,21 @@ static void P_PlayerZMovement(mobj_t *mo) if (P_IsObjectOnGround(mo) && !(mo->flags & MF_NOCLIPHEIGHT)) { if (mo->eflags & MFE_VERTICALFLIP) + { mo->z = mo->ceilingz - mo->height; + } else + { mo->z = mo->floorz; + } if (nightsplayer(mo->player)) { + const boolean flipped = (mo->eflags & MFE_VERTICALFLIP); + // bounce off floor if you were flying towards it - if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 0 && mo->player->flyangle < 180) - || (!(mo->eflags & MFE_VERTICALFLIP) && mo->player->flyangle > 180 && mo->player->flyangle <= 359)) + if ((flipped && mo->player->flyangle > 0 && mo->player->flyangle < 180) || + (!flipped && mo->player->flyangle > 180 && mo->player->flyangle <= 359)) { if (mo->player->flyangle < 90 || mo->player->flyangle >= 270) mo->player->flyangle += P_MobjFlip(mo)*90; @@ -2442,20 +2562,26 @@ static void P_PlayerZMovement(mobj_t *mo) mo->player->flyangle -= P_MobjFlip(mo)*90; mo->player->speed = FixedMul(mo->player->speed, 4*FRACUNIT/5); } + goto nightsdone; } // Get up if you fell. if ((mo->state == &states[mo->info->painstate] || mo->state == &states[S_KART_SPIN]) && mo->player->kartstuff[k_spinouttimer] == 0 && mo->player->kartstuff[k_squishedtimer] == 0) // SRB2kart + { P_SetPlayerMobjState(mo, S_KART_STND1); + } - if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)) { +#if 0 // praying that removing this dupe wont cause any issues... + if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)) + { // Handle landing on slope during Z movement P_HandleSlopeLanding(mo, (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)); } - - if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)) { +#endif + if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)) + { // Handle landing on slope during Z movement P_HandleSlopeLanding(mo, (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)); } @@ -2464,88 +2590,28 @@ static void P_PlayerZMovement(mobj_t *mo) { mo->pmomz = 0; // We're on a new floor, don't keep doing platform movement. - if (!tmfloorthing || tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) - || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER) // Spin Attack + if (!tmfloorthing || tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) || + tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER) // Spin Attack { mo->eflags |= MFE_JUSTHITFLOOR; // Spin Attack if (mo->eflags & MFE_JUSTHITFLOOR) { - // Check if we're on a polyobject - // that triggers a linedef executor. - msecnode_t *node; - boolean stopmovecut = false; - - if (numPolyObjects) + if (!P_PlayerPolyObjectZMovement(mo)) { - for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) - { - sector_t *sec = node->m_sector; - subsector_t *newsubsec; - size_t i; - - for (i = 0; i < numsubsectors; i++) - { - newsubsec = &subsectors[i]; - - if (newsubsec->sector != sec) - continue; - - if (!newsubsec->polyList) - continue; - - polyobj_t *po = newsubsec->polyList; - sector_t *polysec; - - while (po) - { - if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) - { - po = (polyobj_t *)(po->link.next); - continue; - } - - // We're inside it! Yess... - polysec = po->lines[0]->backsector; - - // Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red - if ((mo->z == polysec->ceilingheight || mo->z+mo->height == polysec->floorheight) && po->thinker) - stopmovecut = true; - - if (!(po->flags & POF_LDEXEC)) - { - po = (polyobj_t *)(po->link.next); - continue; - } - - if (mo->z == polysec->ceilingheight) - { - // We're landing on a PO, so check for - // a linedef executor. - // Trigger tags are 32000 + the PO's ID number. - P_LinedefExecute((INT16)(32000 + po->id), mo, NULL); - } - - po = (polyobj_t *)(po->link.next); - } - } - } - } - - if (!stopmovecut) - - // Cut momentum in half when you hit the ground and - // aren't pressing any controls. - if (!(mo->player->cmd.forwardmove || mo->player->cmd.sidemove) && !mo->player->cmomx && !mo->player->cmomy - && !(mo->player->kartstuff[k_spinouttimer])) - { - mo->momx = mo->momx/2; - mo->momy = mo->momy/2; - - if (mo->player->cmd.buttons & BT_BRAKE && !(mo->player->cmd.forwardmove)) // FURTHER slowdown if you're braking. + // Cut momentum in half when you hit the ground and + // aren't pressing any controls. + if (!(mo->player->cmd.forwardmove || mo->player->cmd.sidemove) && !mo->player->cmomx && !mo->player->cmomy + && !(mo->player->kartstuff[k_spinouttimer])) { mo->momx = mo->momx/2; mo->momy = mo->momy/2; + + if (mo->player->cmd.buttons & BT_BRAKE && !(mo->player->cmd.forwardmove)) // FURTHER slowdown if you're braking. + { + mo->momx = mo->momx/2; + mo->momy = mo->momy/2; + } } } } @@ -2623,14 +2689,17 @@ nightsdone: if (nightsplayer(mo->player)) { + const boolean flipped = (mo->eflags & MFE_VERTICALFLIP); + // bounce off ceiling if you were flying towards it - if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 180 && mo->player->flyangle <= 359) - || (!(mo->eflags & MFE_VERTICALFLIP) && mo->player->flyangle > 0 && mo->player->flyangle < 180)) + if ((flipped && mo->player->flyangle > 180 && mo->player->flyangle <= 359) + || (!flipped && mo->player->flyangle > 0 && mo->player->flyangle < 180)) { if (mo->player->flyangle < 90 || mo->player->flyangle >= 270) mo->player->flyangle -= P_MobjFlip(mo)*90; else mo->player->flyangle += P_MobjFlip(mo)*90; + mo->player->flyangle %= 360; mo->player->speed = FixedMul(mo->player->speed, 4*FRACUNIT/5); } @@ -2639,31 +2708,8 @@ nightsdone: // Check for "Mario" blocks to hit and bounce them if (P_MobjFlip(mo)*mo->momz > 0) { - msecnode_t *node; - - if (CheckForMarioBlocks && !(netgame && mo->player->spectator)) // Only let the player punch - { - // Search the touching sectors, from side-to-side... - for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) - { - ffloor_t *rover; - if (!node->m_sector->ffloors) - continue; - - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) - continue; - - // Come on, it's time to go... - if (rover->flags & FF_MARIO - && !(mo->eflags & MFE_VERTICALFLIP) // if you were flipped, your head isn't actually hitting your ceilingz is it? - && *rover->bottomheight == mo->ceilingz) // The player's head hit the bottom! - // DO THE MARIO! - EV_MarioBlock(rover->master->frontsector, node->m_sector, *rover->topheight, mo); - } - } // Ugly ugly billions of braces! Argh! - } + if (CheckForMarioBlocks) + P_CheckMarioBlocks(mo); // hit the ceiling if (mariomode) @@ -2801,7 +2847,7 @@ static boolean P_SceneryZMovement(mobj_t *mo) // clip movement if (((mo->z <= mo->floorz && !(mo->eflags & MFE_VERTICALFLIP)) || (mo->z + mo->height >= mo->ceilingz && mo->eflags & MFE_VERTICALFLIP)) - && !(mo->flags & MF_NOCLIPHEIGHT)) + && !(mo->flags & MF_NOCLIPHEIGHT)) { if (mo->eflags & MFE_VERTICALFLIP) mo->z = mo->ceilingz - mo->height; @@ -2831,7 +2877,7 @@ static boolean P_SceneryZMovement(mobj_t *mo) if (((mo->z + mo->height > mo->ceilingz && !(mo->eflags & MFE_VERTICALFLIP)) || (mo->z < mo->floorz && mo->eflags & MFE_VERTICALFLIP)) - && !(mo->flags & MF_NOCLIPHEIGHT)) + && !(mo->flags & MF_NOCLIPHEIGHT)) { if (mo->eflags & MFE_VERTICALFLIP) mo->z = mo->floorz; @@ -2869,13 +2915,13 @@ void P_MobjCheckWater(mobj_t *mobj) for (rover = sector->ffloors; rover; rover = rover->next) { fixed_t topheight, bottomheight; + fixed_t topcheck, bottomcheck; + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || (((rover->flags & FF_BLOCKPLAYER) && mobj->player) || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) continue; - fixed_t topcheck, bottomcheck; - if (mobj->eflags & MFE_VERTICALFLIP) { topcheck = (thingtop - FixedMul(mobj->info->height/2, mobj->scale)); diff --git a/src/p_spec.c b/src/p_spec.c index 35efaa857..560ac0b2a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5302,6 +5302,18 @@ static void P_RunLevelLoadExecutors(void) } } +static fixed_t P_GetSectorGravityFactor(sector_t *sec) +{ + return FixedDiv(*sec->gravity >> FRACBITS, 1000); +} + +fixed_t P_GetSectorGravity(sector_t *sec) +{ + if (sec && sec->gravity) + return FixedMul(gravity, P_GetSectorGravityFactor(sec)); + return gravity; +} + /** After the map has loaded, scans for specials that spawn 3Dfloors and * thinkers. * diff --git a/src/p_spec.h b/src/p_spec.h index 7b763c498..679ee65dc 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -56,6 +56,8 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n void P_PlayerInSpecialSector(player_t *player); void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *roversector); +fixed_t P_GetSectorGravity(sector_t *sec); + fixed_t P_FindLowestFloorSurrounding(sector_t *sec); fixed_t P_FindHighestFloorSurrounding(sector_t *sec); From 848115d1054da580112f3b40b848755db30c51ec Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Jul 2026 14:53:13 +0200 Subject: [PATCH 524/589] print the unedited musicdef field for whitespace warning otherwise this may just show whitespaces where they arent ones originally --- src/s_sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s_sound.c b/src/s_sound.c index 0a81764c7..d59a98887 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1357,7 +1357,7 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde int err = 0;\ STRBUFCPY(def->field, textline);\ for (textline = def->field; *textline; textline++) {\ - if (err == 0 && *textline == ' ') {err = 1; CONS_Alert(CONS_WARNING, "MUSICDEF: Erroneous whitespace detected in field '%s': '%s'.\n(file %s, line %d) Musicdef might not work correctly!\n", stoken, def->field, wadfiles[wadnum]->filename, line);}\ + if (err == 0 && *textline == ' ') {err = 1; CONS_Alert(CONS_WARNING, "MUSICDEF: Erroneous whitespace detected in field '%s': '%s'.\n(file %s, line %d) Musicdef might not work correctly!\n", stoken, value, wadfiles[wadnum]->filename, line);}\ if (*textline == '_') *textline = ' ';\ } From 97555bc263328234ba6e21ed7fb623900499cc83 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Jul 2026 15:03:07 +0200 Subject: [PATCH 525/589] remove trailing whitespaces from musicdef fields mostly just to prevent the warning popping from those, but also why not lol --- src/s_sound.c | 20 ++++++++++++-------- src/s_sound.h | 1 - 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index d59a98887..39c671879 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1352,13 +1352,18 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde textline = value; -// turn _ into spaces. -#define ADDDEF(field)\ - int err = 0;\ - STRBUFCPY(def->field, textline);\ - for (textline = def->field; *textline; textline++) {\ - if (err == 0 && *textline == ' ') {err = 1; CONS_Alert(CONS_WARNING, "MUSICDEF: Erroneous whitespace detected in field '%s': '%s'.\n(file %s, line %d) Musicdef might not work correctly!\n", stoken, value, wadfiles[wadnum]->filename, line);}\ - if (*textline == '_') *textline = ' ';\ +// turn _ into spaces while also removing trailing whitespaces. +#define ADDDEF(field) \ + int err = 0; \ + STRBUFCPY(def->field, textline); \ + size_t len = strlen(def->field); \ + while (len > 0 && (def->field[len-1] == ' ')) { \ + def->field[len-1] = 0; \ + len--; \ + } \ + for (textline = def->field; *textline; textline++) { \ + if (err == 0 && *textline == ' ') {err = 1; CONS_Alert(CONS_WARNING, "MUSICDEF: Erroneous whitespace detected in field '%s': '%s'.\n(file %s, line %d) Musicdef might not work correctly!\n", stoken, value, wadfiles[wadnum]->filename, line);} \ + if (*textline == '_') *textline = ' '; \ } if (fasticmp(stoken, "usage")) @@ -1371,7 +1376,6 @@ static boolean ReadMusicDefFields(UINT16 wadnum, int line, char *stoken, musicde } else if (fasticmp(stoken, "title")) { - def->use_info = true; ADDDEF(title); } else if (fasticmp(stoken, "alttitle")) diff --git a/src/s_sound.h b/src/s_sound.h index c7f487e92..077fd325e 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -186,7 +186,6 @@ typedef struct musicdef_s char title[256]; char alttitle[256]; char authors[256]; - boolean use_info; size_t num; } musicdef_t; From 38e50a3cfba04cadd95a7d9b3a1f4958e8479e0b Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Jul 2026 15:31:33 +0200 Subject: [PATCH 526/589] bit more p_mobj cleanup more unnesting stuffs --- src/p_mobj.c | 264 +++++++++++++++++++++++++++++---------------------- 1 file changed, 149 insertions(+), 115 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 840364b71..6eb30a7ae 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2835,13 +2835,11 @@ static boolean P_SceneryZMovement(mobj_t *mo) } // Fix for any silly pushables like the egg statues that are also scenery for some reason -- Monster Iestyn - if (P_CheckDeathPitCollide(mo)) + if ((mo->flags & MF_PUSHABLE) && + P_CheckDeathPitCollide(mo)) { - if (mo->flags & MF_PUSHABLE) - { - P_RemoveMobj(mo); - return false; - } + P_RemoveMobj(mo); + return false; } // clip movement @@ -2904,7 +2902,10 @@ void P_MobjCheckWater(mobj_t *mobj) fixed_t thingtop = mobj->z + mobj->height; // especially for players, infotable height does not neccessarily match actual height sector_t *sector = mobj->subsector->sector; ffloor_t *rover; - player_t *p = mobj->player; // Will just be null if not a player. + player_t *player = mobj->player; // Will just be null if not a player. + + const fixed_t moheight = FixedMul(mobj->info->height, mobj->scale); + const fixed_t mohalfheight = FixedMul(mobj->info->height/2, mobj->scale); // Default if no water exists. mobj->watertop = mobj->waterbottom = mobj->z - 1000*FRACUNIT; @@ -2918,19 +2919,19 @@ void P_MobjCheckWater(mobj_t *mobj) fixed_t topcheck, bottomcheck; if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) - || (((rover->flags & FF_BLOCKPLAYER) && mobj->player) - || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) + || (((rover->flags & FF_BLOCKPLAYER) && player) + || ((rover->flags & FF_BLOCKOTHERS) && !player))) continue; if (mobj->eflags & MFE_VERTICALFLIP) { - topcheck = (thingtop - FixedMul(mobj->info->height/2, mobj->scale)); + topcheck = (thingtop - mohalfheight); bottomcheck = thingtop; } else { topcheck = mobj->z; - bottomcheck = (mobj->z + FixedMul(mobj->info->height/2, mobj->scale)); + bottomcheck = (mobj->z + mohalfheight); } topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); @@ -2948,16 +2949,17 @@ void P_MobjCheckWater(mobj_t *mobj) mobj->waterbottom = bottomheight; // Just touching the water? - if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop - FixedMul(mobj->info->height, mobj->scale) < bottomheight) - || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + FixedMul(mobj->info->height, mobj->scale) > topheight)) + if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop - moheight < bottomheight) || + (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + moheight > topheight)) { mobj->eflags |= MFE_TOUCHWATER; if (rover->flags & FF_GOOWATER && !(mobj->flags & MF_NOGRAVITY)) mobj->eflags |= MFE_GOOWATER; } + // Actually in the water? - if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop - FixedMul(mobj->info->height/2, mobj->scale) > bottomheight) - || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + FixedMul(mobj->info->height/2, mobj->scale) < topheight)) + if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop - mohalfheight > bottomheight) || + (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + mohalfheight < topheight)) { mobj->eflags |= MFE_UNDERWATER; if (rover->flags & FF_GOOWATER && !(mobj->flags & MF_NOGRAVITY)) @@ -2966,18 +2968,19 @@ void P_MobjCheckWater(mobj_t *mobj) } // Specific things for underwater players - if (p && (mobj->eflags & MFE_UNDERWATER) == MFE_UNDERWATER) + if (player && (mobj->eflags & MFE_UNDERWATER) == MFE_UNDERWATER) { - if (!((p->powers[pw_super]) || (p->powers[pw_invulnerability]))) + if (!((player->powers[pw_super]) || (player->powers[pw_invulnerability]))) { - if ((p->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) { // Water removes attract shield. - p->powers[pw_shield] = p->powers[pw_shield] & SH_STACK; - P_FlashPal(p, PAL_WHITE, 1); + player->powers[pw_shield] = player->powers[pw_shield] & SH_STACK; + P_FlashPal(player, PAL_WHITE, 1); } } + // Can't drown. - p->powers[pw_underwater] = 0; + player->powers[pw_underwater] = 0; } // The rest of this code only executes on a water state change. @@ -2985,20 +2988,20 @@ void P_MobjCheckWater(mobj_t *mobj) return; // Spectators and dead players also don't count. - if (p && (p->spectator || p->playerstate != PST_LIVE)) + if (player && (player->spectator || player->playerstate != PST_LIVE)) return; - if ((p) // Players + if (player // Players || (mobj->flags & MF_PUSHABLE) // Pushables || ((mobj->info->flags & MF_PUSHABLE) && mobj->fuse) // Previously pushable, might be moving still ) { // Check to make sure you didn't just cross into a sector to jump out of // that has shallower water than the block you were originally in. - if (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->watertop-mobj->floorz <= FixedMul(mobj->info->height, mobj->scale)>>1) + if (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->watertop-mobj->floorz <= moheight>>1) return; - if ((mobj->eflags & MFE_VERTICALFLIP) && mobj->ceilingz-mobj->waterbottom <= FixedMul(mobj->info->height, mobj->scale)>>1) + if ((mobj->eflags & MFE_VERTICALFLIP) && mobj->ceilingz-mobj->waterbottom <= moheight>>1) return; if ((mobj->eflags & MFE_GOOWATER || wasingoo)) // Decide what happens to your momentum when you enter/leave goopy water. @@ -3011,13 +3014,13 @@ void P_MobjCheckWater(mobj_t *mobj) if (P_MobjFlip(mobj)*mobj->momz < 0) { - if ((mobj->eflags & MFE_VERTICALFLIP && thingtop-(FixedMul(mobj->info->height, mobj->scale)>>1)-mobj->momz <= mobj->waterbottom) - || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z+(FixedMul(mobj->info->height, mobj->scale)>>1)-mobj->momz >= mobj->watertop)) + if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop-(moheight>>1)-mobj->momz <= mobj->waterbottom) || + (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z+(moheight>>1)-mobj->momz >= mobj->watertop)) { // Spawn a splash mobj_t *splish; - if (mobj->eflags & MFE_VERTICALFLIP) + if ((mobj->eflags & MFE_VERTICALFLIP)) { splish = P_SpawnMobj(mobj->x, mobj->y, mobj->waterbottom-FixedMul(mobjinfo[MT_SPLISH].height, mobj->scale), MT_SPLISH); splish->flags2 |= MF2_OBJECTFLIP; @@ -3031,9 +3034,9 @@ void P_MobjCheckWater(mobj_t *mobj) } // skipping stone! - if (p && p->kartstuff[k_waterskip] < 2 - && ((p->speed/3 > abs(mobj->momz)) // Going more forward than horizontal, so you can skip across the water. - || (p->speed > K_GetKartSpeed(p,false)/3 && p->kartstuff[k_waterskip])) // Already skipped once, so you can skip once more! + if (player && player->kartstuff[k_waterskip] < 2 + && ((player->speed/3 > abs(mobj->momz)) // Going more forward than horizontal, so you can skip across the water. + || (player->speed > K_GetKartSpeed(player, false)/3 && player->kartstuff[k_waterskip])) // Already skipped once, so you can skip once more! && ((!(mobj->eflags & MFE_VERTICALFLIP) && thingtop - mobj->momz > mobj->watertop) || ((mobj->eflags & MFE_VERTICALFLIP) && mobj->z - mobj->momz < mobj->waterbottom))) { @@ -3046,23 +3049,23 @@ void P_MobjCheckWater(mobj_t *mobj) if (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->momz < FixedMul(min, mobj->scale)) mobj->momz = FixedMul(min, mobj->scale); - else if (mobj->eflags & MFE_VERTICALFLIP && mobj->momz > FixedMul(-min, mobj->scale)) + else if ((mobj->eflags & MFE_VERTICALFLIP) && mobj->momz > FixedMul(-min, mobj->scale)) mobj->momz = FixedMul(-min, mobj->scale); - p->kartstuff[k_waterskip]++; + player->kartstuff[k_waterskip]++; } } else if (P_MobjFlip(mobj)*mobj->momz > 0) { - if (((mobj->eflags & MFE_VERTICALFLIP && thingtop-(FixedMul(mobj->info->height, mobj->scale)>>1)-mobj->momz > mobj->waterbottom) - || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z+(FixedMul(mobj->info->height, mobj->scale)>>1)-mobj->momz < mobj->watertop)) + if ((((mobj->eflags & MFE_VERTICALFLIP) && thingtop-(moheight>>1)-mobj->momz > mobj->waterbottom) + || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z+(moheight>>1)-mobj->momz < mobj->watertop)) && !(mobj->eflags & MFE_UNDERWATER)) // underwater check to prevent splashes on opposite side { // Spawn a splash mobj_t *splish; - if (mobj->eflags & MFE_VERTICALFLIP) + if ((mobj->eflags & MFE_VERTICALFLIP)) { splish = P_SpawnMobj(mobj->x, mobj->y, mobj->waterbottom-FixedMul(mobjinfo[MT_SPLISH].height, mobj->scale), MT_SPLISH); splish->flags2 |= MF2_OBJECTFLIP; @@ -3416,13 +3419,117 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled return false; } +static void P_CheckCrumblingPlatforms(mobj_t *mobj) +{ + msecnode_t *node; + + if (netgame && mobj->player->spectator) + return; + + for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) + { + ffloor_t *rover; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + if (!(rover->flags & FF_CRUMBLE)) + continue; + + if (mobj->eflags & MFE_VERTICALFLIP) + { + if (P_GetSpecialBottomZ(mobj, sectors + rover->secnum, node->m_sector) != mobj->z + mobj->height) // You nut. + continue; + } + else + { + if (P_GetSpecialTopZ(mobj, sectors + rover->secnum, node->m_sector) != mobj->z) + continue; + } + + EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), mobj->player, rover->alpha, !(rover->flags & FF_NORETURN)); + } + } +} + +static boolean P_MobjTouchesSectorWithWater(mobj_t *mobj) +{ + msecnode_t *node; + + for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) + { + ffloor_t *rover; + + if (!node->m_sector->ffloors) + continue; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + if (!(rover->flags & FF_SWIMMABLE)) // Is there water? + continue; + + return true; + } + } + + return false; +} + +// Check for floating water platforms and bounce them +static void P_CheckFloatbobPlatforms(mobj_t *mobj) +{ + msecnode_t *node; + + // Can't land on anything if you're not moving downwards + if (P_MobjFlip(mobj)*mobj->momz >= 0) + return; + + if (!P_MobjTouchesSectorWithWater(mobj)) + return; + + for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) + { + ffloor_t *rover; + + if (!node->m_sector->ffloors) + continue; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + if (!(rover->flags & FF_FLOATBOB)) + continue; + + + if (mobj->eflags & MFE_VERTICALFLIP) + { + if (abs(*rover->bottomheight - (mobj->z + mobj->height)) > abs(mobj->momz)) + continue; + } + else + { + if (abs(*rover->topheight - mobj->z) > abs(mobj->momz)) // The player is landing on the cheese! + continue; + } + + // Initiate a 'bouncy' elevator function which slowly diminishes. + EV_BounceSector(rover->master->frontsector, -mobj->momz, rover->master); + } + } // Ugly ugly billions of braces! Argh! +} + // // P_PlayerMobjThinker // static void P_PlayerMobjThinker(mobj_t *mobj) { - msecnode_t *node; - I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); @@ -3469,84 +3576,11 @@ static void P_PlayerMobjThinker(mobj_t *mobj) else P_TryMove(mobj, mobj->x, mobj->y, true); - if (!(netgame && mobj->player->spectator)) - { - // Crumbling platforms - for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) - { - ffloor_t *rover; + // Crumbling platforms + P_CheckCrumblingPlatforms(mobj); - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - boolean oncrumble; - - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_CRUMBLE)) - continue; - - if (mobj->eflags & MFE_VERTICALFLIP) - { - oncrumble = P_GetSpecialBottomZ(mobj, sectors + rover->secnum, node->m_sector) == mobj->z + mobj->height; // You nut. - } - else - { - oncrumble = P_GetSpecialTopZ(mobj, sectors + rover->secnum, node->m_sector) == mobj->z; - } - - if (oncrumble) - EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), mobj->player, rover->alpha, !(rover->flags & FF_NORETURN)); - } - } - } - - // Check for floating water platforms and bounce them - if (CheckForFloatBob && P_MobjFlip(mobj)*mobj->momz < 0) - { - boolean thereiswater = false; - - for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) - { - if (!node->m_sector->ffloors) - continue; - - ffloor_t *rover; - // Get water boundaries first - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) - continue; - - if (rover->flags & FF_SWIMMABLE) // Is there water? - { - thereiswater = true; - break; - } - } - } - - if (thereiswater) - { - for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) - { - if (!node->m_sector->ffloors) - continue; - - ffloor_t *rover; - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_FLOATBOB)) - continue; - - if ((!(mobj->eflags & MFE_VERTICALFLIP) && abs(*rover->topheight-mobj->z) <= abs(mobj->momz)) // The player is landing on the cheese! - || (mobj->eflags & MFE_VERTICALFLIP && abs(*rover->bottomheight-(mobj->z+mobj->height)) <= abs(mobj->momz))) - { - // Initiate a 'bouncy' elevator function - // which slowly diminishes. - EV_BounceSector(rover->master->frontsector, -mobj->momz, rover->master); - } - } - } - } // Ugly ugly billions of braces! Argh! - } + if (CheckForFloatBob) + P_CheckFloatbobPlatforms(mobj); // always do the gravity bit now, that's simpler // BUT CheckPosition only if wasn't done before. From 3a2e009d01fa9768d490585f2051468d7ae3c7f4 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Jul 2026 15:52:02 +0200 Subject: [PATCH 527/589] have the musiccredit "box" style be colourized --- src/hu_stuff.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 77931550d..e7c8c3ddb 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2259,12 +2259,13 @@ static void HU_DrawSongCreditsBox(void) y = -BOXCREDITHEIGHT*dup + (FixedMul(BOXCREDITHEIGHT*FRACUNIT, FixedDiv(t*FRACUNIT, TICRATE*FRACUNIT/2))*dup - interpoffset)/FRACUNIT; } - bgt = (NUMTRANSMAPS/2) + (cursongcredit.trans/2); + bgt = (NUMTRANSMAPS/2) + (cursongcredit.trans/2) - 2; // arbitrary value, looks a bit better if (bgt < NUMTRANSMAPS) { - V_DrawFill(x, y, strwidth*dup, BOXCREDITHEIGHT*dup, 28|flags|(bgt< Date: Tue, 21 Jul 2026 15:54:18 +0200 Subject: [PATCH 528/589] smol fbo stuff cleanup was from the water branch --- src/hardware/r_opengl/r_opengl.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 0c04beb09..0e846a17e 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -776,15 +776,15 @@ static int GLFramebuffer_CheckExt(void) // gl versions from 2.1 may still support framebuffer objects // maybe, just maybe, we support the standart extensions - if (GL_isExtAvailable("GL_ARB_framebuffer_no_attachments", gl_extensions) - && GL_isExtAvailable("GL_ARB_framebuffer_object", gl_extensions) - && GL_isExtAvailable("GL_ARB_framebuffer_sRGB", gl_extensions)) + if (GL_isExtAvailable("GL_ARB_framebuffer_no_attachments", gl_extensions) && + GL_isExtAvailable("GL_ARB_framebuffer_object", gl_extensions) && + GL_isExtAvailable("GL_ARB_framebuffer_sRGB", gl_extensions)) return FBO_ARB; // nope, try the older 2.1 extensions - if (GL_isExtAvailable("GL_EXT_framebuffer_no_attachments", gl_extensions) - && GL_isExtAvailable("GL_EXT_framebuffer_object", gl_extensions) - && GL_isExtAvailable("GL_EXT_framebuffer_sRGB", gl_extensions)) + if (GL_isExtAvailable("GL_EXT_framebuffer_no_attachments", gl_extensions) && + GL_isExtAvailable("GL_EXT_framebuffer_object", gl_extensions) && + GL_isExtAvailable("GL_EXT_framebuffer_sRGB", gl_extensions)) { // perhaps we may even support a stencil attachment if (GL_isExtAvailable("GL_EXT_packed_depth_stencil", gl_extensions)) @@ -885,7 +885,7 @@ void SetupGLFunc4(void) { \ GL_MSG_Warning("failed to get OpenGL FBO function: %s\n", #func); \ GL_DBG_Printf("\nFBO: No framebuffer object support\n"); \ - supportFBO = false; \ + supportFBO = FBO_NONE; \ return; \ } \ @@ -3247,7 +3247,7 @@ void GL_SetTransform(FTransform *stransform) #ifdef USE_FBO_OGL static void GL_Framebuffer_DeleteAttachments(void) { - if (!supportFBO || !framebufferobject.init) + if (supportFBO == FBO_NONE || !framebufferobject.init) return; // Unbind the framebuffer @@ -3267,7 +3267,7 @@ static void GL_Framebuffer_DeleteAttachments(void) static void GL_Framebuffer_Generate(void) { - if (!supportFBO || framebufferobject.init || !UseScreenFBO()) + if (supportFBO == FBO_NONE || framebufferobject.init || !UseScreenFBO()) return; // Generate the framebuffer @@ -3287,10 +3287,10 @@ static void GL_Framebuffer_Generate(void) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); Clamp2D(GL_TEXTURE_WRAP_S); Clamp2D(GL_TEXTURE_WRAP_T); - pglBindTexture(GL_TEXTURE_2D, 0); // Attach the framebuffer texture to the framebuffer pglFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, framebufferobject.tex, 0); + pglBindTexture(GL_TEXTURE_2D, 0); } // Generate the renderbuffer @@ -3332,7 +3332,7 @@ static void GL_Framebuffer_Generate(void) // if this fails, dont retry it a gazillion times // this wouldnt recover - supportFBO = false; + supportFBO = FBO_NONE; pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); return; } @@ -3345,7 +3345,7 @@ static void GL_Framebuffer_Generate(void) void GL_Framebuffer_Unbind(void) { - if (!supportFBO || !framebufferobject.init) + if (supportFBO == FBO_NONE || !framebufferobject.init) return; pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); @@ -3354,13 +3354,13 @@ void GL_Framebuffer_Unbind(void) void GL_Framebuffer_Enable(void) { - if (!supportFBO || !UseScreenFBO()) + if (supportFBO == FBO_NONE || !UseScreenFBO()) return; GL_Framebuffer_Generate(); // failed - if (!supportFBO || !framebufferobject.init) + if (supportFBO == FBO_NONE || !framebufferobject.init) return; pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj); @@ -3369,7 +3369,7 @@ void GL_Framebuffer_Enable(void) void GL_Framebuffer_Disable(void) { - if (!supportFBO || !framebufferobject.init) + if (supportFBO == FBO_NONE || !framebufferobject.init) return; pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); From 4f21d8f983f48d7bb55f78bc95d6e671525d8f44 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Jul 2026 16:05:03 +0200 Subject: [PATCH 529/589] dont apply lua rumble during replay playback same as non lua rumble --- src/lua_baselib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index d24b88c51..9703cbafe 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3087,6 +3087,8 @@ static int lib_gPlayerDeviceRumble(lua_State *L) if (!player) return LUA_ErrInvalid(L, "player_t"); + if (demo.playback) return 0; + pnum = P_GetLocalPlayerNumForPlayer(player); // Not a local player From a539f38e72f6c0a858e8b4139f21322b7b134d95 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Jul 2026 20:32:58 +0200 Subject: [PATCH 530/589] add more safety checks to some maploading stuff + rename things to make more sense --- src/hardware/hw_cache.c | 2 +- src/p_setup.c | 146 ++++++++++++++++++++++------------------ src/r_segs.cpp | 2 +- 3 files changed, 81 insertions(+), 69 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 9300cbe81..c4cd7d383 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -998,7 +998,7 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum) const char *flatname = W_CheckNameForNum(flatlumpnum); // hack for gba rainbow roads cyan floors - if (UNLIKELY(memcmp(flatname, "GBA_RRF5", 8) == 0 && flatname[8] == 0)) + if (UNLIKELY(flatname && memcmp(flatname, "GBA_RRF5", 8) == 0 && flatname[8] == 0)) { glMipmap->flags &= ~TF_CHROMAKEYED; } diff --git a/src/p_setup.c b/src/p_setup.c index 54b461665..c878d35d4 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -318,15 +318,15 @@ void P_AllocMapHeader(INT16 i) // Loads the vertexes for a level. FUNCINLINE static ATTRINLINE void P_LoadVertices(UINT8 *data) { - mapvertex_t *ml = (mapvertex_t *)data; - vertex_t *li = vertexes; + mapvertex_t *mv = (mapvertex_t *)data; + vertex_t *v = vertexes; size_t i; // Copy and convert vertex coordinates, internal representation as fixed. - for (i = 0; i < numvertexes; i++, li++, ml++) + for (i = 0; i < numvertexes; i++, v++, mv++) { - li->x = SHORT(ml->x)<y = SHORT(ml->y)<x = SHORT(mv->x)<y = SHORT(mv->y)<v1); - v2 = SHORT(ml->v2); + v1 = SHORT(ms->v1); + v2 = SHORT(ms->v2); // e6y - // check and fix wrong references to non-existent vertexes - // see e1m9 @ NIVELES.WAD - // http://www.doomworld.com/idgames/index.php?id=12647 - if ((unsigned)v1 >= numvertexes || (unsigned)v2 >= numvertexes) - { - if ((unsigned)v1 >= numvertexes) - CorruptMapWarning(va("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v1)); - if ((unsigned)v2 >= numvertexes) - CorruptMapWarning(va("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v2)); + // moved down for additional checks to avoid overflow + // if wrong vertexe's indexes are in SEGS lump + // see below for more detailed information - if (li->sidedef == &sides[li->linedef->sidenum[0]]) - { - li->v1 = lines[ml->linedef].v1; - li->v2 = lines[ml->linedef].v2; - } - else - { - li->v1 = lines[ml->linedef].v2; - li->v2 = lines[ml->linedef].v1; - } - } - else - { - li->v1 = &vertexes[v1]; - li->v2 = &vertexes[v2]; - } + seg->angle = (SHORT(ms->angle)) << FRACBITS; + seg->offset = (SHORT(ms->offset)) << FRACBITS; -#ifdef HWRENDER - if (rendermode == render_opengl) - { - li->fv1.x = FixedToFloat(li->v1->x); - li->fv1.y = FixedToFloat(li->v1->y); - //li->fv1.z = FixedToFloat(li->v1->z); // z is unused in gl - - li->fv2.x = FixedToFloat(li->v2->x); - li->fv2.y = FixedToFloat(li->v2->y); - //li->fv2.z = FixedToFloat(li->v2->z); - } -#endif - li->length = P_SegLength(li); - li->angle = (SHORT(ml->angle))<offset = (SHORT(ml->offset))<linedef); + rawlinedef = SHORT(ms->linedef); //e6y: check for wrong indexes if ((unsigned)rawlinedef >= numlines) @@ -546,8 +511,8 @@ static void P_LoadSegs(UINT8 *data) } ldef = &lines[rawlinedef]; - li->linedef = ldef; - rawside = SHORT(ml->side); + seg->linedef = ldef; + rawside = SHORT(ms->side); //e6y: fix wrong side index if (rawside != 0 && rawside != 1) @@ -562,9 +527,9 @@ static void P_LoadSegs(UINT8 *data) I_Error("P_LoadSegs: linedef %d for seg %s references a non-existent sidedef %d", rawlinedef, sizeu1(i), ldef->sidenum[rawside]); } - li->side = rawside; + seg->side = rawside; - li->sidedef = &sides[ldef->sidenum[rawside]]; + seg->sidedef = &sides[ldef->sidenum[rawside]]; /* cph 2006/09/30 - our frontsector can be the second side of the * linedef, so must check for NO_INDEX in case we are incorrectly @@ -572,11 +537,11 @@ static void P_LoadSegs(UINT8 *data) if (ldef->sidenum[rawside] == NO_INDEX) { CorruptMapWarning(va("P_LoadSegs: front of seg %s has no sidedef\n", sizeu1(i))); - li->frontsector = NULL; + seg->frontsector = NULL; } else { - li->frontsector = sides[ldef->sidenum[rawside]].sector; + seg->frontsector = sides[ldef->sidenum[rawside]].sector; } if (ldef->flags & ML_TWOSIDED) @@ -584,15 +549,58 @@ static void P_LoadSegs(UINT8 *data) if (ldef->sidenum[rawside^1] == NO_INDEX) { CorruptMapWarning(va("P_LoadSegs: back of seg %s has no sidedef while being marked as double sided\n", sizeu1(i))); - li->backsector = NULL; + seg->backsector = NULL; } else { - li->backsector = sides[ldef->sidenum[rawside^1]].sector; + seg->backsector = sides[ldef->sidenum[rawside^1]].sector; } } - P_UpdateSegLightOffset(li); + // e6y + // check and fix wrong references to non-existent vertexes + // see e1m9 @ NIVELES.WAD + // http://www.doomworld.com/idgames/index.php?id=12647 + if ((unsigned)v1 >= numvertexes || (unsigned)v2 >= numvertexes) + { + if ((unsigned)v1 >= numvertexes) + CorruptMapWarning(va("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v1)); + if ((unsigned)v2 >= numvertexes) + CorruptMapWarning(va("P_LoadSegs: seg %s references a non-existent vertex %d\n", sizeu1(i), v2)); + + if (seg->sidedef == &sides[seg->linedef->sidenum[0]]) + { + seg->v1 = lines[ms->linedef].v1; + seg->v2 = lines[ms->linedef].v2; + } + else + { + seg->v1 = lines[ms->linedef].v2; + seg->v2 = lines[ms->linedef].v1; + } + } + else + { + seg->v1 = &vertexes[v1]; + seg->v2 = &vertexes[v2]; + } + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + seg->fv1.x = FixedToFloat(seg->v1->x); + seg->fv1.y = FixedToFloat(seg->v1->y); + //seg->fv1.z = FixedToFloat(seg->v1->z); // z is unused in gl + + seg->fv2.x = FixedToFloat(seg->v2->x); + seg->fv2.y = FixedToFloat(seg->v2->y); + //seg->fv2.z = FixedToFloat(seg->v2->z); + } +#endif + + seg->length = P_SegLength(seg); + + P_UpdateSegLightOffset(seg); } } @@ -610,10 +618,6 @@ FUNCINLINE static ATTRINLINE void P_LoadSubsectors(void *data) } } -// -// P_LoadSectors -// - // // levelflats // @@ -665,13 +669,17 @@ static void P_CheckCyanFlat(levelflat_t *levelflat) const char *flatname = W_CheckNameForNum(levelflat->lumpnum); // hack for gba rainbow roads cyan floors - if (UNLIKELY(memcmp(flatname, "GBA_RRF5", 8) == 0 && flatname[8] == 0)) + if (UNLIKELY(flatname && memcmp(flatname, "GBA_RRF5", 8) == 0 && flatname[8] == 0)) { levelflat->cyan = false; return; } const UINT8 *flat = R_GetFlat(levelflat->lumpnum); + + if (!flat) + return; + const size_t size = W_LumpLength(levelflat->lumpnum); for (size_t steppy = 0; steppy < size; steppy++) @@ -791,6 +799,10 @@ INT32 P_CheckLevelFlat(const char *flatname) return (INT32)i; } +// +// P_LoadSectors +// + static const sector_t sector_default = { .nexttag = -1, .firsttag = -1, @@ -1894,7 +1906,7 @@ static void P_ReadBlockMapLump(INT16 *wadblockmaplump, size_t count) // because making both the WAD and PK3 loading code use // the same functions is trickier than it looks for blockmap // -- Monster Iestyn 09/01/18 -static boolean P_LoadRawBlockMap(UINT8 *data, size_t count) +static boolean P_LoadBlockMap(UINT8 *data, size_t count) { if (!count || count >= 0x20000) return false; @@ -2120,7 +2132,7 @@ static void P_LoadMapLUT(const virtres_t* virt) rejectmatrix = NULL; } - if (!(virtblockmap && P_LoadRawBlockMap(virtblockmap->data, virtblockmap->size))) + if (!(virtblockmap && P_LoadBlockMap(virtblockmap->data, virtblockmap->size))) P_CreateBlockMap(); } diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 8a2693c84..3f6b9d449 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1882,7 +1882,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) // big room fix if (longboi) - rw_distance = (fixed_t)R_CalcSegDist(curline,viewx,viewy); + rw_distance = (fixed_t)R_CalcSegDist(curline, viewx, viewy); ds_p->x1 = rw_x = start; ds_p->x2 = stop; From 6e91e00289066aff557092c806a5cbd5f5c25f40 Mon Sep 17 00:00:00 2001 From: romoney5 Date: Fri, 24 Jul 2026 00:43:58 -0400 Subject: [PATCH 531/589] Ignore scenery thinker for player objects Prevents Lua from being able to remove player objects using MF_SCENERY and causing potential crashes --- 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 6eb30a7ae..8b4f5c5b1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9170,7 +9170,7 @@ void P_MobjThinker(mobj_t *mobj) mobj->frame = (mobj->frame & ~FF_TRANSMASK) | (((NUMTRANSMAPS-1) - mobj->fuse / 2) << FF_TRANSSHIFT); // Special thinker for scenery objects - if (mobj->flags & MF_SCENERY) + if (mobj->flags & MF_SCENERY && !mobj->player) { P_MobjSceneryThink(mobj); return; From 7e47b9b6ba44958e5c24db3c8490277c9b1497d8 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jul 2026 07:35:42 +0200 Subject: [PATCH 532/589] fix crash in K_drawKartMinimapHead if player mobj was removed --- src/k_hud.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/k_hud.c b/src/k_hud.c index c5b166d36..9dbdb935b 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -3581,6 +3581,10 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) #endif skin = K_GetMobjSkin(mo); + + if (!skin) + return; + minimaphead = (skinlocal ? localfacemmapprefix : facemmapprefix)[K_GetMobjSkinNum(skin, skinlocal)]; if (minimaphead == NULL) @@ -3784,6 +3788,9 @@ static void K_drawKartMinimap(void) mobj_t *mobj = players[localplayers[i]].mo; + if (!mobj) + continue; + // dont draw for no contestants boolean playertimedout = (mobj->health <= 0 && players[localplayers[i]].pflags & PF_TIMEOVER); From 957d3f72291682753e1f344cb96ebfaa2ca160a7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jul 2026 15:30:56 +0200 Subject: [PATCH 533/589] delet fmt for lua hook profiler i dont want another stinky library this would just be an arsepain to include in windoze builds TODO: make this drawer less of a mess, maybe integrate into perfstats instead? --- src/Makefile | 2 +- src/lua_profile.cpp | 64 ++++++++++++--------------------------------- 2 files changed, 18 insertions(+), 48 deletions(-) diff --git a/src/Makefile b/src/Makefile index 77c9f7129..4ee7cf1a9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -307,7 +307,7 @@ opts+=$(WFLAGS) $(CFLAGS) cxxopts:=$(opts) $(CXXFLAGS) opts+=$(CWFLAGS) # warning flags that shouldnt be passed to c++ compiler -libs+=$(LDFLAGS) -lstdc++ -lpthread -lfmt +libs+=$(LDFLAGS) -lstdc++ -lpthread asflags:=$(ASFLAGS) -x assembler-with-cpp diff --git a/src/lua_profile.cpp b/src/lua_profile.cpp index a25646a74..3c7b1c81f 100644 --- a/src/lua_profile.cpp +++ b/src/lua_profile.cpp @@ -16,9 +16,6 @@ #include #include -#include -#include - extern "C" { #include "blua/lua.h" }; @@ -93,7 +90,8 @@ lua_timer_t* LUA_BeginFunctionTimer(lua_State* L, int fn_idx, const char* name) return view; }; - auto [it, ins] = g_tic_timers.try_emplace(fmt::format("{}:{} ({})", label(), ar.linedefined, name)); + // i sure hope this std::string mess is fine... + auto [it, ins] = g_tic_timers.try_emplace(std::string(va("%s:%d (%s)", std::string(label()).c_str(), ar.linedefined, name))); auto& [key, timer] = *it; g_time_reference = I_GetPreciseTime(); @@ -145,10 +143,7 @@ void LUA_ResetTicTimers(void) void LUA_RenderTimers(void) { - ///using srb2::Draw; - constexpr int kRowHeight = 4; - //constexpr float kScale = 0.5f; // pretty much what the whole srb2::Draw does lol auto draw_row = [](float x, float y, INT32 flags, const std::string& str) @@ -162,15 +157,11 @@ void LUA_RenderTimers(void) }; float row_y = kRowHeight - 60; - draw_row(0.f, row_y - kRowHeight, 0, fmt::format("-- AVERAGES PER TIC (over {} tics) --", cv_lua_profile.value)); - - //Draw row = Draw(0, kRowHeight).font(Draw::Font::kConsole).align(Draw::Align::kLeft).scale(0.5).flags(V_MONOSPACE); - //row.y(-kRowHeight).text("-- AVERAGES PER TIC (over {} tics) --", cv_lua_profile.value); + draw_row(0.f, row_y - kRowHeight, 0, va("-- AVERAGES PER TIC (over %d tics) --", cv_lua_profile.value)); if (g_invalid) { row_y += kRowHeight; - //row.flags(V_GRAYMAP).text(" "); draw_row(0.f, row_y - kRowHeight, V_GRAYMAP, " "); return; } @@ -209,36 +200,26 @@ void LUA_RenderTimers(void) } } - /* - Draw tally = row.flags(color_flag(cum * 1'000'000.0)); - - tally.text("{:8.2f} us - TOTAL", cum * 1'000'000.0); - tally.y(kRowHeight).text("{:8.2f} ms", cum * 1000.0); - tally.y(kRowHeight * 2).text( - "{:8.2f}% overhead ({:.2f} / {:.2f}) <-- not counting rendering time", - (cum / g_avg_tic_time) * 100.0, - cum * TICRATE, - g_avg_tic_time * TICRATE - ); - - row = row.y(kRowHeight * 4); - */ - { const INT32 tally_flags = color_flag(cum * 1'000'000.0); - draw_row(0.f, row_y, tally_flags, fmt::format("{:8.2f} us - TOTAL", cum * 1'000'000.0)); - draw_row(0.f, row_y + kRowHeight, tally_flags, fmt::format("{:8.2f} ms", cum * 1000.0)); - draw_row(0.f, row_y + kRowHeight * 2, tally_flags, fmt::format( - "{:8.2f}% overhead ({:.2f} / {:.2f}) <-- not counting rendering time", + draw_row(0.f, row_y, tally_flags, va("%8.2f us - TOTAL", cum * 1'000'000.0)); + draw_row(0.f, row_y + kRowHeight, tally_flags, va("%8.2f ms", cum * 1000.0)); + + // dont need to show this if we didnt capture over time + // this would just show nan or inf anyways + if (std::fpclassify(g_avg_tic_time) != FP_ZERO) + { + draw_row(0.f, row_y + kRowHeight * 2, tally_flags, va( + "%8.2f%% overhead (%.2f / %.2f) <-- not counting rendering time", (cum / g_avg_tic_time) * 100.0, (cum * (double)TICRATE), (g_avg_tic_time * (double)TICRATE) - )); + )); + } } row_y += kRowHeight * 4; // row = row.y(kRowHeight * 4) - } std::sort( @@ -258,22 +239,11 @@ void LUA_RenderTimers(void) double t = timer.avg.time * 1'000'000.0; - /* - row.flags(color_flag(t)).text( - "{:>8.2f} us {:>8.2f} calls - {}", + draw_row(0.f, row_y, color_flag(t), va( + "%8.2f us %8.2f calls - %s", t, timer.avg.calls, - key - ); - - row = row.y(kRowHeight); - */ - - draw_row(0.f, row_y, color_flag(t), fmt::format( - "{:>8.2f} us {:>8.2f} calls - {}", - t, - timer.avg.calls, - key + key.c_str() )); row_y += kRowHeight; // row = row.y(kRowHeight) From e0e8be8d46ecfa0c3211f412f2c6ca11cacfc69e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jul 2026 15:47:35 +0200 Subject: [PATCH 534/589] perfstats thinkframe maxpage fix from blan + also yoink the ps types to get rid of magic numbers just prevents the cvar being set to a page that does not exist --- src/lua_hooklib.c | 2 +- src/m_perfstats.c | 97 ++++++++++++++++++++--------------------------- src/m_perfstats.h | 10 +++++ 3 files changed, 52 insertions(+), 57 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index b380945ab..52bf99708 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -760,7 +760,7 @@ static void hook_think_frame(int type) const hook_t * map = &hookIds[type]; int k; - const boolean perfstats = (cv_perfstats.value >= 3); + const boolean perfstats = (cv_perfstats.value >= PS_THINKFRAME); if (prepare_hook(&hook, 0, type)) { diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 49a855686..5f1be305f 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -168,14 +168,14 @@ perfstatrow_t gamelogic_rows[] = { }; perfstatrow_t thinkercount_rows[] = { - {"thnkers", "Thinkers: ", &ps_thinkercount, PS_LEVEL}, - {" mobjs ", " Mobjs: ", &ps_mobjcount, PS_LEVEL}, + {"thnkers" , "Thinkers: ", &ps_thinkercount, PS_LEVEL}, + {" mobjs " , " Mobjs: ", &ps_mobjcount, PS_LEVEL}, {" regular", " Regular: ", &ps_regularcount, PS_LEVEL}, {" scenery", " Scenery: ", &ps_scenerycount, PS_LEVEL}, {" nothink", " Nothink: ", &ps_nothinkcount, PS_HIDE_ZERO|PS_LEVEL}, - {" precip ", " Precipitation: ", &ps_precipcount, PS_LEVEL}, - {" other ", " Other: ", &ps_otherthcount, PS_LEVEL}, - {" remove ", " Pending removal:", &ps_removecount, PS_LEVEL}, + {" precip " , " Precipitation: ", &ps_precipcount, PS_LEVEL}, + {" other " , " Other: ", &ps_otherthcount, PS_LEVEL}, + {" remove " , " Pending removal:", &ps_removecount, PS_LEVEL}, {} }; @@ -605,7 +605,9 @@ static void PS_CountThinkers(void) else if (thinker->function == (actionf_p1)P_MobjThinker) { mobj_t *mobj = (mobj_t*)thinker; + ps_mobjcount.value.i++; + if (mobj->flags & MF_NOTHINK) ps_nothinkcount.value.i++; else if (mobj->flags & MF_SCENERY) @@ -624,49 +626,17 @@ static void PS_CountThinkers(void) ps_precipcount.value.i++; } - - /*for (i = 0; i < NUM_THINKERLISTS; i++) - { - for (thinker = thlist[i].next; thinker != &thlist[i]; thinker = thinker->next) - { - ps_thinkercount.value.i++; - if (thinker->function == (actionf_p1)P_RemoveThinkerDelayed) - ps_removecount.value.i++; - else if (i == THINK_POLYOBJ) - ps_polythcount.value.i++; - else if (i == THINK_MAIN) - ps_mainthcount.value.i++; - else if (i == THINK_MOBJ) - { - if (thinker->function == (actionf_p1)P_MobjThinker) - { - mobj_t *mobj = (mobj_t*)thinker; - ps_mobjcount.value.i++; - if (mobj->flags & MF_NOTHINK) - ps_nothinkcount.value.i++; - else if (mobj->flags & MF_SCENERY) - ps_scenerycount.value.i++; - else - ps_regularcount.value.i++; - } - } - else if (i == THINK_DYNSLOPE) - ps_dynslopethcount.value.i++; - else if (i == THINK_PRECIP) - ps_precipcount.value.i++; - } - }*/ } // Update all metrics that are calculated on every tick. void PS_UpdateTickStats(void) { - if (cv_perfstats.value == 1 && cv_ps_samplesize.value > 1) + if (cv_perfstats.value == PS_RENDER && cv_ps_samplesize.value > 1) { PS_UpdateRowHistories(gamelogicbrief_row, false); } - if (cv_perfstats.value == 2) + if (cv_perfstats.value == PS_LOGIC) { if (PS_IsLevelActive()) { @@ -691,25 +661,25 @@ void PS_UpdateTickStats(void) if (cv_ps_samplesize.value > 1) { - if (cv_perfstats.value >= 3 && PS_IsLevelActive()) + if (cv_perfstats.value >= PS_THINKFRAME && PS_IsLevelActive()) { int i; switch (cv_perfstats.value) { - case 3: + case PS_THINKFRAME: for (i = 0; i < thinkframe_hooks_length; i++) { PS_UpdateMetricHistory(&thinkframe_hooks[i].time_taken, true, false); } break; - case 4: + case PS_PRETHINKFRAME: for (i = 0; i < prethinkframe_hooks_length; i++) { PS_UpdateMetricHistory(&prethinkframe_hooks[i].time_taken, true, false); } break; - case 5: + case PS_POSTTHINKFRAME: for (i = 0; i < postthinkframe_hooks_length; i++) { PS_UpdateMetricHistory(&postthinkframe_hooks[i].time_taken, true, false); @@ -719,6 +689,7 @@ void PS_UpdateTickStats(void) break; } } + if (cv_perfstats.value) { ps_tick_index++; @@ -749,7 +720,7 @@ static void PS_DrawDescriptorHeader(void) int samples_left = max(ps_frame_samples_left, ps_tick_samples_left); int x, y; - if (cv_perfstats.value >= 3) + if (cv_perfstats.value >= PS_THINKFRAME) { x = 2; y = 0; @@ -865,20 +836,19 @@ static void draw_think_frame_stats(int hook_length, ps_hookinfo_t *hook) last_mod_name[0] = '\0'; INT32 total = 0; - //Decide page length based and drawn text on choosen thinker type + // Decide page length based and drawn text on choosen thinker type switch (cv_perfstats.value) { - case 3: + case PS_THINKFRAME: { maxpage = thinkframe_hooks_length/PAGE_ENTRIES + 1; page = max(1, min(cv_ps_thinkframe_page.value, maxpage)); pagestart = min((page - 1)*PAGE_ENTRIES, thinkframe_hooks_length); pageend = min(pagestart + PAGE_ENTRIES, thinkframe_hooks_length); - V_DrawSmallString(MAX_X-50, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "ThinkFrame"); } break; - case 4: + case PS_PRETHINKFRAME: { maxpage = prethinkframe_hooks_length/PAGE_ENTRIES + 1; page = max(1, min(cv_ps_thinkframe_page.value, maxpage)); @@ -887,7 +857,7 @@ static void draw_think_frame_stats(int hook_length, ps_hookinfo_t *hook) V_DrawSmallString(MAX_X-60, MAX_Y+2*HEIGHT, V_MONOSPACE | V_GREENMAP, "PreThinkFrame"); } break; - case 5: + case PS_POSTTHINKFRAME: { maxpage = postthinkframe_hooks_length/PAGE_ENTRIES + 1; page = max(1, min(cv_ps_thinkframe_page.value, maxpage)); @@ -975,7 +945,22 @@ static void draw_think_frame_stats(int hook_length, ps_hookinfo_t *hook) void PS_ThinkFrame_Page_OnChange(void) { - int maxpage = thinkframe_hooks_length/PAGE_ENTRIES + 1; + int maxpage = 0; + + switch (cv_perfstats.value) + { + case PS_THINKFRAME: + maxpage = thinkframe_hooks_length/PAGE_ENTRIES + 1; + break; + case PS_PRETHINKFRAME: + maxpage = prethinkframe_hooks_length/PAGE_ENTRIES + 1; + break; + case PS_POSTTHINKFRAME: + maxpage = postthinkframe_hooks_length/PAGE_ENTRIES + 1; + break; + default: + break; + } if (cv_ps_thinkframe_page.value > maxpage) CV_StealthSetValue(&cv_ps_thinkframe_page, maxpage); @@ -1008,18 +993,18 @@ static void PS_DrawPostThinkFrameStats(void) void M_DrawPerfStats(void) { - if (cv_perfstats.value == 1) // rendering + if (cv_perfstats.value == PS_RENDER) // rendering { PS_UpdateFrameStats(); PS_DrawRenderStats(); } - else if (cv_perfstats.value == 2) // logic + else if (cv_perfstats.value == PS_LOGIC) // logic { // PS_UpdateTickStats is called in TryRunTics, since otherwise it would miss // tics when frame skips happen PS_DrawGameLogicStats(); } - else if (cv_perfstats.value >= 3) // lua thinkframe + else if (cv_perfstats.value >= PS_THINKFRAME) // lua thinkframe { if (!PS_IsLevelActive()) return; @@ -1036,13 +1021,13 @@ void M_DrawPerfStats(void) switch (cv_perfstats.value) { - case 3: + case PS_THINKFRAME: PS_DrawThinkFrameStats(); break; - case 4: + case PS_PRETHINKFRAME: PS_DrawPreThinkFrameStats(); break; - case 5: + case PS_POSTTHINKFRAME: PS_DrawPostThinkFrameStats(); break; default: diff --git a/src/m_perfstats.h b/src/m_perfstats.h index 083656d61..e6f6739f3 100644 --- a/src/m_perfstats.h +++ b/src/m_perfstats.h @@ -26,6 +26,16 @@ typedef struct void *history; } ps_metric_t; +typedef enum +{ + PS_OFF = 0, + PS_RENDER, + PS_LOGIC, + PS_THINKFRAME, + PS_PRETHINKFRAME, + PS_POSTTHINKFRAME +} ps_types_t; + typedef struct { ps_metric_t time_taken; From c401926c0b07264d4fe0ddd4e69b0639fdc77c29 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jul 2026 15:43:50 +0200 Subject: [PATCH 535/589] fix lua hook profiler drawing out of screen bounds in some cases this omits alot of hooks in the profiler, tho not sure if anyone should even care about those back in the list maybe just have it have multiple pages like perfstats, or better just integrate it into perfstats...... --- src/lua_profile.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/lua_profile.cpp b/src/lua_profile.cpp index 3c7b1c81f..bf68035b8 100644 --- a/src/lua_profile.cpp +++ b/src/lua_profile.cpp @@ -144,6 +144,7 @@ void LUA_ResetTicTimers(void) void LUA_RenderTimers(void) { constexpr int kRowHeight = 4; + float row_y = kRowHeight; // pretty much what the whole srb2::Draw does lol auto draw_row = [](float x, float y, INT32 flags, const std::string& str) @@ -156,13 +157,11 @@ void LUA_RenderTimers(void) ); }; - float row_y = kRowHeight - 60; - draw_row(0.f, row_y - kRowHeight, 0, va("-- AVERAGES PER TIC (over %d tics) --", cv_lua_profile.value)); + draw_row(0.f, 0.f, 0, va("-- AVERAGES PER TIC (over %d tics) --", cv_lua_profile.value)); if (g_invalid) { - row_y += kRowHeight; - draw_row(0.f, row_y - kRowHeight, V_GRAYMAP, " "); + draw_row(0.f, row_y, V_GRAYMAP, " "); return; } @@ -219,7 +218,7 @@ void LUA_RenderTimers(void) } } - row_y += kRowHeight * 4; // row = row.y(kRowHeight * 4) + row_y += kRowHeight * 4; } std::sort( @@ -246,7 +245,7 @@ void LUA_RenderTimers(void) key.c_str() )); - row_y += kRowHeight; // row = row.y(kRowHeight) + row_y += kRowHeight; // FIXME this is all ugly and sucks if (row_y >= BASEVIDHEIGHT) From 5c7be859779f05f36d68a8409294bb59a44b943f Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jul 2026 15:50:26 +0200 Subject: [PATCH 536/589] fix cmake .ch.......... --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 864a5870c..85ced4e54 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -291,7 +291,7 @@ if(${SRB2_CONFIG_HAVE_BLUA}) lua_hook.h lua_hud.h lua_hudlib_drawlist.h - lua_profile.ch + lua_profile.h lua_libs.h lua_script.h lua_udatalib.h From 0c440d240c4464fec1e59006a55f7b6e92ba8e11 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jul 2026 15:54:37 +0200 Subject: [PATCH 537/589] can pass char to this now no need to reconvert this stuff from const char to std::string and back to const char really lol --- src/lua_profile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_profile.cpp b/src/lua_profile.cpp index bf68035b8..d910c5d65 100644 --- a/src/lua_profile.cpp +++ b/src/lua_profile.cpp @@ -147,13 +147,13 @@ void LUA_RenderTimers(void) float row_y = kRowHeight; // pretty much what the whole srb2::Draw does lol - auto draw_row = [](float x, float y, INT32 flags, const std::string& str) + auto draw_row = [](float x, float y, INT32 flags, const char *str) { V_DrawSmallStringAtFixed( FloatToFixed(x), FloatToFixed(y), V_MONOSPACE|V_ALLOWLOWERCASE|flags, - str.c_str() + str ); }; From 4631844c9ff13b8389a6b121b9c72fe4bc6d88b7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jul 2026 16:07:14 +0200 Subject: [PATCH 538/589] revert removing the slopelanding dupe dont think this would cause any issues at all, but i dont feel like maybe causing some dumbass edge cases anywhere really can test this further after v10 release since its already taking ages --- 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 8b4f5c5b1..cc62c6cab 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2573,7 +2573,7 @@ static void P_PlayerZMovement(mobj_t *mo) P_SetPlayerMobjState(mo, S_KART_STND1); } -#if 0 // praying that removing this dupe wont cause any issues... +#if 1 // praying that removing this dupe wont cause any issues... if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)) { // Handle landing on slope during Z movement From 7878e01e3f10e3114b5f40223d478fee73d2ba1e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 24 Jul 2026 16:15:48 +0200 Subject: [PATCH 539/589] update copyrights for "core" folder --- src/core/memory.cpp | 6 +++--- src/core/memory.h | 6 +++--- src/core/static_vec.hpp | 6 +++--- src/core/thread_pool.cpp | 6 +++--- src/core/thread_pool.h | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 81ba79d5d..e0289a579 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -1,7 +1,7 @@ -// BLANKART +// DR. ROBOTNIK'S RING RACERS //----------------------------------------------------------------------------- -// Copyright (C) 2024 by Ronald "Eidolon" Kinard -// Copyright (C) 2024 by Kart Krew +// Copyright (C) 2025 by Ronald "Eidolon" Kinard +// Copyright (C) 2025 by Kart Krew // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/core/memory.h b/src/core/memory.h index 4aec917d7..14b51a039 100644 --- a/src/core/memory.h +++ b/src/core/memory.h @@ -1,7 +1,7 @@ -// SONIC ROBO BLAST 2 KART +// DR. ROBOTNIK'S RING RACERS //----------------------------------------------------------------------------- -// Copyright (C) 2024 by Ronald "Eidolon" Kinard -// Copyright (C) 2024 by Kart Krew +// Copyright (C) 2025 by Ronald "Eidolon" Kinard +// Copyright (C) 2025 by Kart Krew // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/core/static_vec.hpp b/src/core/static_vec.hpp index c1f486a2b..f31f17939 100644 --- a/src/core/static_vec.hpp +++ b/src/core/static_vec.hpp @@ -1,7 +1,7 @@ -// SONIC ROBO BLAST 2 KART +// DR. ROBOTNIK'S RING RACERS //----------------------------------------------------------------------------- -// Copyright (C) 2024 by Ronald "Eidolon" Kinard -// Copyright (C) 2024 by Kart Krew +// Copyright (C) 2025 by Ronald "Eidolon" Kinard +// Copyright (C) 2025 by Kart Krew // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/core/thread_pool.cpp b/src/core/thread_pool.cpp index 11aa6f1bb..c716b6470 100644 --- a/src/core/thread_pool.cpp +++ b/src/core/thread_pool.cpp @@ -1,7 +1,7 @@ -// BLANKART +// DR. ROBOTNIK'S RING RACERS //----------------------------------------------------------------------------- -// Copyright (C) 2024 by Ronald "Eidolon" Kinard -// Copyright (C) 2024 by Kart Krew +// Copyright (C) 2025 by Ronald "Eidolon" Kinard +// Copyright (C) 2025 by Kart Krew // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/core/thread_pool.h b/src/core/thread_pool.h index 71eebdaf1..0c1fc88ad 100644 --- a/src/core/thread_pool.h +++ b/src/core/thread_pool.h @@ -1,7 +1,7 @@ -// SONIC ROBO BLAST 2 KART +// DR. ROBOTNIK'S RING RACERS //----------------------------------------------------------------------------- -// Copyright (C) 2024 by Ronald "Eidolon" Kinard -// Copyright (C) 2024 by Kart Krew +// Copyright (C) 2025 by Ronald "Eidolon" Kinard +// Copyright (C) 2025 by Kart Krew // // This program is free software distributed under the // terms of the GNU General Public License, version 2. From 94f46c3ce68c5d8e8c6eb331455aaf1195d766bd Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 25 Jul 2026 09:22:51 +0200 Subject: [PATCH 540/589] also prevent "local" pushable mobjs from executing linedef actions missed when i did the other, pushables have a seperate executor special --- src/p_mobj.c | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index cc62c6cab..03b821d3e 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9150,15 +9150,17 @@ void P_MobjThinker(mobj_t *mobj) tmfloorthing = tmhitthing = NULL; - const sector_t *sec1 = mobj->subsector ? mobj->subsector->sector : NULL; - - // 970 allows ANY mobj to trigger a linedef exec - if (!mobj->islocal && sec1 && GETSECSPECIAL(sec1->special, 2) == 8) // BEWARE: islocal does not exist in vanilla + // do NOT trigger linedef executors for "local" mobjs + if (!mobj->islocal) { - sector_t *sec2; - sec2 = P_ThingOnSpecial3DFloor(mobj); - if (sec2 && GETSECSPECIAL(sec2->special, 2) == 1) - P_LinedefExecute(sec2->tag, mobj, sec2); + // 970 allows ANY mobj to trigger a linedef exec + if (mobj->subsector && GETSECSPECIAL(mobj->subsector->sector->special, 2) == 8) + { + sector_t *sec2; + sec2 = P_ThingOnSpecial3DFloor(mobj); + if (sec2 && GETSECSPECIAL(sec2->special, 2) == 1) + P_LinedefExecute(sec2->tag, mobj, sec2); + } } if (mobj->scale != mobj->destscale) @@ -9358,25 +9360,29 @@ void P_PushableThinker(mobj_t *mobj) I_Assert(!P_MobjWasRemoved(mobj)); - if (P_MobjWasRemovedCompat(mobj)) - return; - - sec = mobj->subsector->sector; - - if (mobj->z == sec->floorheight && GETSECSPECIAL(sec->special, 2) == 1) - P_LinedefExecute(sec->tag, mobj, sec); + // do NOT trigger linedef executors for "local" mobjs + if (!mobj->islocal) { - sector_t *sec2; + sec = mobj->subsector->sector; - sec2 = P_ThingOnSpecial3DFloor(mobj); - if (sec2 && GETSECSPECIAL(sec2->special, 2) == 1) - P_LinedefExecute(sec2->tag, mobj, sec2); + if (mobj->z == sec->floorheight && GETSECSPECIAL(sec->special, 2) == 1) + P_LinedefExecute(sec->tag, mobj, sec); + { + sector_t *sec2; + + sec2 = P_ThingOnSpecial3DFloor(mobj); + if (sec2 && GETSECSPECIAL(sec2->special, 2) == 1) + P_LinedefExecute(sec2->tag, mobj, sec2); + } } // it has to be pushable RIGHT NOW for this part to happen if (mobj->flags & MF_PUSHABLE && !(mobj->momx || mobj->momy)) P_TryMove(mobj, mobj->x, mobj->y, true); + if (P_MobjWasRemovedCompat(mobj)) + return; + if (mobj->fuse == 1) // it would explode in the MobjThinker code { mobj_t *spawnmo; @@ -9402,7 +9408,8 @@ void P_PushableThinker(mobj_t *mobj) } spawnmo = P_SpawnMobj(x, y, z, mobj->type); - if (spawnmo) + + if (!P_MobjWasRemovedCompat(spawnmo)) { spawnmo->spawnpoint = mobj->spawnpoint; P_UnsetThingPosition(spawnmo); From d5252bd3b38c2dcaa261ee73eb3527ffada43ca5 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 28 Jul 2026 20:49:23 +0200 Subject: [PATCH 541/589] fix an oopsie in p_mobj.c prob did that while sleep deprived, P_WeaponOrPanel includes a few more things than intended to be there doubt we even use any of those, but i dont want to cause any potential issues agaion --- src/p_mobj.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 03b821d3e..dbfe3d596 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9264,7 +9264,8 @@ void P_MobjThinker(mobj_t *mobj) mobj->eflags &= ~MFE_JUSTHITFLOOR; } - if (mobj->type == MT_FALLINGROCK + // Sliding physics for slidey mobjs! + if ( mobj->type == MT_FALLINGROCK || mobj->type == MT_LITTLETUMBLEWEED || mobj->type == MT_BIGTUMBLEWEED || mobj->type == MT_FLINGRING @@ -9309,21 +9310,24 @@ void P_MobjThinker(mobj_t *mobj) if (P_MobjWasRemoved(mobj)) return; - if (P_WeaponOrPanel(mobj->type)) + if ((mobj->health == 0) && // Fading tile + (mobj->type == MT_BOUNCEPICKUP + || mobj->type == MT_RAILPICKUP + || mobj->type == MT_AUTOPICKUP + || mobj->type == MT_EXPLODEPICKUP + || mobj->type == MT_SCATTERPICKUP + || mobj->type == MT_GRENADEPICKUP)) { - if (mobj->health == 0) // Fading tile - { - INT32 value = mobj->info->damage/10; - value = mobj->fuse/value; - value = 10-value; - value--; + INT32 value = mobj->info->damage/10; + value = mobj->fuse/value; + value = 10-value; + value--; - if (value <= 0) - value = 1; + if (value <= 0) + value = 1; - mobj->frame &= ~FF_TRANSMASK; - mobj->frame |= value << FF_TRANSSHIFT; - } + mobj->frame &= ~FF_TRANSMASK; + mobj->frame |= value << FF_TRANSSHIFT; } } From 617e8fdd551bb7ce2d96966b1dd57edf4b1b5ad1 Mon Sep 17 00:00:00 2001 From: MIDIMan Date: Wed, 29 Jul 2026 17:08:24 -0400 Subject: [PATCH 542/589] Manually set NetVars's hook_type Also adds a 2.3 TODO comment for MF_AMBIENT --- src/lua_hooklib.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index fe997123b..a488c7ed6 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1062,6 +1062,9 @@ void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save) lua_pushcclosure(gL, archFunc, 2); // stack: tables, savebuffer_t, archFunc + // Manually set the hook's variables here since we don't call prepare_hook + hook.hook_type = HOOK(NetVars); + hook.mobj_type = NONMOHOOK; // Force mobj_type to be NONMOHOOK so the mobj_type check get skipped init_hook_call(&hook, 0, res_none); call_mapped(&hook, map); From f03692b840fca24768a325b9fbc19399a6543efe Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 5 Aug 2026 22:46:49 +0200 Subject: [PATCH 543/589] delet duped MobjThinker check --- src/lua_hooklib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index a488c7ed6..82c1a00d6 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -584,7 +584,6 @@ FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype || hook->hook_type == MOBJ_HOOK(MobjCollide ) || hook->hook_type == MOBJ_HOOK(MobjMoveCollide) || hook->hook_type == MOBJ_HOOK(MobjFuse ) - || hook->hook_type == MOBJ_HOOK(MobjThinker ) || hook->hook_type == MOBJ_HOOK(BossThinker ) )) { From c39073dd9e9e6195aca9b930a61e6002a07d5929 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Aug 2026 15:09:17 +0200 Subject: [PATCH 544/589] fix arm compile idk why i added this, if this is ever needed for whatever pls yell at me --- src/Makefile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Makefile b/src/Makefile index 4ee7cf1a9..5b1f9f0fa 100644 --- a/src/Makefile +++ b/src/Makefile @@ -246,10 +246,6 @@ ifdef STATIC libs+=-static endif -ifneq (,$(filter $(CC) $(CXX),gcc g++)) - opts+=-mno-ms-bitfields -endif - # build with profiling information ifdef PROFILEMODE opts+=-pg From 2f9a400cf399fa4c51a48a17764a052328826f5a Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Aug 2026 16:48:23 +0200 Subject: [PATCH 545/589] cmake flag for mumble stimky --- src/CMakeLists.txt | 3 +++ src/sdl/CMakeLists.txt | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 85ced4e54..28f48cdad 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -247,6 +247,9 @@ set(SRB2_CONFIG_ASAN OFF CACHE BOOL set(SRB2_CONFIG_UBSAN OFF CACHE BOOL "Compile with UndefinedBehaviorSanitizer (libubsan).") +set(SRB2_CONFIG_MUMBLE ON CACHE BOOL + "Enable Mumble support") + set(SRB2_CONFIG_SATURNPAK ON CACHE BOOL "Enable Saturn specific special packet. Required for using the newer resynch system") set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index c7d612c80..13b41323e 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -243,6 +243,10 @@ if(${SDL2_FOUND}) target_link_options(SRB2SDL2 PRIVATE -fsanitize=undefined) endif() + if(NOT SRB2_CONFIG_MUMBLE) + target_compile_options(SRB2SDL2 PRIVATE -DNOMUMBLE) + endif() + ## strip debug symbols into separate file when using gcc # if(CMAKE_COMPILER_IS_GNUCC) # if(${CMAKE_BUILD_TYPE} MATCHES Debug) From 91604315566d08cdf97da161eecc109802ff6719 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Aug 2026 16:57:32 +0200 Subject: [PATCH 546/589] fix compile for android bionic c lib --- src/sdl/i_system.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index dd3508efd..48ba6a21e 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1405,7 +1405,11 @@ void I_SleepDuration(precise_t duration) duration -= slack; struct timespec ts = { .tv_sec = static_cast<__time_t>(duration / precision), +#ifdef __BIONIC__ + .tv_nsec = static_cast(duration * 1000000000 / precision % 1000000000), +#else .tv_nsec = static_cast<__syscall_slong_t>(duration * 1000000000 / precision % 1000000000), +#endif }; int status; do status = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &ts); From b2cdbaae60407e5ed865b19333ce1c1732806416 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Aug 2026 16:57:42 +0200 Subject: [PATCH 547/589] fix protocol register thingie --- src/d_protocol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_protocol.c b/src/d_protocol.c index 963d8e587..7cf84be93 100644 --- a/src/d_protocol.c +++ b/src/d_protocol.c @@ -211,12 +211,12 @@ void D_SetupProtocol(void) if (result) { - if (!fastcmp(buffer, "no")) + if (fastcmp(buffer, "no")) { fclose(fp); return; } - else if (fastcmp(buffer, exe_path)) + else if (!fastcmp(buffer, exe_path)) { // overwrite fclose(fp); From 88d86a6e600c185eca9d6aab56f145688ae0c692 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Aug 2026 17:04:55 +0200 Subject: [PATCH 548/589] fix NOMUMBLE compile idk how and why this breaks, but I_OutputMsg is in doomdef anyways for god knows why --- src/m_curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_curl.c b/src/m_curl.c index 77588a3fb..f7ff29955 100644 --- a/src/m_curl.c +++ b/src/m_curl.c @@ -11,7 +11,7 @@ #include "m_curl.h" #include "doomtype.h" -#include "i_system.h" // I_OutputMsg +#include "doomdef.h" // I_OutputMsg #include "m_argv.h" // M_CheckParm, M_GetNextParm static boolean curl_args_init = false; From 5d807d65e530458634f4a452366eefa06fe568a5 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Aug 2026 17:43:07 +0200 Subject: [PATCH 549/589] smol style fix less confusing --- src/d_netfil.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index 944d9560b..613b72df5 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -1616,8 +1616,7 @@ static void CURLGetFile(void) #endif } -HTTP_login * -CURLGetLogin (const char *url, HTTP_login ***return_prev_next) +HTTP_login *CURLGetLogin(const char *url, HTTP_login ***return_prev_next) { HTTP_login * login; HTTP_login ** prev_next; @@ -1627,7 +1626,7 @@ CURLGetLogin (const char *url, HTTP_login ***return_prev_next) ( login = (*prev_next)); prev_next = &login->next ){ - if (fastcmp(login->url, url) != 0) + if (fastcmp(login->url, url)) { if (return_prev_next) (*return_prev_next) = prev_next; From 73bc64f9dad3b5befa9596c5fb1b7b17745c33db Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Aug 2026 22:16:15 +0200 Subject: [PATCH 550/589] fix clamp assert in HWR_SplitWall idk man it really hates if lo > hi apparently lol --- src/hardware/hw_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 562be50bb..907f80cf0 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1101,8 +1101,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, // Found a break // The heights are clamped to ensure the polygon doesn't cross itself. - bot = std::clamp(bheight, realbot, top); - endbot = std::clamp(endbheight, endrealbot, endtop); + bot = std::min(std::max(bheight, realbot), top); + endbot = std::min(std::max(endbheight, endrealbot), endtop); Surf->PolyColor.s.alpha = alpha; From 421d735052d059c6fd096bd63fc88adcff27f603 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 6 Aug 2026 22:15:29 +0200 Subject: [PATCH 551/589] fix compiler complains when compiling with valgrind support --- src/Makefile.d/features.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk index 410077939..af67a5494 100644 --- a/src/Makefile.d/features.mk +++ b/src/Makefile.d/features.mk @@ -86,7 +86,7 @@ ifdef VALGRIND VALGRIND_PKGCONFIG?=valgrind VALGRIND_LDFLAGS= $(eval $(call Use_pkg_config,VALGRIND)) -ZDEBUG=1 +#ZDEBUG=1 we enable this by default opts+=-DHAVE_VALGRIND endif From 599eda96aa6a8b1d2f343e53351c40ecda5a9503 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 7 Aug 2026 19:32:41 +0200 Subject: [PATCH 552/589] fix M_ScrollString not null terminating its output this caused music test to have non terminated strings --- src/m_menu.c | 8 ++++++-- src/m_misc.c | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 9f621af6a..b75cfa430 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5766,7 +5766,8 @@ static void M_DrawMusicTest(void) x = 24; y = 64; - if (renderisnewtic) st_musictime++; + if (renderisnewtic) + st_musictime++; while (t <= b) { @@ -5774,12 +5775,13 @@ static void M_DrawMusicTest(void) V_DrawFill(20, y-4, 280-1, 16, 237); { + const musicdef_t *def = S_GetMusicCredit(t); - const size_t MAXLENGTH = 34; const char *songname = def->title[0] ? def->title : def->source; size_t namelength = strlen(songname); + static const size_t MAXLENGTH = 34; char buf[MAXLENGTH+1]; if (t == st_sel && namelength > MAXLENGTH) @@ -5788,11 +5790,13 @@ static void M_DrawMusicTest(void) strlcpy(buf, songname, MAXLENGTH); V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE|V_MONOSPACE, buf); + if (curplaying == def) { V_DrawFill(20+280-9, y-4, 8, 16, 230); } } + t++; y += 16; } diff --git a/src/m_misc.c b/src/m_misc.c index 493e66487..7fba30790 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1261,7 +1261,7 @@ void M_ScrollString(const char name[], size_t len, char result[], size_t maxlen, const size_t amount = len - maxlen + 1; // Note: anything above 17 will cause zero division - const size_t MAXSPEED = 6; + static const size_t MAXSPEED = 6; const tic_t t = timer / (35/min(amount, MAXSPEED)); const size_t state = (t / amount) % 4; @@ -1296,7 +1296,7 @@ void M_ScrollString(const char name[], size_t len, char result[], size_t maxlen, } // Technically not necessary, since it gets set again after function call, but just in case - result[maxlen] = 0; + result[maxlen-1] = '\0'; } void M_MinimapGenerate(void) From 0464a8b0c73dac31230b08e3871ecab73ddbcafa Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 7 Aug 2026 20:14:31 +0200 Subject: [PATCH 553/589] attempt to mitigate "palette" cvar allowing random lumps to be used as palette if theres a proper way to check for actual palettes pls tell me thx --- src/v_video.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index 109eac171..5c98d8e52 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -581,13 +581,19 @@ const char *GetPalette(void) if (user && user[0]) { - if (W_CheckNumForName(user) == LUMPERROR) + const lumpnum_t palnum = W_CheckNumForName(user); + + if (palnum == LUMPERROR) { CONS_Alert(CONS_WARNING, "cv_palette %s lump does not exist\n", user); } + else if (W_LumpLength(palnum) % (256 * 3) != 0) // not divisable by 768, so most def not a valid palette, idk if theres a better way to check this + { + CONS_Alert(CONS_WARNING, "cv_palette %s is not a valid palette lump\n", user); + } else { - return cv_palette.string; + return user; } } @@ -609,15 +615,16 @@ void V_ReloadPalette(void) void V_SetPalette(INT32 palettenum) { RGBA_t *pal = NULL; + if (!pLocalPalette) V_ReloadPalette(); -#ifdef HWRENDER - if (rendermode == render_soft || - (rendermode == render_opengl && HWR_ShouldUsePaletteRendering())) // opengl without paletterendering hates subpalettes -#endif + if (palettenum == 0) { - if (palettenum == 0) +#ifdef HWRENDER + if (rendermode == render_soft || + (rendermode == render_opengl && HWR_ShouldUsePaletteRendering())) // opengl without paletterendering hates subpalettes +#endif { palettenum = cv_palettenum.value; } From 3c6882203bfcbdb76046a20bd873e9ae1c5099c8 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 12 Aug 2019 15:18:36 +0100 Subject: [PATCH 554/589] Initialise player_names[] in D_RegisterClientCommands such that we don't need to have to manually update it if MAXPLAYERS ever changed --- src/d_netcmd.c | 5 +++++ src/g_game.c | 27 +++------------------------ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 1758f4718..dccbbd345 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -815,6 +815,11 @@ void D_RegisterClientCommands(void) Color_cons_t[MAXSKINCOLORS].value = 0; Color_cons_t[MAXSKINCOLORS].strvalue = NULL; + // Set default player names + // Monster Iestyn (12/08/19): not sure where else I could have actually put this, but oh well + for (i = 0; i < MAXPLAYERS; i++) + sprintf(player_names[i], "Player %d", i); + if (dedicated) return; diff --git a/src/g_game.c b/src/g_game.c index f720f98fd..994733992 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -453,34 +453,13 @@ consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, dr static CV_PossibleValue_t cechotoggle_t[] = {{0, "Off"}, {1, "On"}, {2, "Console"}, {0, NULL}}; consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, cechotoggle_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#if MAXPLAYERS > 16 -#error "please update player_name table using the new value for MAXPLAYERS" -#endif - #ifdef SEENAMES player_t *seenplayer = NULL; // player we're aiming at right now #endif -char player_names[MAXPLAYERS][MAXPLAYERNAME+1] = -{ - "Player 1", - "Player 2", - "Player 3", - "Player 4", - "Player 5", - "Player 6", - "Player 7", - "Player 8", - "Player 9", - "Player 10", - "Player 11", - "Player 12", - "Player 13", - "Player 14", - "Player 15", - "Player 16" -}; // SRB2kart - removed Players 17 through 32 - +// now automatically allocated in D_RegisterClientCommands +// so that it doesn't have to be updated depending on the value of MAXPLAYERS +char player_names[MAXPLAYERS][MAXPLAYERNAME+1]; INT32 player_name_changes[MAXPLAYERS] = {}; INT16 rw_maximums[NUM_WEAPONS] = From 0e8a32612fbc4bb9271caf1d097d93dff9342824 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Aug 2026 17:26:14 +0200 Subject: [PATCH 555/589] move player_name init to D_RegisterServerCommands runs before registering client commands and is for everything server + client needs --- src/d_netcmd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index dccbbd345..f08d0d2c8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -604,6 +604,12 @@ void D_RegisterServerCommands(void) Forceskin_cons_t[i].value = 0; Forceskin_cons_t[i].strvalue = NULL; } + + // Set default player names + // Monster Iestyn (12/08/19): not sure where else I could have actually put this, but oh well + for (i = 0; i < MAXPLAYERS; i++) + sprintf(player_names[i], "Player %d", 1 + i); + RegisterNetXCmd(XD_NAMEANDCOLOR, Got_NameAndColor); RegisterNetXCmd(XD_WEAPONPREF, Got_WeaponPref); RegisterNetXCmd(XD_MAP, Got_Mapcmd); @@ -815,11 +821,6 @@ void D_RegisterClientCommands(void) Color_cons_t[MAXSKINCOLORS].value = 0; Color_cons_t[MAXSKINCOLORS].strvalue = NULL; - // Set default player names - // Monster Iestyn (12/08/19): not sure where else I could have actually put this, but oh well - for (i = 0; i < MAXPLAYERS; i++) - sprintf(player_names[i], "Player %d", i); - if (dedicated) return; From 0a750cd3bcf0cf4e6dcf540636b3d4724748abaa Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Aug 2026 17:38:11 +0200 Subject: [PATCH 556/589] cleanup gl shadow checks just move em into the function to be less ugly --- src/hardware/hw_main.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 907f80cf0..baa4461e4 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3235,6 +3235,18 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t if (!spr->mobj) return; + // Ceiling scenery have no shadow. + if ((spr->mobj->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) == (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) + return; + + // Debris have no corona or shadow. + if (spr->mobj->flags2 & MF2_DEBRIS) + return; + + // Without this, your shadow shows on the floor, even after you die and fall through the ground. + if (spr->mobj->z < spr->mobj->floorz) + return; + R_GetShadowZ(spr->mobj, &floorslope); mobjfloor = HWR_OpaqueFloorAtPos( @@ -3495,10 +3507,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) hwrpatch = static_cast(gpatch->hardware); // Draw shadow BEFORE sprite - if (UNLIKELY(cv_shadow.value // Shadows enabled - && (sprmo->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) != (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY) // Ceiling scenery have no shadow. - && !(sprmo->flags2 & MF2_DEBRIS) // Debris have no corona or shadow. - && (sprmo->z >= sprmo->floorz))) // Without this, your shadow shows on the floor, even after you die and fall through the ground. + if (UNLIKELY(cv_shadow.value)) { //////////////////// // SHADOW SPRITE! // @@ -3824,10 +3833,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) } // Draw shadow BEFORE sprite - if (UNLIKELY(cv_shadow.value // Shadows enabled - && (sprmo->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) != (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY) // Ceiling scenery have no shadow. - && !(sprmo->flags2 & MF2_DEBRIS) // Debris have no corona or shadow. - && (sprmo->z >= sprmo->floorz))) // Without this, your shadow shows on the floor, even after you die and fall through the ground. + if (UNLIKELY(cv_shadow.value)) { //////////////////// // SHADOW SPRITE! // From 2b9224cc3f6d42491d31095af602cdf7716225b5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Aug 2026 18:09:35 +0200 Subject: [PATCH 557/589] forgor to update player names comment --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 994733992..50d43cf7a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -457,7 +457,7 @@ consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, cechotoggle_t, NULL, 0, player_t *seenplayer = NULL; // player we're aiming at right now #endif -// now automatically allocated in D_RegisterClientCommands +// now automatically allocated in D_RegisterServerCommands // so that it doesn't have to be updated depending on the value of MAXPLAYERS char player_names[MAXPLAYERS][MAXPLAYERNAME+1]; INT32 player_name_changes[MAXPLAYERS] = {}; From d7db0d68dca2b22ab9f6a6cdf2234fd3e4508f13 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Aug 2026 18:53:39 +0200 Subject: [PATCH 558/589] ensure serverinfo mapname is null terminated forgor back then --- src/d_clisrv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 95879cc17..ed52e8a98 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1685,9 +1685,10 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) (dedicated ? SV_DEDICATED : 0) ); - CopyCaretColors(netbuffer->u.serverinfo.servername, cv_servername.string, - MAXSERVERNAME); + CopyCaretColors(netbuffer->u.serverinfo.servername, cv_servername.string, MAXSERVERNAME); + strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), sizeof(netbuffer->u.serverinfo.mapname)-1); + netbuffer->u.serverinfo.mapname[sizeof(netbuffer->u.serverinfo.mapname)-1] = '\0'; memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, sizeof(netbuffer->u.serverinfo.mapmd5)); From a951622f6a38fd48cba38a713aa6fd874cd6ccd0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Aug 2026 19:00:03 +0200 Subject: [PATCH 559/589] ensure serverinfo "application" is null terminated not strictly needed but better be safe than sorry --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ed52e8a98..14dbae364 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1660,8 +1660,8 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) netbuffer->u.serverinfo.packetversion = PACKETVERSION; netbuffer->u.serverinfo.version = VERSION; netbuffer->u.serverinfo.subversion = SUBVERSION; - strncpy(netbuffer->u.serverinfo.application, SRB2APPLICATION, - sizeof netbuffer->u.serverinfo.application); + strncpy(netbuffer->u.serverinfo.application, SRB2APPLICATION, sizeof(netbuffer->u.serverinfo.application)-1); + netbuffer->u.serverinfo.application[sizeof(netbuffer->u.serverinfo.application)-1] = '\0'; // return back the time value so client can compute their ping netbuffer->u.serverinfo.time = (tic_t)LONG(servertime); netbuffer->u.serverinfo.leveltime = (tic_t)LONG(leveltime); From bf70beb88aec9dc27438382758a063354f19cc82 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Aug 2026 19:03:24 +0200 Subject: [PATCH 560/589] cleanup SV_SendServerInfo a little mostly just make it more readable by using ptr --- src/d_clisrv.c | 78 ++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 14dbae364..8001ac2fe 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1629,8 +1629,8 @@ static boolean CL_SendJoin(void) netbuffer->u.clientcfg.packetversion = PACKETVERSION; netbuffer->u.clientcfg.version = VERSION; netbuffer->u.clientcfg.subversion = SUBVERSION; - strncpy(netbuffer->u.clientcfg.application, SRB2APPLICATION, - sizeof(netbuffer->u.clientcfg.application)); + strncpy(netbuffer->u.clientcfg.application, SRB2APPLICATION, sizeof(netbuffer->u.clientcfg.application)-1); + netbuffer->u.clientcfg.application[sizeof(netbuffer->u.clientcfg.application)-1] = '\0'; #ifdef SATURNJOIN netbuffer->u.clientcfg.issaturn = ISSATURN; #endif @@ -1655,89 +1655,91 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); + serverinfo_pak *serverinfo = &netbuffer->u.serverinfo; + netbuffer->packettype = PT_SERVERINFO; - netbuffer->u.serverinfo._255 = 255; - netbuffer->u.serverinfo.packetversion = PACKETVERSION; - netbuffer->u.serverinfo.version = VERSION; - netbuffer->u.serverinfo.subversion = SUBVERSION; - strncpy(netbuffer->u.serverinfo.application, SRB2APPLICATION, sizeof(netbuffer->u.serverinfo.application)-1); - netbuffer->u.serverinfo.application[sizeof(netbuffer->u.serverinfo.application)-1] = '\0'; + serverinfo->_255 = 255; + serverinfo->packetversion = PACKETVERSION; + serverinfo->version = VERSION; + serverinfo->subversion = SUBVERSION; + strncpy(serverinfo->application, SRB2APPLICATION, sizeof(serverinfo->application)-1); + serverinfo->application[sizeof(serverinfo->application)-1] = '\0'; // return back the time value so client can compute their ping - netbuffer->u.serverinfo.time = (tic_t)LONG(servertime); - netbuffer->u.serverinfo.leveltime = (tic_t)LONG(leveltime); + serverinfo->time = (tic_t)LONG(servertime); + serverinfo->leveltime = (tic_t)LONG(leveltime); // force 1 player if (UseFakeSeed()) - netbuffer->u.serverinfo.numberofplayer = (UINT8)1; + serverinfo->numberofplayer = (UINT8)1; else - netbuffer->u.serverinfo.numberofplayer = (UINT8)D_NumPlayers(); + serverinfo->numberofplayer = (UINT8)D_NumPlayers(); - netbuffer->u.serverinfo.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); + serverinfo->maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); // SRB2Kart: Vanilla's gametype constants for MS support - netbuffer->u.serverinfo.gametype = (UINT8)((gt == GT_MATCH) ? VANILLA_GT_MATCH : VANILLA_GT_RACE); + serverinfo->gametype = (UINT8)((gt == GT_MATCH) ? VANILLA_GT_MATCH : VANILLA_GT_RACE); - netbuffer->u.serverinfo.modifiedgame = (UINT8)modifiedgame; - netbuffer->u.serverinfo.cheatsenabled = CV_CheatsEnabled(); + serverinfo->modifiedgame = (UINT8)modifiedgame; + serverinfo->cheatsenabled = CV_CheatsEnabled(); - netbuffer->u.serverinfo.kartvars = (UINT8) ( + serverinfo->kartvars = (UINT8) ( (cv_kartspeed.value & SV_SPEEDMASK) | (dedicated ? SV_DEDICATED : 0) ); - CopyCaretColors(netbuffer->u.serverinfo.servername, cv_servername.string, MAXSERVERNAME); + CopyCaretColors(serverinfo->servername, cv_servername.string, MAXSERVERNAME); - strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), sizeof(netbuffer->u.serverinfo.mapname)-1); - netbuffer->u.serverinfo.mapname[sizeof(netbuffer->u.serverinfo.mapname)-1] = '\0'; + strncpy(serverinfo->mapname, G_BuildMapName(gamemap), sizeof(serverinfo->mapname)-1); + serverinfo->mapname[sizeof(serverinfo->mapname)-1] = '\0'; - memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, sizeof(netbuffer->u.serverinfo.mapmd5)); + memcpy(serverinfo->mapmd5, mapmd5, sizeof(serverinfo->mapmd5)); - netbuffer->u.serverinfo.iszone = 0; + serverinfo->iszone = 0; - memset(netbuffer->u.serverinfo.maptitle, 0, sizeof(netbuffer->u.serverinfo.maptitle)); - memset(netbuffer->u.serverinfo.httpsource, 0, MAX_MIRROR_LENGTH); + memset(serverinfo->maptitle, 0, sizeof(serverinfo->maptitle)); + memset(serverinfo->httpsource, 0, MAX_MIRROR_LENGTH); if (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) && mapheaderinfo[gamemap-1]->lvlttl[0]) { - strncpy(netbuffer->u.serverinfo.maptitle, mapheaderinfo[gamemap-1]->lvlttl, sizeof(netbuffer->u.serverinfo.maptitle)-1); + strncpy(serverinfo->maptitle, mapheaderinfo[gamemap-1]->lvlttl, sizeof(serverinfo->maptitle)-1); if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) { if (mapheaderinfo[gamemap-1]->zonttl[0]) { - strncat(netbuffer->u.serverinfo.maptitle, " ", sizeof(netbuffer->u.serverinfo.maptitle)-1); - strncat(netbuffer->u.serverinfo.maptitle, mapheaderinfo[gamemap-1]->zonttl, - sizeof(netbuffer->u.serverinfo.maptitle)-1); + strncat(serverinfo->maptitle, " ", sizeof(serverinfo->maptitle)-1); + strncat(serverinfo->maptitle, mapheaderinfo[gamemap-1]->zonttl, sizeof(serverinfo->maptitle)-1); } else { - netbuffer->u.serverinfo.iszone = 1; // ms and clients will append this themselves + serverinfo->iszone = 1; // ms and clients will append this themselves } } if (mapheaderinfo[gamemap-1]->actnum[0]) { - strncat(netbuffer->u.serverinfo.maptitle, " ", sizeof(netbuffer->u.serverinfo.maptitle)-1); - strncat(netbuffer->u.serverinfo.maptitle, mapheaderinfo[gamemap-1]->actnum, - sizeof(netbuffer->u.serverinfo.maptitle)-1); + strncat(serverinfo->maptitle, " ", sizeof(serverinfo->maptitle)-1); + strncat(serverinfo->maptitle, mapheaderinfo[gamemap-1]->actnum, sizeof(serverinfo->maptitle)-1); } } else - strncpy(netbuffer->u.serverinfo.maptitle, "Unknown", 33); + { + strncpy(serverinfo->maptitle, "Unknown", 33); + } - netbuffer->u.serverinfo.maptitle[32] = '\0'; + serverinfo->maptitle[32] = '\0'; - netbuffer->u.serverinfo.actnum = 0; //mapheaderinfo[gamemap-1]->actnum + serverinfo->actnum = 0; //mapheaderinfo[gamemap-1]->actnum mirror_length = strlen(httpurl); if (mirror_length > MAX_MIRROR_LENGTH) mirror_length = MAX_MIRROR_LENGTH; - if (snprintf(netbuffer->u.serverinfo.httpsource, mirror_length+1, "%s", httpurl) < 0) + if (snprintf(serverinfo->httpsource, mirror_length+1, "%s", httpurl) < 0) // If there's an encoding error, send nothing, we accept that the above may be truncated - strncpy(netbuffer->u.serverinfo.httpsource, "", mirror_length); + strncpy(serverinfo->httpsource, "", mirror_length); - netbuffer->u.serverinfo.httpsource[MAX_MIRROR_LENGTH-1] = '\0'; + serverinfo->httpsource[MAX_MIRROR_LENGTH-1] = '\0'; p = PutFileNeeded(0); From e1430f7bc72e5db4873993d37b6b0b6cead84d0d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 8 Aug 2026 19:07:48 +0200 Subject: [PATCH 561/589] replace magic number with sizeof --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8001ac2fe..060e0a303 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1724,10 +1724,10 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) } else { - strncpy(serverinfo->maptitle, "Unknown", 33); + strncpy(serverinfo->maptitle, "Unknown", sizeof(serverinfo->maptitle)-1); } - serverinfo->maptitle[32] = '\0'; + serverinfo->maptitle[sizeof(serverinfo->maptitle)-1] = '\0'; serverinfo->actnum = 0; //mapheaderinfo[gamemap-1]->actnum From 309d459a7027b66885ca9f678ae4fe316b1693f1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 9 Aug 2026 15:00:44 +0200 Subject: [PATCH 562/589] fix apple clang warning for music test define this as constant otherwise compiler may treat the array as being variable in size for some reason --- src/m_menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index b75cfa430..2d758743d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5775,13 +5775,12 @@ static void M_DrawMusicTest(void) V_DrawFill(20, y-4, 280-1, 16, 237); { - const musicdef_t *def = S_GetMusicCredit(t); const char *songname = def->title[0] ? def->title : def->source; size_t namelength = strlen(songname); - static const size_t MAXLENGTH = 34; +#define MAXLENGTH 34 char buf[MAXLENGTH+1]; if (t == st_sel && namelength > MAXLENGTH) @@ -5795,6 +5794,7 @@ static void M_DrawMusicTest(void) { V_DrawFill(20+280-9, y-4, 8, 16, 230); } +#undef MAXLENGTH } t++; From 16577877d38711f4feb822dd40d24fc7cd0021f9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 9 Aug 2026 16:50:18 +0200 Subject: [PATCH 563/589] replace all sprintf with snprintf some of this was taken from https://gitlab.com/kart-krew-dev/ring-racers/-/commit/59f23dfa181327ed5c00f55688840d39e3583569 so thx! should fix apple clang warnings and is alot safer to have all this crap be bounded theres prob alot more other stuff, and id love to eventually replace all the strcpy family functions with snprintf and equivalent --- src/blua/lobject.c | 2 +- src/blua/lstrlib.c | 12 +++--- src/blua/luaconf.h | 2 +- src/command.c | 27 +++++++++---- src/d_clisrv.c | 14 +++---- src/d_net.c | 4 +- src/d_netcmd.c | 22 ++++++----- src/d_netfil.c | 5 ++- src/dedicated/i_system.c | 41 ++++++++++---------- src/discord.c | 2 +- src/f_wipe.c | 3 +- src/g_demo.c | 21 +++++----- src/g_game.c | 20 ++++++---- src/g_input.c | 3 +- src/hardware/hw_bsp.c | 3 +- src/hardware/hw_main.cpp | 6 +-- src/hardware/hw_md2.c | 4 +- src/hardware/hw_md2load.c | 58 +--------------------------- src/hardware/hw_md3load.c | 80 +-------------------------------------- src/http-mserv.c | 18 +++++---- src/hu_stuff.c | 18 ++++----- src/i_tcp.c | 9 ++--- src/k_hud.c | 36 +++++++++--------- src/lua_script.c | 3 +- src/m_menu.c | 31 ++++++++------- src/m_misc.c | 13 +++---- src/p_setup.c | 20 ++++++---- src/p_user.c | 16 ++++++-- src/s_sound.c | 2 +- src/sdl/i_system.cpp | 56 ++++++++++++++------------- src/sdl/i_ttf.c | 10 ++++- src/sdl/mixer_sound.c | 2 +- src/st_stuff.c | 2 +- src/w_wad.c | 6 +-- src/win32/win_dbg.c | 2 +- src/y_inter.c | 24 ++++++++---- 36 files changed, 261 insertions(+), 336 deletions(-) diff --git a/src/blua/lobject.c b/src/blua/lobject.c index 0250de21d..c3cdd9eec 100644 --- a/src/blua/lobject.c +++ b/src/blua/lobject.c @@ -143,7 +143,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { } case 'p': { char buff[4*sizeof(void *) + 8]; /* should be enough space for a `%p' */ - sprintf(buff, "%p", va_arg(argp, void *)); + snprintf(buff, sizeof(buff), "%p", va_arg(argp, void *)); pushstr(L, buff); break; } diff --git a/src/blua/lstrlib.c b/src/blua/lstrlib.c index 6fe279bcb..5d3e4193c 100644 --- a/src/blua/lstrlib.c +++ b/src/blua/lstrlib.c @@ -776,23 +776,23 @@ static int str_format (lua_State *L) { strfrmt = scanformat(L, strfrmt, form); switch (*strfrmt++) { case 'c': { - sprintf(buff, form, (int)luaL_checknumber(L, arg)); + snprintf(buff, sizeof(buff), form, (int)luaL_checknumber(L, arg)); break; } case 'd': case 'i': { addintlen(form); - sprintf(buff, form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); + snprintf(buff, sizeof(buff), form, (LUA_INTFRM_T)luaL_checknumber(L, arg)); break; } case 'o': case 'u': case 'x': case 'X': { addintlen(form); - sprintf(buff, form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); + snprintf(buff, sizeof(buff), form, (unsigned LUA_INTFRM_T)luaL_checknumber(L, arg)); break; } case 'e': case 'E': case 'f': case 'g': case 'G': { - lua_Number n = luaL_checknumber(L, arg); - sprintf(buff, form, (double)n); + lua_Number n = luaL_checknumber(L, arg); + snprintf(buff, sizeof(buff), form, (double)n); break; } case 'q': { @@ -810,7 +810,7 @@ static int str_format (lua_State *L) { continue; /* skip the `addsize' at the end */ } else { - sprintf(buff, form, s); + snprintf(buff, sizeof(buff), form, s); break; } } diff --git a/src/blua/luaconf.h b/src/blua/luaconf.h index 22fa8bf53..76ade3bfd 100644 --- a/src/blua/luaconf.h +++ b/src/blua/luaconf.h @@ -536,7 +536,7 @@ #define LUA_NUMBER_SCAN "%d" #define LUA_NUMBER_FMT "%d" #endif -#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) +#define lua_number2str(s,n) snprintf((s), LUAI_MAXNUMBER2STR, LUA_NUMBER_FMT, (n)) #define LUAI_MAXNUMBER2STR 12 /* 10 digits, sign, and \0 */ #define lua_str2number(s,p) ({ \ long nmr = strtol((s), (p), 10); \ diff --git a/src/command.c b/src/command.c index f09f7bf47..93d99f4ef 100644 --- a/src/command.c +++ b/src/command.c @@ -1596,7 +1596,9 @@ void CV_SaveNetVars(UINT8 **p, boolean isdemorecording) // send only changed cvars ... // the client will reset all netvars to default before loading WRITEUINT16(*p, 0x0000); + for (cvar = consvar_vars; cvar; cvar = cvar->next) + { if (((cvar->flags & CV_NETVAR) && !CV_IsSetToDefault(cvar)) || (isdemorecording && cvar->netid == cv_numlaps.netid)) { WRITEUINT16(*p, cvar->netid); @@ -1614,7 +1616,7 @@ void CV_SaveNetVars(UINT8 **p, boolean isdemorecording) else { char buf[9]; - sprintf(buf, "%d", mapheaderinfo[gamemap - 1]->numlaps); + snprintf(buf, sizeof(buf), "%d", mapheaderinfo[gamemap - 1]->numlaps); WRITESTRING(*p, buf); } } @@ -1626,6 +1628,8 @@ void CV_SaveNetVars(UINT8 **p, boolean isdemorecording) WRITEUINT8(*p, false); ++count; } + } + WRITEUINT16(count_p, count); } @@ -1782,8 +1786,7 @@ void CV_StealthSet(consvar_t *var, const char *value) void CV_StealthSetValue(consvar_t *var, INT32 value) { char val[32]; - - sprintf(val, "%d", value); + snprintf(val, sizeof(val), "%d", value); CV_SetCVar(var, val, true); } @@ -1803,8 +1806,7 @@ void CV_Set(consvar_t *var, const char *value) void CV_SetValue(consvar_t *var, INT32 value) { char val[32]; - - sprintf(val, "%d", value); + snprintf(val, sizeof(val), "%d", value); CV_SetCVar(var, val, false); } @@ -2202,6 +2204,7 @@ void CV_SaveVariables(FILE *f) consvar_t *cvar; for (cvar = consvar_vars; cvar; cvar = cvar->next) + { if (cvar->flags & CV_SAVE) { char stringtowrite[MAXTEXTCMD+1]; @@ -2210,15 +2213,23 @@ void CV_SaveVariables(FILE *f) if (fastcmp(cvar->string, "MAX") || fastcmp(cvar->string, "MIN")) { if (cvar->flags & CV_FLOAT) - sprintf(stringtowrite, "%f", FixedToFloat(cvar->value)); + { + snprintf(stringtowrite, sizeof(stringtowrite), "%f", FixedToFloat(cvar->value)); + } else - sprintf(stringtowrite, "%d", cvar->value); + { + snprintf(stringtowrite, sizeof(stringtowrite), "%d", cvar->value); + } } else - strcpy(stringtowrite, cvar->string); + { + strncpy(stringtowrite, cvar->string, sizeof(stringtowrite)-1); + stringtowrite[sizeof(stringtowrite)-1] = '\0'; + } fprintf(f, "%s \"%s\"\n", cvar->name, stringtowrite); } + } } //============================================================================ diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 060e0a303..c61ef182d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2097,7 +2097,7 @@ static void SV_SavedGame(void) if (!cv_dumpconsistency.value) return; - sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); + snprintf(tmpsave, sizeof(tmpsave), "%s" PATHSEP TMPSAVENAME, srb2home); // first save it in a malloced buffer save.p = save.buffer = (UINT8 *)Z_Malloc(SAVEGAMESIZE, PU_STATIC, NULL); @@ -2135,7 +2135,7 @@ static void CL_LoadReceivedSavegame(boolean reloading) size_t length, decompressedlen; char tmpsave[264]; - sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); + snprintf(tmpsave, sizeof(tmpsave), "%s" PATHSEP TMPSAVENAME, srb2home); length = FIL_ReadFile(tmpsave, &save.buffer); @@ -2214,7 +2214,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXPLAYERS; i++) { LUA_InvalidatePlayer(&players[i]); - sprintf(player_names[i], "Player %d", i + 1); + snprintf(player_names[i], MAXPLAYERNAME+1, "Player %d", i + 1); } CL_LoadReceivedSavegame(true); @@ -2950,7 +2950,7 @@ static void CL_ConnectToServer(void) tic_t asksent; char tmpsave[264]; - sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); + snprintf(tmpsave, sizeof(tmpsave), "%s" PATHSEP TMPSAVENAME, srb2home); filedownload.current = -1; cl_mode = CL_SEARCHING; @@ -3513,7 +3513,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) player_muted[playernum] = false; // Reset the name - sprintf(player_names[playernum], "Player %d", playernum+1); + snprintf(player_names[playernum], MAXPLAYERNAME+1, "Player %d", playernum+1); player_name_changes[playernum] = 0; @@ -4475,7 +4475,7 @@ void SV_ResetServer(void) for (i = 0; i < MAXPLAYERS; i++) { LUA_InvalidatePlayer(&players[i]); - sprintf(player_names[i], "Player %d", i + 1); + snprintf(player_names[i], MAXPLAYERNAME+1, "Player %d", i + 1); } memset(player_name_changes, 0, sizeof(player_name_changes)); @@ -5534,7 +5534,7 @@ static void PT_WillResendGamestate(void) CONS_Printf(M_GetText("Reloading game state...\n")); - sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); + snprintf(tmpsave, sizeof(tmpsave), "%s" PATHSEP TMPSAVENAME, srb2home); // Don't get a corrupt savegame error because tmpsave already exists if (FIL_FileExists(tmpsave) && unlink(tmpsave) == -1) diff --git a/src/d_net.c b/src/d_net.c index f7e7ffecd..a11dd3401 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1315,7 +1315,9 @@ boolean D_CheckNetGame(void) while (!debugfile && k < MAXPLAYERS) { k++; - sprintf(filename, "debug%d.txt", k); + + snprintf(filename, sizeof(filename), "debug%d.txt", k); + debugfile = fopen(va("%s" PATHSEP "%s", srb2home, filename), "w"); } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f08d0d2c8..cd8dba956 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -608,7 +608,7 @@ void D_RegisterServerCommands(void) // Set default player names // Monster Iestyn (12/08/19): not sure where else I could have actually put this, but oh well for (i = 0; i < MAXPLAYERS; i++) - sprintf(player_names[i], "Player %d", 1 + i); + snprintf(player_names[i], sizeof(player_names[i]), "Player %d", 1 + i); RegisterNetXCmd(XD_NAMEANDCOLOR, Got_NameAndColor); RegisterNetXCmd(XD_WEAPONPREF, Got_WeaponPref); @@ -1288,7 +1288,8 @@ static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum) else if (len == 1) // Agh! { // Last ditch effort... - sprintf(name, "%d", M_RandomKey(10)); + snprintf(name, MAXPLAYERNAME+1, "%d", M_RandomKey(10)); + if (!EnsurePlayerNameIsGood(name, playernum)) return false; } @@ -2342,11 +2343,12 @@ static char *ConcatCommandArgv(int start, int end) if (!p) I_Error("ConcatCommandArgv: Out of memory!\n"); - --end;/* handle the final argument separately */ + --end; /* handle the final argument separately */ for (i = start; i < end; ++i) { - p += sprintf(p, "%s ", COM_Argv(i)); + if (size - (p - final) > 0) + p += snprintf(p, size - (p - final), "%s ", COM_Argv(i)); } /* at this point "end" is actually the last argument's position */ @@ -4361,13 +4363,13 @@ static void Got_RequestAddfilecmd(const UINT8 **cp, INT32 playernum) char message[275]; if (toomany) - sprintf(message, M_GetText("Too many files loaded to add %s\n"), filename); + snprintf(message, sizeof(message), M_GetText("Too many files loaded to add %s\n"), filename); else if (ncs == FS_NOTFOUND) - sprintf(message, M_GetText("The server doesn't have %s\n"), filename); + snprintf(message, sizeof(message), M_GetText("The server doesn't have %s\n"), filename); else if (ncs == FS_MD5SUMBAD) - sprintf(message, M_GetText("Checksum mismatch on %s\n"), filename); + snprintf(message, sizeof(message), M_GetText("Checksum mismatch on %s\n"), filename); else - sprintf(message, M_GetText("Unknown error finding wad file (%s)\n"), filename); + snprintf(message, sizeof(message), M_GetText("Unknown error finding wad file (%s)\n"), filename); CONS_Printf("%s",message); @@ -5201,8 +5203,10 @@ static void Command_Mapmd5_f(void) { INT32 i; char md5tmp[33]; + for (i = 0; i < 16; ++i) - sprintf(&md5tmp[i*2], "%02x", mapmd5[i]); + snprintf(&md5tmp[i*2], 3, "%02x", mapmd5[i]); + CONS_Printf("%s: %s\n", G_BuildMapName(gamemap), md5tmp); } else diff --git a/src/d_netfil.c b/src/d_netfil.c index 613b72df5..e8d3baa7e 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -299,10 +299,13 @@ boolean CL_CheckDownloadable(void) { INT32 j; char md5tmp[33]; + for (j = 0; j < 16; j++) - sprintf(&md5tmp[j*2], "%02x", fileneeded[i].md5sum[j]); + snprintf(&md5tmp[j*2], 3, "%02x", fileneeded[i].md5sum[j]); + CONS_Printf("%s", md5tmp); } + CONS_Printf("\n"); } } diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index b6d50a712..c5ae3b451 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -542,7 +542,7 @@ void I_OutputMsg(const char *fmt, ...) I_Error("I_OutputMsg: Out of memory!\n"); va_start(argptr, fmt); - vsprintf(txt, fmt, argptr); + vsnprintf(txt, len+1, fmt, argptr); va_end(argptr); #ifdef HAVE_TTF @@ -550,7 +550,7 @@ void I_OutputMsg(const char *fmt, ...) DEFAULTFONTBGR, DEFAULTFONTBGG, DEFAULTFONTBGB, DEFAULTFONTBGA, txt); #endif - len = strlen(txt); + len = strnlen(txt, len+1); #ifdef LOGMESSAGES if (logstream) @@ -1053,7 +1053,7 @@ static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_ms sigmsg = ("SIGABRT - SRB2Kart-Saturn was terminated by an abort signal."); break; default: - sprintf(signal_msg, "Signal number %d", signal_num); + snprintf(signal_msg, 512, "Signal number %d", signal_num); sigmsg = (core_dumped ? "Unknown signal" : signal_msg); break; } @@ -1061,13 +1061,17 @@ static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_ms if (core_dumped) { if (sigmsg) - sprintf(signal_msg, "%s (core dumped)", sigmsg); + { + snprintf(signal_msg, 512, "%s (core dumped)", sigmsg); + } else + { strcat(signal_msg, " (core dumped)"); + } } else { - sprintf(signal_msg, "%s", sigmsg); + snprintf(signal_msg, 512, "%s", sigmsg); } } @@ -1764,7 +1768,8 @@ char *I_GetUserName(void) } } } - strncpy(username, p, MAXPLAYERNAME); + + snprintf(username, sizeof(username), "%s", p); } if (!fastcmp(username, "")) @@ -1820,28 +1825,23 @@ const char *I_ClipboardPaste(void) */ static boolean isWadPathOk(const char *path) { - char *wad3path = (char*)(malloc(256)); + char wad3path[256]; - if (!wad3path) - return false; - - sprintf(wad3path, pandf, path, WADKEYWORD); + snprintf(wad3path, sizeof(wad3path), pandf, path, WADKEYWORD); if (FIL_ReadFileOK(wad3path)) { - free(wad3path); return true; } - free(wad3path); return false; } -static void pathonly(char *s) +static void pathonly(char *s, size_t size) { size_t j; - for (j = strlen(s); j != (size_t)-1; j--) + for (j = strnlen(s, size); j != (size_t)-1; j--) { if ((s[j] == '\\') || (s[j] == ':') || (s[j] == '/')) { @@ -1868,11 +1868,12 @@ static const char *searchWad(const char *searchDir) static char tempsw[256] = ""; filestatus_t fstemp; - strcpy(tempsw, WADKEYWORD); + snprintf(tempsw, sizeof(tempsw), "%s", WADKEYWORD); fstemp = filesearch(tempsw, searchDir, NULL, true, 20); + if (fstemp == FS_FOUND) { - pathonly(tempsw); + pathonly(tempsw, sizeof(tempsw)); return tempsw; } @@ -1910,7 +1911,7 @@ static const char *locateWad(void) #ifndef NOCWD // examine current dir - strcpy(returnWadPath, "."); + snprintf(returnWadPath, sizeof(returnWadPath), "%s", "."); I_OutputMsg(",%s", returnWadPath); if (isWadPathOk(returnWadPath)) return NULL; @@ -1922,7 +1923,7 @@ static const char *locateWad(void) // examine user jart directory if ((envstr = I_GetEnv("HOME")) != NULL) { - sprintf(returnWadPath, "%s" PATHSEP DEFAULTDIR, envstr); + snprintf(returnWadPath, sizeof(returnWadPath), "%s" PATHSEP DEFAULTDIR, envstr); CHECKWADPATH(returnWadPath); } #endif @@ -1936,7 +1937,7 @@ static const char *locateWad(void) // examine default dirs for (i = 0; wadDefaultPaths[i]; i++) { - strcpy(returnWadPath, wadDefaultPaths[i]); + snprintf(returnWadPath, sizeof(returnWadPath), "%s", wadDefaultPaths[i]); CHECKWADPATH(returnWadPath); } diff --git a/src/discord.c b/src/discord.c index 8f937cfc1..a5e5f59c9 100644 --- a/src/discord.c +++ b/src/discord.c @@ -402,7 +402,7 @@ static void Discordrp_OnChange(void) static void DRPC_GotServerIP(UINT32 address) { const unsigned char * p = (const unsigned char *)&address; - sprintf(self_ip, "%u.%u.%u.%u:%u", p[0], p[1], p[2], p[3], current_port); + snprintf(self_ip, IP_SIZE+1, "%u.%u.%u.%u:%u", p[0], p[1], p[2], p[3], current_port); } /*-------------------------------------------------- diff --git a/src/f_wipe.c b/src/f_wipe.c index 32b385c9e..8abbe3397 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -111,7 +111,8 @@ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) goto freemask; // SRB2Kart: This suddenly triggers ERRORMODE now - //sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)masknum, (UINT16)scrnnum); + //snprintf(&lumpname[4], 3, "%.2hu%.2hu", (UINT16)masknum, (UINT16)scrnnum); + //lumpname[8] = 0; lumpname[4] = '0'+(masknum/10); lumpname[5] = '0'+(masknum%10); diff --git a/src/g_demo.c b/src/g_demo.c index f4240a42d..b86bbc8f8 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2212,7 +2212,8 @@ void G_LoadDemoInfo(menudemo_t *pdemo) { CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), pdemo->filepath); pdemo->type = MD_INVALID; - sprintf(pdemo->title, "INVALID REPLAY"); + snprintf(pdemo->title, sizeof(pdemo->title), "INVALID REPLAY"); + return; } @@ -2222,7 +2223,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) { CONS_Alert(CONS_ERROR, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemo->filepath); pdemo->type = MD_INVALID; - sprintf(pdemo->title, "INVALID REPLAY"); + snprintf(pdemo->title, sizeof(pdemo->title), "INVALID REPLAY"); return; } @@ -2247,14 +2248,14 @@ void G_LoadDemoInfo(menudemo_t *pdemo) #ifdef DEMO_COMPAT_100 case 0x0001: pdemo->type = MD_OUTDATED; - sprintf(pdemo->title, "Legacy Replay"); + snprintf(pdemo->title, sizeof(pdemo->title), "Legacy Replay"); break; #endif // too old, cannot support. default: CONS_Alert(CONS_ERROR, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemo->filepath); pdemo->type = MD_INVALID; - sprintf(pdemo->title, "INVALID REPLAY"); + snprintf(pdemo->title, sizeof(pdemo->title), "INVALID REPLAY"); return; } @@ -2267,7 +2268,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) { CONS_Alert(CONS_ERROR, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemo->filepath); pdemo->type = MD_INVALID; - sprintf(pdemo->title, "INVALID REPLAY"); + snprintf(pdemo->title, sizeof(pdemo->title), "INVALID REPLAY"); return; } @@ -2288,7 +2289,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) { CONS_Alert(CONS_ERROR, M_GetText("%s is a legacy multiplayer replay and cannot be played.\n"), pdemo->filepath); pdemo->type = MD_INVALID; - sprintf(pdemo->title, "INVALID REPLAY"); + snprintf(pdemo->title, sizeof(pdemo->title), "INVALID REPLAY"); return; } #endif @@ -2522,7 +2523,7 @@ void G_LoadDemoTitle(menudemo_t *pdemo) if (!handle) { CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), pdemo->filepath); - sprintf(pdemo->title, "INVALID REPLAY"); + snprintf(pdemo->title, sizeof(pdemo->title), "INVALID REPLAY"); return; } @@ -2534,7 +2535,7 @@ void G_LoadDemoTitle(menudemo_t *pdemo) if (count < 96 || memcmp(info_p, DEMOHEADER, 12)) { CONS_Alert(CONS_ERROR, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemo->filepath); - sprintf(pdemo->title, "INVALID REPLAY"); + snprintf(pdemo->title, sizeof(pdemo->title), "INVALID REPLAY"); return; } @@ -2563,13 +2564,13 @@ void G_LoadDemoTitle(menudemo_t *pdemo) break; #ifdef DEMO_COMPAT_100 case 0x0001: - sprintf(pdemo->title, "Legacy Replay"); + snprintf(pdemo->title, sizeof(pdemo->title), "Legacy Replay"); break; #endif // too old, cannot support. default: CONS_Alert(CONS_ERROR, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemo->filepath); - sprintf(pdemo->title, "INVALID REPLAY"); + snprintf(pdemo->title, sizeof(pdemo->title), "INVALID REPLAY"); } } diff --git a/src/g_game.c b/src/g_game.c index 50d43cf7a..c2b6499f9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -604,14 +604,18 @@ const char *G_BuildMapName(INT32 map) } if (map < 100 && map >= 0) // ...but why use signed integer in first place? idk but this prevents warning (and potential buffer overflow lol) - sprintf(&mapname[3], "%.2d", map); + { + snprintf(&mapname[3], sizeof(mapname)-3, "%.2d", map); + } else { mapname[3] = (char)('A' + (char)((map - 100) / 36)); + if ((map - 100) % 36 < 10) mapname[4] = (char)('0' + (char)((map - 100) % 36)); else mapname[4] = (char)('A' + (char)((map - 100) % 36) - 10); + mapname[5] = '\0'; } @@ -3766,7 +3770,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride) startonmapnum = mapoverride; #endif - sprintf(savename, savegamename, slot); + snprintf(savename, sizeof(savename), savegamename, slot); length = FIL_ReadFile(savename, &save.buffer); if (!length) @@ -3778,7 +3782,7 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride) save.p = save.buffer; memset(vcheck, 0, sizeof (vcheck)); - sprintf(vcheck, "version %d", VERSION); + snprintf(vcheck, sizeof(vcheck), "version %d", VERSION); if (!fastcmp((const char *)save.p, (const char *)vcheck)) { @@ -3844,7 +3848,7 @@ void G_SaveGame(UINT32 savegameslot) const char *backup; savebuffer_t save = {}; - sprintf(savename, savegamename, savegameslot); + snprintf(savename, sizeof(savename), savegamename, savegameslot); backup = va("%s",savename); // save during evaluation or credits? game's over, folks! @@ -3864,7 +3868,7 @@ void G_SaveGame(UINT32 savegameslot) } memset(name, 0, sizeof (name)); - sprintf(name, "version %d", VERSION); + snprintf(name, sizeof(name), "version %d", VERSION); WRITEMEM(save.p, name, VERSIONSIZE); P_SaveGame(&save); @@ -4093,12 +4097,12 @@ char *G_BuildMapTitle(INT32 mapnum) if (!title) return NULL; - sprintf(title, "%s", mapheaderinfo[mapnum-1]->lvlttl); + snprintf(title, len, "%s", mapheaderinfo[mapnum-1]->lvlttl); if (zonetext) - sprintf(title + strlen(title), " %s", zonetext); + snprintf(title + strlen(title), len - strlen(title), " %s", zonetext); if (actnum) - sprintf(title + strlen(title), " %s", actnum); + snprintf(title + strlen(title), len - strlen(title), " %s", actnum); } return title; diff --git a/src/g_input.c b/src/g_input.c index c4dfece9d..31df065fc 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1250,7 +1250,8 @@ const char *G_KeynumToString(INT32 keynum) return keynames[j].name; // create a name for unknown keys - sprintf(keynamestr, "KEY%d", keynum); + snprintf(keynamestr, sizeof(keynamestr), "KEY%d", keynum); + return keynamestr; } diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index f53153ea9..07b7c1e5e 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -581,7 +581,8 @@ static void loading_status(void) I_OsPolling(); CON_Drawer(); - sprintf(s, "%d%%", (++ls_percent)<<1); + snprintf(s, sizeof(s), "%d%%", (++ls_percent)<<1); + x = BASEVIDWIDTH/2; y = BASEVIDHEIGHT/2; V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); // Black background to match fade in effect diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index baa4461e4..f7c689525 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -514,7 +514,7 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg, extracolormap_t *colo const INT16 offset = (cv_glfakecontrast.value == 2) ? seg->hwLightOffset : ((INT16)seg->lightOffset * 8); finallight += offset; - finallight = CLAMP(finallight, 0 , 255); + finallight = CLAMP(finallight, 0, 255); } return (FUINT)finallight; @@ -532,7 +532,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t const INT16 offset = (cv_glfakecontrast.value == 2) ? slope->hwLightOffset : ((INT16)slope->lightOffset * 8); finallight += (fof ? -offset : offset); - finallight = CLAMP(finallight, 0 , 255); + finallight = CLAMP(finallight, 0, 255); } return (FUINT)finallight; @@ -6121,7 +6121,7 @@ static boolean HWR_WipeCheck(UINT8 wipenum, UINT8 scrnnum) } // puts the numbers into the lumpname - sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)wipenum, (UINT16)scrnnum); + snprintf(&lumpname[4], sizeof(lumpname) - 4, "%.2hu%.2hu", (UINT16)wipenum, (UINT16)scrnnum); wipelumpnum = W_CheckNumForName(lumpname); // again, shouldn't be here really diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 0f8328041..f21f2f82d 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1247,7 +1247,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) if (!md2->model) { CONS_Debug(DBG_RENDER, "Loading model... (%s, %s)", sprnames[spr->mobj->sprite], md2->filename); - sprintf(filename, "mdls/%s", md2->filename); + snprintf(filename, sizeof(filename), "mdls/%s", md2->filename); md2->model = md2_readModel(filename); if (md2->model) @@ -1483,7 +1483,7 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c { char filename[64]; CONS_Debug(DBG_RENDER, "Loading model... (%s)\n", md2->filename); - sprintf(filename, "mdls/%s", md2->filename); + snprintf(filename, sizeof(filename), "mdls/%s", md2->filename); md2->model = md2_readModel(filename); if (md2->model) diff --git a/src/hardware/hw_md2load.c b/src/hardware/hw_md2load.c index d28ebf058..a880aa677 100644 --- a/src/hardware/hw_md2load.c +++ b/src/hardware/hw_md2load.c @@ -275,13 +275,6 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) return NULL; retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, NULL); - - //size_t fileLen; - - //int i, j; - - //size_t namelen; - //char *texturefilename; texPos = strchr(fileName, '/'); if (texPos) @@ -318,8 +311,6 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) retModel->numMeshes = 1; // MD2 only has one mesh retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, NULL); retModel->meshes[0].numFrames = header->numFrames; - // const float WUNITS = 1.0f; - // float dataScale = WUNITS; // Tris and ST are simple structures that can be straight-copied tris = (md2triangle_t*)&buffer[header->offsetTris]; @@ -355,47 +346,6 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) retModel->materials[t].specular[3] = 1.0f; retModel->materials[t].shininess = 0.0f; retModel->materials[t].spheremap = false; - - /* retModel->materials[t].texture = Texture::ReadTexture((char*)texturefilename, ZT_TEXTURE); - - if (!systemSucks) - { - // Check for a normal map...?? - char openfilename[1024]; - char normalMapName[1024]; - strcpy(normalMapName, texturefilename); - size_t len = strlen(normalMapName); - char *ptr = &normalMapName[len]; - ptr--; // z - ptr--; // u - ptr--; // b - ptr--; // . - *ptr++ = '_'; - *ptr++ = 'n'; - *ptr++ = '.'; - *ptr++ = 'b'; - *ptr++ = 'u'; - *ptr++ = 'z'; - *ptr++ = '\0'; - - sprintf(openfilename, "%s/%s", "textures", normalMapName); - // Convert backslashes to forward slashes - for (int k = 0; k < 1024; k++) - { - if (openfilename[k] == '\0') - break; - - if (openfilename[k] == '\\') - openfilename[k] = '/'; - } - - Resource::resource_t *res = Resource::Open(openfilename); - if (res) - { - Resource::Close(res); - retModel->materials[t].lightmap = Texture::ReadTexture(normalMapName, ZT_TEXTURE); - } - }*/ } retModel->meshes[0].numTriangles = header->numTris; @@ -425,15 +375,11 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) md2frame_t *framePtr = (md2frame_t*)ptr; retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, NULL); retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, NULL); - - // if (retModel->materials[0].lightmap) - // retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag); retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, NULL); vertptr = retModel->meshes[0].tinyframes[i].vertices; normptr = retModel->meshes[0].tinyframes[i].normals; - // tanptr = retModel->meshes[0].tinyframes[i].tangents; retModel->meshes[0].tinyframes[i].material = &retModel->materials[0]; framePtr++; // Advance to vertex list @@ -509,9 +455,7 @@ model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) md2frame_t *framePtr = (md2frame_t*)ptr; retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, NULL); - // if (retModel->materials[0].lightmap) - // retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag); - //float *vertptr, *normptr; + normptr = (float*)retModel->meshes[0].frames[i].normals; vertptr = (float*)retModel->meshes[0].frames[i].vertices; trisPtr = tris; diff --git a/src/hardware/hw_md3load.c b/src/hardware/hw_md3load.c index 06aa6507e..73111f63e 100644 --- a/src/hardware/hw_md3load.c +++ b/src/hardware/hw_md3load.c @@ -243,48 +243,6 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) mdShader[j].name[len-1] = 'z'; mdShader[j].name[len-2] = 'u'; mdShader[j].name[len-3] = 'b'; - - // Load material -/* retModel->materials[matCount].texture = Texture::ReadTexture(mdShader[j].name, ZT_TEXTURE); - - if (!systemSucks) - { - // Check for a normal map...?? - char openfilename[1024]; - char normalMapName[1024]; - strcpy(normalMapName, mdShader[j].name); - len = strlen(normalMapName); - char *ptr = &normalMapName[len]; - ptr--; // z - ptr--; // u - ptr--; // b - ptr--; // . - *ptr++ = '_'; - *ptr++ = 'n'; - *ptr++ = '.'; - *ptr++ = 'b'; - *ptr++ = 'u'; - *ptr++ = 'z'; - *ptr++ = '\0'; - - sprintf(openfilename, "%s/%s", "textures", normalMapName); - // Convert backslashes to forward slashes - for (int k = 0; k < 1024; k++) - { - if (openfilename[k] == '\0') - break; - - if (openfilename[k] == '\\') - openfilename[k] = '/'; - } - - Resource::resource_t *res = Resource::Open(openfilename); - if (res) - { - Resource::Close(res); - retModel->materials[matCount].lightmap = Texture::ReadTexture(normalMapName, ZT_TEXTURE); - } - }*/ } retModel->meshes[i].numFrames = mdS->numFrames; @@ -305,19 +263,15 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) { short *vertptr; char *normptr; - // char *tanptr; int k; md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, NULL); retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, NULL); -// if (retModel->materials[0].lightmap) -// retModel->meshes[i].tinyframes[j].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag); retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, NULL); vertptr = retModel->meshes[i].tinyframes[j].vertices; normptr = retModel->meshes[i].tinyframes[j].normals; -// tanptr = retModel->meshes[i].tinyframes[j].tangents; retModel->meshes[i].tinyframes[j].material = &retModel->materials[i]; for (k = 0; k < mdS->numVerts; k++) @@ -384,8 +338,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, NULL); -// if (retModel->materials[i].lightmap) -// retModel->meshes[i].frames[j].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag); + vertptr = retModel->meshes[i].frames[j].vertices; normptr = retModel->meshes[i].frames[j].normals; retModel->meshes[i].frames[j].material = &retModel->materials[i]; @@ -471,37 +424,6 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) } } } - /* - // Tags? - retModel->numTags = mdh->numTags; - retModel->maxNumFrames = mdh->numFrames; - retModel->tags = (tag_t*)Z_Calloc(sizeof(tag_t) * retModel->numTags * mdh->numFrames, ztag); - md3Tag *mdTag = (md3Tag*)&buffer[mdh->offsetTags]; - tag_t *curTag = retModel->tags; - for (i = 0; i < mdh->numFrames; i++) - { - int j; - for (j = 0; j < retModel->numTags; j++, mdTag++) - { - strcpys(curTag->name, mdTag->name, sizeof(curTag->name) / sizeof(char)); - curTag->transform.m[0][0] = mdTag->axis[0]; - curTag->transform.m[0][1] = mdTag->axis[1]; - curTag->transform.m[0][2] = mdTag->axis[2]; - curTag->transform.m[1][0] = mdTag->axis[3]; - curTag->transform.m[1][1] = mdTag->axis[4]; - curTag->transform.m[1][2] = mdTag->axis[5]; - curTag->transform.m[2][0] = mdTag->axis[6]; - curTag->transform.m[2][1] = mdTag->axis[7]; - curTag->transform.m[2][2] = mdTag->axis[8]; - curTag->transform.m[3][0] = mdTag->origin[0] * WUNITS; - curTag->transform.m[3][1] = mdTag->origin[1] * WUNITS; - curTag->transform.m[3][2] = mdTag->origin[2] * WUNITS; - curTag->transform.m[3][3] = 1.0f; - - Matrix::Rotate(&curTag->transform, 90.0f, &Vector::Xaxis); - curTag++; - } - }*/ free(buffer); diff --git a/src/http-mserv.c b/src/http-mserv.c index 7b5fac188..c371dbb54 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -135,8 +135,7 @@ HMS_on_read (char *s, size_t _1, size_t n, void *userdata) return n; } -static struct HMS_buffer * -HMS_connect (const char *format, ...) +static struct HMS_buffer *HMS_connect(const char *format, ...) { va_list ap; CURL *curl; @@ -174,7 +173,7 @@ HMS_connect (const char *format, ...) if (cv_masterserver_token.string && cv_masterserver_token.string[0]) { quack_token = curl_easy_escape(curl, cv_masterserver_token.string, 0); - token_length = ( sizeof "&token="-1 )+ strlen(quack_token); + token_length = ( sizeof "&token="-1 ) + strlen(quack_token); } else { @@ -186,27 +185,30 @@ HMS_connect (const char *format, ...) I_lock_mutex(&hms_api_mutex); #endif - seek = strlen(hms_api) + 1;/* + '/' */ + seek = strlen(hms_api) + 1; /* + '/' */ va_start (ap, format); - url = malloc(seek + vsnprintf(NULL, 0, format, ap) + sizeof HMS_QUERY_VERSION - 1 + token_length + 1); + size_t url_size = (seek + vsnprintf(NULL, 0, format, ap) + + sizeof HMS_QUERY_VERSION - 1 + + token_length + 1); + url = malloc(url_size); va_end (ap); - sprintf(url, "%s/", hms_api); + snprintf(url, seek + 1, "%s/", hms_api); #ifdef HAVE_THREADS I_unlock_mutex(hms_api_mutex); #endif va_start (ap, format); - seek += vsprintf(&url[seek], format, ap); + seek += vsnprintf(&url[seek], url_size - seek, format, ap); va_end (ap); strcpy(&url[seek], HMS_QUERY_VERSION); seek += sizeof HMS_QUERY_VERSION - 1; if (quack_token) - sprintf(&url[seek], "&token=%s", quack_token); + snprintf(&url[seek], url_size - seek, "&token=%s", quack_token); Printf_url(url); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index e7c8c3ddb..c61ecc9f2 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -154,14 +154,14 @@ void HU_LoadGraphics(void) for (i = 0; i < HU_FONTSIZE; i++, j++) { // cache the heads-up font for entire game execution - sprintf(buffer, "STCFN%.3d", j); + snprintf(buffer, sizeof(buffer), "STCFN%.3d", j); if (W_CheckNumForName(buffer) == LUMPERROR) hu_font[i] = NULL; else hu_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); // tiny version of the heads-up font - sprintf(buffer, "TNYFN%.3d", j); + snprintf(buffer, sizeof(buffer), "TNYFN%.3d", j); if (W_CheckNumForName(buffer) == LUMPERROR) tny_font[i] = NULL; else @@ -188,7 +188,7 @@ void HU_LoadGraphics(void) for (i = 0; i < KART_FONTSIZE; i++, j++) { // cache the heads-up font for entire game execution - sprintf(buffer, "MKFNT%.3d", j); + snprintf(buffer, sizeof(buffer), "MKFNT%.3d", j); if (W_CheckNumForName(buffer) == LUMPERROR) kart_font[i] = NULL; else @@ -199,7 +199,7 @@ void HU_LoadGraphics(void) j = LT_FONTSTART; for (i = 0; i < LT_FONTSIZE; i++) { - sprintf(buffer, "LTFNT%.3d", j); + snprintf(buffer, sizeof(buffer), "LTFNT%.3d", j); j++; if (W_CheckNumForName(buffer) == LUMPERROR) @@ -212,7 +212,7 @@ void HU_LoadGraphics(void) j = CRED_FONTSTART; for (i = 0; i < CRED_FONTSIZE; i++) { - sprintf(buffer, "CRFNT%.3d", j); + snprintf(buffer, sizeof(buffer), "CRFNT%.3d", j); j++; if (W_CheckNumForName(buffer) == LUMPERROR) @@ -224,11 +224,11 @@ void HU_LoadGraphics(void) // cache numbers too! for (i = 0; i < 10; i++) { - sprintf(buffer, "STTNUM%d", i); + snprintf(buffer, sizeof(buffer), "STTNUM%d", i); tallnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - sprintf(buffer, "PINGN%d", i); + snprintf(buffer, sizeof(buffer), "PINGN%d", i); pingnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - sprintf(buffer, "OPPRNK0%d", i); + snprintf(buffer, sizeof(buffer), "OPPRNK0%d", i); ranknum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } @@ -240,7 +240,7 @@ void HU_LoadGraphics(void) // cache ping gfx: for (i = 0; i < 5; i++) { - sprintf(buffer, "PINGGFX%d", i+1); + snprintf(buffer, sizeof(buffer), "PINGGFX%d", i+1); pinggfx[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } diff --git a/src/i_tcp.c b/src/i_tcp.c index 4eab1efbc..565d30d3c 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -213,7 +213,7 @@ static char *get_WSAErrorStr(int e) NULL); if (!buf[0]) // provide a fallback error message if no message is available for some reason - sprintf(buf, "Unknown error"); + snprintf(buf, sizeof(buf), "Unknown error"); return buf; } @@ -364,12 +364,12 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk) if (addr == NULL) { - sprintf(s, "No address"); + snprintf(s, sizeof(s), "No address"); } else if (inet_ntop(sk->any.sa_family, addr, &s[v6], sizeof (s) - v6) == NULL) { e = errno; - sprintf(s, "Unknown family type, error #%u: %s", e, strerror(e)); + snprintf(s, sizeof(s), "Unknown family type, error #%u: %s", e, strerror(e)); } #ifdef HAVE_IPV6 else if(sk->any.sa_family == AF_INET6) @@ -416,7 +416,7 @@ static const char *SOCK_GetBanMask(size_t ban) if (ban >= numbans) return NULL; - if (sprintf(s,"%d",banned[ban].mask) > 0) + if (snprintf(s, sizeof(s), "%d",banned[ban].mask) > 0) return s; return NULL; @@ -622,7 +622,6 @@ static boolean hole_punch(ssize_t c) { return false; } - } #endif //ifdef HOLEPUNCH diff --git a/src/k_hud.c b/src/k_hud.c index 9dbdb935b..71bd018c0 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -388,7 +388,7 @@ static void K_LoadSaturnHUDGraphics(void) skp_speedpatchesdial[3] = (patch_t *)W_CachePatchName("SP_DFRAC", PU_HUDGFX); skp_speedpatchesdial[4] = (patch_t *)W_CachePatchName("SP_DPERC", PU_HUDGFX); - sprintf(buffer, "K_DSPNMx"); + snprintf(buffer, sizeof(buffer), "K_DSPNMx"); for (i = 0; i < 10; i++) { buffer[7] = '0'+(i%10); @@ -507,7 +507,7 @@ static void K_LoadSaturnHUDGraphics(void) skp_speedpatchesdialclr[3] = (patch_t *)W_CachePatchName("SC_DFRAC", PU_HUDGFX); skp_speedpatchesdialclr[4] = (patch_t *)W_CachePatchName("SC_DPERC", PU_HUDGFX); - sprintf(buffer, "K_DSPNCx"); + snprintf(buffer, sizeof(buffer), "K_DSPNCx"); for (i = 0; i < 10; i++) { buffer[7] = '0'+(i%10); @@ -677,7 +677,7 @@ void K_LoadKartHUDGraphics(void) kp_racefinish[5] = (patch_t *)W_CachePatchName("K_2PFINB", PU_HUDGFX); // Position numbers - sprintf(buffer, "K_POSNxx"); + snprintf(buffer, sizeof(buffer), "K_POSNxx"); for (i = 0; i < NUMPOSNUMS; i++) { buffer[6] = '0'+i; @@ -688,14 +688,14 @@ void K_LoadKartHUDGraphics(void) } } - sprintf(buffer, "K_POSNWx"); + snprintf(buffer, sizeof(buffer), "K_POSNWx"); for (i = 0; i < NUMWINFRAMES; i++) { buffer[7] = '0'+i; kp_winnernum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } - sprintf(buffer, "OPPRNKxx"); + snprintf(buffer, sizeof(buffer), "OPPRNKxx"); for (i = 0; i <= MAXPLAYERS; i++) { buffer[6] = '0'+(i/10); @@ -703,7 +703,7 @@ void K_LoadKartHUDGraphics(void) kp_facenum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } - sprintf(buffer, "K_CHILIx"); + snprintf(buffer, sizeof(buffer), "K_CHILIx"); for (i = 0; i < 8; i++) { buffer[7] = '0'+(i+1); @@ -772,21 +772,21 @@ void K_LoadKartHUDGraphics(void) kp_kitchensink[1] = (patch_t *)W_CachePatchName("K_ISSINK", PU_HUDGFX); kp_sadface[1] = (patch_t *)W_CachePatchName("K_ISSAD", PU_HUDGFX); - sprintf(buffer, "K_ITINVx"); + snprintf(buffer, sizeof(buffer), "K_ITINVx"); for (i = 0; i < 7; i++) { buffer[7] = '1'+i; kp_invincibility[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } - sprintf(buffer, "K_ITORBx"); + snprintf(buffer, sizeof(buffer), "K_ITORBx"); for (i = 0; i < 4; i++) { buffer[7] = '1'+i; kp_orbinaut[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } - sprintf(buffer, "K_ISINVx"); + snprintf(buffer, sizeof(buffer), "K_ISINVx"); for (i = 0; i < 6; i++) { buffer[7] = '1'+i; @@ -794,7 +794,7 @@ void K_LoadKartHUDGraphics(void) } // CHECK indicators - sprintf(buffer, "K_CHECKx"); + snprintf(buffer, sizeof(buffer), "K_CHECKx"); for (i = 0; i < 6; i++) { buffer[7] = '1'+i; @@ -802,7 +802,7 @@ void K_LoadKartHUDGraphics(void) } // Eggman warning numbers - sprintf(buffer, "K_EGGNx"); + snprintf(buffer, sizeof(buffer), "K_EGGNx"); for (i = 0; i < 4; i++) { buffer[6] = '0'+i; @@ -815,7 +815,7 @@ void K_LoadKartHUDGraphics(void) kp_fpview[2] = (patch_t *)W_CachePatchName("VIEWC0E0", PU_HUDGFX); // Input UI Wheel - sprintf(buffer, "K_WHEELx"); + snprintf(buffer, sizeof(buffer), "K_WHEELx"); for (i = 0; i < 5; i++) { buffer[7] = '0'+i; @@ -823,7 +823,7 @@ void K_LoadKartHUDGraphics(void) } // HERE COMES A NEW CHALLENGER - sprintf(buffer, "K_CHALxx"); + snprintf(buffer, sizeof(buffer), "K_CHALxx"); for (i = 0; i < 25; i++) { buffer[6] = '0'+((i+1)/10); @@ -832,14 +832,14 @@ void K_LoadKartHUDGraphics(void) } // Lap start animation - sprintf(buffer, "K_LAP0x"); + snprintf(buffer, sizeof(buffer), "K_LAP0x"); for (i = 0; i < 7; i++) { buffer[6] = '0'+(i+1); kp_lapanim_lap[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } - sprintf(buffer, "K_LAPFxx"); + snprintf(buffer, sizeof(buffer), "K_LAPFxx"); for (i = 0; i < 11; i++) { buffer[6] = '0'+((i+1)/10); @@ -847,7 +847,7 @@ void K_LoadKartHUDGraphics(void) kp_lapanim_final[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } - sprintf(buffer, "K_LAPNxx"); + snprintf(buffer, sizeof(buffer), "K_LAPNxx"); for (i = 0; i < 10; i++) { buffer[6] = '0'+i; @@ -858,14 +858,14 @@ void K_LoadKartHUDGraphics(void) } } - sprintf(buffer, "K_LAPE0x"); + snprintf(buffer, sizeof(buffer), "K_LAPE0x"); for (i = 0; i < 2; i++) { buffer[7] = '0'+(i+1); kp_lapanim_emblem[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } - sprintf(buffer, "K_LAPH0x"); + snprintf(buffer, sizeof(buffer), "K_LAPH0x"); for (i = 0; i < 3; i++) { buffer[7] = '0'+(i+1); diff --git a/src/lua_script.c b/src/lua_script.c index 4e1cfc995..eb78cd201 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -289,8 +289,7 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump) if (!name) I_Error("LUA_LoadLump: Out of memory!\n"); - sprintf(name, "%s|%s", wadfiles[wad]->filename, lump_p->fullname); - name[len] = '\0'; + snprintf(name, len + 1, "%s|%s", wadfiles[wad]->filename, lump_p->fullname); } LUA_LoadFile(&f, name); // actually load file! diff --git a/src/m_menu.c b/src/m_menu.c index 2d758743d..cabcadf7f 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -616,7 +616,7 @@ void Nextmap_OnChange(void) if (!gpath) return; - sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)); + snprintf(gpath, glen, "%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)); CV_StealthSetValue(&cv_dummystaff, 0); @@ -735,7 +735,7 @@ static void Dummystaff_OnChange(void) while (*temp) temp++; - sprintf(temp, " - %d", cv_dummystaff.value); + snprintf(temp, sizeof(dummystaffname) - (size_t)(temp - dummystaffname), " - %d", cv_dummystaff.value); } } @@ -825,7 +825,8 @@ static void M_ChangeCvar(INT32 choice) float increment; increment = FIXED_TO_FLOAT(cv->value)+(choice)*((currentMenu->menuitems[itemOn].status & IT_CV_BIGFLOAT) ? 0.5f : (1.0f/16.0f)); - sprintf(s,"%ld%s",(long)increment,M_Ftrim(increment)); + snprintf(s, sizeof(s), "%ld%s", (long)increment, M_Ftrim(increment)); + CV_Set(cv, s); } else @@ -4185,12 +4186,12 @@ static void PrepReplayList(boolean reset) if (dirmenu[i][DIR_TYPE] == EXT_UP) { demolist_all[i].type = MD_SUBDIR; - sprintf(demolist_all[i].title, "UP"); + snprintf(demolist_all[i].title, sizeof(demolist_all[i].title), "UP"); } else if (dirmenu[i][DIR_TYPE] == EXT_FOLDER) { demolist_all[i].type = MD_SUBDIR; - strncpy(demolist_all[i].title, dirmenu[i] + DIR_STRING, 64); + snprintf(demolist_all[i].title, sizeof(demolist_all[i].title), "%s", dirmenu[i] + DIR_STRING); } else { @@ -4198,7 +4199,7 @@ static void PrepReplayList(boolean reset) snprintf(demolist_all[i].filepath, sizeof(demolist_all[i].filepath), // 255 = UINT8 limit. dirmenu entries are restricted to this length (see DIR_LEN). "%s%.255s", menupath, dirmenu[i] + DIR_STRING); - sprintf(demolist_all[i].title, "....."); + snprintf(demolist_all[i].title, sizeof(demolist_all[i].title), "....."); } } @@ -5983,7 +5984,8 @@ static void M_DrawStatsMaps(void) V_DrawString(20, 42, highlightflags|MENUCAPS, "Combined time records:"); - sprintf(beststr, "%i:%02i:%02i.%02i", G_TicsToHours(besttime), G_TicsToMinutes(besttime, false), G_TicsToSeconds(besttime), G_TicsToCentiseconds(besttime)); + snprintf(beststr, sizeof(beststr), "%i:%02i:%02i.%02i", G_TicsToHours(besttime), G_TicsToMinutes(besttime, false), G_TicsToSeconds(besttime), G_TicsToCentiseconds(besttime)); + V_DrawRightAlignedString(BASEVIDWIDTH-16, 42, (mapsunfinished ? warningflags : 0), beststr); if (mapsunfinished) @@ -7150,7 +7152,7 @@ static void M_CheckMODVersion(int id) if (updatecheck) { - sprintf(updatestring, UPDATE_ALERT_STRING, VERSIONSTRING, updatecheck); + snprintf(updatestring, sizeof(updatestring), UPDATE_ALERT_STRING, VERSIONSTRING, updatecheck); #ifdef HAVE_THREADS I_lock_mutex(&m_menu_mutex); #endif @@ -9602,11 +9604,13 @@ static void M_ChangecontrolResponse(event_t *ev) menu_t *prev = currentMenu->prevMenu; if (controltochange == gc_pause) - sprintf(tmp, M_GetText("The \x82Pause Key \x80is enabled, but \nyou may select another key. \n\nHit another key for\n%s\nESC for Cancel"), - controltochangetext); + { + snprintf(tmp, sizeof(tmp), M_GetText("The \x82Pause Key \x80is enabled, but \nyou may select another key. \n\nHit another key for\n%s\nESC for Cancel"), controltochangetext); + } else - sprintf(tmp, M_GetText("The \x82Pause Key \x80is enabled, but \nit is not configurable. \n\nHit another key for\n%s\nESC for Cancel"), - controltochangetext); + { + snprintf(tmp, sizeof(tmp), M_GetText("The \x82Pause Key \x80is enabled, but \nit is not configurable. \n\nHit another key for\n%s\nESC for Cancel"), controltochangetext); + } M_StartMessage(tmp, M_ChangecontrolResponse, MM_EVENTHANDLER); currentMenu->prevMenu = prev; @@ -9627,8 +9631,7 @@ static void M_ChangeControl(INT32 choice) static char tmp[68]; controltochange = currentMenu->menuitems[choice].alphaKey; - sprintf(tmp, M_GetText("Hit the new key for\n%s\nESC for Cancel"), - currentMenu->menuitems[choice].text); + snprintf(tmp, sizeof(tmp), M_GetText("Hit the new key for\n%s\nESC for Cancel"), currentMenu->menuitems[choice].text); strlcpy(controltochangetext, currentMenu->menuitems[choice].text, 33); M_StartMessage(tmp, M_ChangecontrolResponse, MM_EVENTHANDLER); diff --git a/src/m_misc.c b/src/m_misc.c index 7fba30790..41dea5517 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1253,7 +1253,6 @@ boolean M_ScreenshotResponder(event_t *ev) return true; } - void M_ScrollString(const char name[], size_t len, char result[], size_t maxlen, tic_t timer) { // How much should we scroll. Not sure why +1 is needed, but without it this function skips 2 @@ -1708,7 +1707,7 @@ const char * M_Ftrim(double f) int i; /* I know I said it's the default, but just in case... */ - sprintf(dig, "%.6f", fabs(modf(f, &f))); + snprintf(dig, sizeof(dig), "%.6f", fabs(modf(f, &f))); /* trim trailing zeroes */ for (i = strlen(dig)-1; dig[i] == '0'; --i) @@ -1814,35 +1813,35 @@ TMatrix *RotateZMatrix(angle_t rad) char *sizeu1(size_t num) { static char sizeu1_buf[28]; - sprintf(sizeu1_buf, "%"PRIdS, num); + snprintf(sizeu1_buf, sizeof(sizeu1_buf), "%" PRIdS, num); return sizeu1_buf; } char *sizeu2(size_t num) { static char sizeu2_buf[28]; - sprintf(sizeu2_buf, "%"PRIdS, num); + snprintf(sizeu2_buf, sizeof(sizeu2_buf), "%" PRIdS, num); return sizeu2_buf; } char *sizeu3(size_t num) { static char sizeu3_buf[28]; - sprintf(sizeu3_buf, "%"PRIdS, num); + snprintf(sizeu3_buf, sizeof(sizeu3_buf), "%" PRIdS, num); return sizeu3_buf; } char *sizeu4(size_t num) { static char sizeu4_buf[28]; - sprintf(sizeu4_buf, "%"PRIdS, num); + snprintf(sizeu4_buf, sizeof(sizeu4_buf), "%" PRIdS, num); return sizeu4_buf; } char *sizeu5(size_t num) { static char sizeu5_buf[28]; - sprintf(sizeu5_buf, "%"PRIdS, num); + snprintf(sizeu5_buf, sizeof(sizeu5_buf), "%" PRIdS, num); return sizeu5_buf; } diff --git a/src/p_setup.c b/src/p_setup.c index c878d35d4..1d9586406 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -180,7 +180,7 @@ FUNCNORETURN static ATTRNORETURN void CorruptMapError(const char *msg) // don't use va() because the calling function probably uses it char mapnum[10]; - sprintf(mapnum, "%hd", gamemap); + snprintf(mapnum, sizeof(mapnum), "%hd", gamemap); CON_LogMessage("Map "); CON_LogMessage(mapnum); CON_LogMessage(" is corrupt: "); @@ -2205,7 +2205,7 @@ void P_SetupLevelSky(INT32 skynum, boolean global) { char skytexname[12]; - sprintf(skytexname, "SKY%d", skynum); + snprintf(skytexname, sizeof(skytexname), "SKY%d", skynum); skytexture = R_TextureNumForName(skytexname); levelskynum = skynum; @@ -2450,23 +2450,26 @@ static void P_ForceCharacter(const char *forcecharskin) if (netgame) { char skincmd[33]; + if (splitscreen) { - sprintf(skincmd, "skin2 %s\n", forcecharskin); + snprintf(skincmd, sizeof(skincmd), "skin2 %s\n", forcecharskin); CV_Set(&cv_skin2, forcecharskin); + if (splitscreen > 1) { - sprintf(skincmd, "skin3 %s\n", forcecharskin); + snprintf(skincmd, sizeof(skincmd), "skin3 %s\n", forcecharskin); CV_Set(&cv_skin3, forcecharskin); + if (splitscreen > 2) { - sprintf(skincmd, "skin4 %s\n", forcecharskin); + snprintf(skincmd, sizeof(skincmd), "skin4 %s\n", forcecharskin); CV_Set(&cv_skin4, forcecharskin); } } } - sprintf(skincmd, "skin %s\n", forcecharskin); + snprintf(skincmd, sizeof(skincmd), "skin %s\n", forcecharskin); COM_BufAddText(skincmd); } else @@ -2523,7 +2526,7 @@ static void P_LoadRecordGhosts(void) const char *mapname = G_BuildMapName(gamemap); - sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, mapname); + snprintf(gpath, glen, "%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, mapname); // Best Time ghost if (cv_ghost_besttime.value) @@ -2879,7 +2882,8 @@ static void P_SetupPlayer(void) if (!demo.playback && multiplayer && D_NumPlayers()) { static char buf[256]; - sprintf(buf, "replay"PATHSEP"online"PATHSEP"%d-%s", (int)(time(NULL)), G_BuildMapName(gamemap)); + + snprintf(buf, sizeof(buf), "replay"PATHSEP"online"PATHSEP"%d-%s", (int)(time(NULL)), G_BuildMapName(gamemap)); I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); I_mkdir(va("%s"PATHSEP"replay"PATHSEP"online", srb2home), 0755); diff --git a/src/p_user.c b/src/p_user.c index 8480b0e60..42b206830 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -625,15 +625,23 @@ boolean P_EndingMusic(player_t *player) } if (G_RaceGametype() && bestlocalpos == MAXPLAYERS+1) - sprintf(buffer, "k*fail"); // F-Zero death results theme + { + snprintf(buffer, sizeof(buffer), "k*fail"); // F-Zero death results theme + } else { if (bestlocalpos == 1) - sprintf(buffer, "k*win"); + { + snprintf(buffer, sizeof(buffer), "k*win"); + } else if (isPlayerLosing(bestlocalplayer)) - sprintf(buffer, "k*lose"); + { + snprintf(buffer, sizeof(buffer), "k*lose"); + } else - sprintf(buffer, "k*ok"); + { + snprintf(buffer, sizeof(buffer), "k*ok"); + } } S_SpeedMusic(1.0f); diff --git a/src/s_sound.c b/src/s_sound.c index 39c671879..a1165cbdf 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -334,7 +334,7 @@ lumpnum_t S_GetSfxLumpNum(sfxinfo_t *sfx) char namebuf[9]; lumpnum_t sfxlump; - sprintf(namebuf, "ds%s", sfx->name); + snprintf(namebuf, sizeof(namebuf), "ds%s", sfx->name); sfxlump = W_CheckNumForName(namebuf); if (sfxlump != LUMPERROR) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 48ba6a21e..a505f7002 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -577,7 +577,7 @@ void I_OutputMsg(const char *fmt, ...) I_Error("I_OutputMsg: Out of memory!\n"); va_start(argptr, fmt); - vsprintf(txt, fmt, argptr); + vsnprintf(txt, len+1, fmt, argptr); va_end(argptr); #ifdef HAVE_TTF @@ -585,7 +585,7 @@ void I_OutputMsg(const char *fmt, ...) DEFAULTFONTBGR, DEFAULTFONTBGG, DEFAULTFONTBGB, DEFAULTFONTBGA, txt); #endif - len = strlen(txt); + len = strnlen(txt, len+1); #ifdef LOGMESSAGES if (logstream) @@ -983,13 +983,13 @@ void I_InitJoystick(UINT8 index) { char dbpath[1024]; - sprintf(dbpath, "%s" PATHSEP "gamecontrollerdb.txt", srb2path); + snprintf(dbpath, sizeof(dbpath), "%s" PATHSEP "gamecontrollerdb.txt", srb2path); SDL_GameControllerAddMappingsFromFile(dbpath); } { char dbpath[1024]; - sprintf(dbpath, "%s" PATHSEP "gamecontrollerdb_user.txt", srb2home); + snprintf(dbpath, sizeof(dbpath), "%s" PATHSEP "gamecontrollerdb_user.txt", srb2home); SDL_GameControllerAddMappingsFromFile(dbpath); } @@ -1151,8 +1151,7 @@ const char *I_GetJoyName(INT32 joyindex) if (tempname) { - memcpy(joyname, tempname, 255); - joyname[255] = '\0'; + snprintf(joyname, sizeof(joyname), "%s", tempname); } } @@ -1697,16 +1696,20 @@ static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_ms if (core_dumped) { if (sigmsg) - sprintf(signal_msg, "%s (core dumped)", sigmsg); + { + snprintf(signal_msg, 512, "%s (core dumped)", sigmsg); + } else + { strcat(signal_msg, " (core dumped)"); + } } else { - sprintf(signal_msg, "%s", sigmsg); + snprintf(signal_msg, 512, "%s", sigmsg); } - sprintf(signal_name, "%s", signame); + snprintf(signal_name, 128, "%s", signame); } int I_OpenURL(const char *url) @@ -2341,7 +2344,8 @@ char *I_GetUserName(void) } } } - strncpy(username, p, MAXPLAYERNAME); + + snprintf(username, sizeof(username), "%s", p); } if (!fastcmp(username, "")) @@ -2386,13 +2390,15 @@ INT32 I_PutEnv(char *variable) INT32 I_ClipboardCopy(const char *data, size_t size) { char storage[256]; + if (size > 255) size = 255; - memcpy(storage, data, size); - storage[size] = 0; + + snprintf(storage, sizeof(storage), "%.*s", (int)size, data); if (SDL_SetClipboardText(storage)) return 0; + return -1; } @@ -2405,7 +2411,7 @@ const char *I_ClipboardPaste(void) return NULL; clipboard_contents = SDL_GetClipboardText(); - strlcpy(clipboard_modified, clipboard_contents, 256); + snprintf(clipboard_modified, sizeof(clipboard_modified), "%s", clipboard_contents); SDL_free(clipboard_contents); while (*i) @@ -2434,28 +2440,23 @@ const char *I_ClipboardPaste(void) */ static boolean isWadPathOk(const char *path) { - char *wad3path = static_cast(malloc(256)); + char wad3path[256]; - if (!wad3path) - return false; - - sprintf(wad3path, pandf, path, WADKEYWORD); + snprintf(wad3path, sizeof(wad3path), pandf, path, WADKEYWORD); if (FIL_ReadFileOK(wad3path)) { - free(wad3path); return true; } - free(wad3path); return false; } -static void pathonly(char *s) +static void pathonly(char *s, size_t size) { size_t j; - for (j = strlen(s); j != (size_t)-1; j--) + for (j = strnlen(s, size); j != (size_t)-1; j--) { if ((s[j] == '\\') || (s[j] == ':') || (s[j] == '/')) { @@ -2482,11 +2483,12 @@ static const char *searchWad(const char *searchDir) static char tempsw[256] = ""; filestatus_t fstemp; - strcpy(tempsw, WADKEYWORD); + snprintf(tempsw, sizeof(tempsw), "%s", WADKEYWORD); fstemp = filesearch(tempsw, searchDir, NULL, true, 20); + if (fstemp == FS_FOUND) { - pathonly(tempsw); + pathonly(tempsw, sizeof(tempsw)); return tempsw; } @@ -2524,7 +2526,7 @@ static const char *locateWad(void) #ifndef NOCWD // examine current dir - strcpy(returnWadPath, "."); + snprintf(returnWadPath, sizeof(returnWadPath), "%s", "."); I_OutputMsg(",%s", returnWadPath); if (isWadPathOk(returnWadPath)) return NULL; @@ -2536,7 +2538,7 @@ static const char *locateWad(void) // examine user jart directory if ((envstr = I_GetEnv("HOME")) != NULL) { - sprintf(returnWadPath, "%s" PATHSEP DEFAULTDIR, envstr); + snprintf(returnWadPath, sizeof(returnWadPath), "%s" PATHSEP DEFAULTDIR, envstr); CHECKWADPATH(returnWadPath); } #endif @@ -2550,7 +2552,7 @@ static const char *locateWad(void) // examine default dirs for (i = 0; wadDefaultPaths[i]; i++) { - strcpy(returnWadPath, wadDefaultPaths[i]); + snprintf(returnWadPath, sizeof(returnWadPath), "%s", wadDefaultPaths[i]); CHECKWADPATH(returnWadPath); } diff --git a/src/sdl/i_ttf.c b/src/sdl/i_ttf.c index f2cd497ee..fcba5ec46 100644 --- a/src/sdl/i_ttf.c +++ b/src/sdl/i_ttf.c @@ -183,13 +183,17 @@ void I_TTFDrawText(TTF_Font *font, TextQuality quality, INT32 fgR, INT32 fgG, IN TTFRect.x = TTFRectCheck.x; TTFRect.y = TTFRectCheck.y; } + // Copy the character to the text buffer. - sprintf(textbuffer, "%s%c", textbuffer, c); + snprintf(textbuffer, sizeof(textbuffer), "%s%c", textbuffer, c); + // Hack to allow TTF_SizeText to work properly. - sprintf(linebuffer, "%c", c); + snprintf(linebuffer, sizeof(linebuffer), "%c", c); + // If we have reached the end of the screen, move to the next available line. TTF_SizeText(currentfont, linebuffer, &w, &h); TTFRectCheck.x += w; + if (TTFRectCheck.x >= res.width) { // Render cached text to the SDL surface. @@ -204,8 +208,10 @@ void I_TTFDrawText(TTF_Font *font, TextQuality quality, INT32 fgR, INT32 fgG, IN TTFRect.y = TTFRectCheck.y; } } + // Add 1 to the pointer reference for the character to process. textmsg++; + // Copy contents of the now-old buffer to somewhere else, so it can be referenced in next loop. prevc = c; } diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index be67b69eb..420326043 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -868,7 +868,7 @@ boolean I_SetSongSpeed(float speed) { // deprecated in 0.5.0 char modspd[13]; - sprintf(modspd, "%g", speed); + snprintf(modspd, sizeof(modspd), "%g", speed); openmpt_module_ctl_set(openmpt_mhandle, "play.tempo_factor", modspd); } #else diff --git a/src/st_stuff.c b/src/st_stuff.c index c8bdd5d51..bc7f9e3e3 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -591,7 +591,7 @@ static void ST_overlayDrawer(void) char name[MAXPLAYERNAME+12]; INT32 y = (stplyrnum == 0) ? 4 : BASEVIDHEIGHT/2-12; - sprintf(name, "VIEWPOINT: %s", player_names[stplyr-players]); + snprintf(name, sizeof(name), "VIEWPOINT: %s", player_names[stplyr-players]); V_DrawRightAlignedThinString(BASEVIDWIDTH-40, y, V_HUDTRANSHALF|V_ALLOWLOWERCASE|K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOBOTTOM|V_SNAPTORIGHT), name); } else if (splitscreen) diff --git a/src/w_wad.c b/src/w_wad.c index a8bdc0f9b..5d0771dc3 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -292,8 +292,7 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) if (!name) I_Error("W_LoadDehackedLumpsPK3: Out of memory!\n"); - sprintf(name, "%s|%s", wadfiles[wadnum]->filename, lump_p->fullname); - name[length] = '\0'; + snprintf(name, length + 1, "%s|%s", wadfiles[wadnum]->filename, lump_p->fullname); CONS_Printf("Loading SOC from %s\n", name); DEH_LoadDehackedLumpPwad(wadnum, posStart); free(name); @@ -328,8 +327,7 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) if (!name) I_Error("W_LoadDehackedLumps: Out of memory!\n"); - sprintf(name, "%s|%s", wadfiles[wadnum]->filename, lump_p->fullname); - name[length] = '\0'; + snprintf(name, length + 1, "%s|%s", wadfiles[wadnum]->filename, lump_p->fullname); CONS_Printf(M_GetText("Loading SOC from %s\n"), name); DEH_LoadDehackedLumpPwad(wadnum, lump); diff --git a/src/win32/win_dbg.c b/src/win32/win_dbg.c index d47117698..067936be9 100644 --- a/src/win32/win_dbg.c +++ b/src/win32/win_dbg.c @@ -118,7 +118,7 @@ static VOID FPrintf(HANDLE fileHandle, LPCSTR lpFmt, ...) DWORD bytesWritten; va_start(arglist, lpFmt); - vsnprintf(str, 1999, lpFmt, arglist); + vsnprintf(str, sizeof(str), lpFmt, arglist); va_end(arglist); WriteFile(fileHandle, str, (DWORD)strlen(str), &bytesWritten, NULL); diff --git a/src/y_inter.c b/src/y_inter.c index a92392f39..bcb6a649e 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -153,7 +153,7 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) ; else if ((data.rankingsmode = (boolean)rankingsmode)) { - sprintf(data.levelstring, "* Total Rankings *"); + snprintf(data.levelstring, sizeof(data.levelstring), "* Total Rankings *"); data.encore = false; } else @@ -162,32 +162,41 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) if (mapheaderinfo[prevmap]->levelflags & LF_NOZONE) { if (mapheaderinfo[prevmap]->actnum[0]) + { snprintf(data.levelstring, - sizeof data.levelstring, + sizeof(data.levelstring), "* %s %s *", mapheaderinfo[prevmap]->lvlttl, mapheaderinfo[prevmap]->actnum); + } else + { snprintf(data.levelstring, - sizeof data.levelstring, + sizeof(data.levelstring), "* %s *", mapheaderinfo[prevmap]->lvlttl); + } } else { const char *zonttl = (mapheaderinfo[prevmap]->zonttl[0] ? mapheaderinfo[prevmap]->zonttl : "Zone"); + if (mapheaderinfo[prevmap]->actnum[0]) + { snprintf(data.levelstring, - sizeof data.levelstring, + sizeof(data.levelstring), "* %s %s %s *", mapheaderinfo[prevmap]->lvlttl, zonttl, mapheaderinfo[prevmap]->actnum); + } else + { snprintf(data.levelstring, - sizeof data.levelstring, + sizeof(data.levelstring), "* %s %s *", mapheaderinfo[prevmap]->lvlttl, zonttl); + } } - data.levelstring[sizeof data.levelstring - 1] = '\0'; + data.levelstring[sizeof(data.levelstring) - 1] = '\0'; data.encore = encoremode; @@ -652,7 +661,8 @@ static void Y_UpdateRecordReplays(void) if ((gpath = malloc(glen)) == NULL) I_Error("Out of memory for replay filepath\n"); - sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); + snprintf(gpath, glen, "%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); + snprintf(lastdemo, 255, "%s-%s-last.lmp", gpath, cv_chooseskin.string); if (FIL_FileExists(lastdemo)) From df291710d81429b9b9f9ce19078dbbc50e4defae Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 9 Aug 2026 17:49:23 +0200 Subject: [PATCH 564/589] replace a few more length magic numbers with sizeof just to be sure really --- src/d_netcmd.c | 4 ++-- src/dedicated/i_system.c | 6 +++--- src/g_demo.c | 41 ++++++++++++++++++++-------------------- src/g_game.c | 4 ++-- src/k_hud.c | 2 +- src/lua_script.c | 6 +++--- src/m_misc.c | 20 +++++++++++--------- src/p_setup.c | 6 +++--- src/s_sound.c | 2 +- src/sdl/i_system.cpp | 8 ++++---- src/y_inter.c | 24 +++++++++++------------ 11 files changed, 62 insertions(+), 61 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index cd8dba956..24d01bef1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2762,11 +2762,11 @@ static void Command_ReplayMarker(void) if (title) { - snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + snprintf(demo.titlename, sizeof(demo.titlename), "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); Z_Free(title); } else - snprintf(demo.titlename, 64, "[%i:%02d/%.5s]", G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + snprintf(demo.titlename, sizeof(demo.titlename), "[%i:%02d/%.5s]", G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); CONS_Printf("Replay will be saved!\n"); } diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index c5ae3b451..e37b9502b 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1348,7 +1348,7 @@ FUNCNORETURN static ATTRNORETURN void newsignalhandler_Warn(const char *pr) { char text[128]; - snprintf(text, sizeof text, + snprintf(text, sizeof(text), "Error while setting up signal reporting: %s: %s", pr, strerror(errno) @@ -1534,7 +1534,7 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) if (errorcount > 20) { va_start(argptr, error); - vsnprintf(buffer, 8192, error, argptr); + vsnprintf(buffer, sizeof(buffer), error, argptr); va_end(argptr); I_OutputMsg("SRB2Kart %s Recursive Error", buffer); @@ -1547,7 +1547,7 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) // Display error message in the console before we start shutting it down va_start(argptr, error); - vsnprintf(buffer, 8192, error, argptr); + vsnprintf(buffer, sizeof(buffer), error, argptr); va_end(argptr); I_OutputMsg("\nI_Error(): %s\n", buffer); diff --git a/src/g_demo.c b/src/g_demo.c index b86bbc8f8..cb24999e6 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1723,11 +1723,11 @@ void G_BeginRecording(void) // Print to a separate temp buffer instead of demo.titlename, so we can use it in M_TextInputSetString if (title) { - snprintf(demotitlename, 64, "%s - %s", title, modeattacking ? "Time Attack" : connectedservername); + snprintf(demotitlename, sizeof(demotitlename), "%s - %s", title, modeattacking ? "Time Attack" : connectedservername); Z_Free(title); } else - snprintf(demotitlename, 64, "%s", modeattacking ? "Time Attack" : connectedservername); + snprintf(demotitlename, sizeof(demotitlename), "%s", modeattacking ? "Time Attack" : connectedservername); // Init just in case it isn't initialized already M_TextInputInit(&demo.titlenameinput, demo.titlename, sizeof(demo.titlename)); @@ -2213,7 +2213,6 @@ void G_LoadDemoInfo(menudemo_t *pdemo) CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), pdemo->filepath); pdemo->type = MD_INVALID; snprintf(pdemo->title, sizeof(pdemo->title), "INVALID REPLAY"); - return; } @@ -2634,7 +2633,7 @@ void G_DoPlayDemo(char *defdemoname) //FIL_DefaultExtension(defdemoname, ".lmp"); if (!FIL_ReadFile(defdemoname, &demobuf.buffer)) { - snprintf(msg, 1024, M_GetText("Failed to read file '%s'.\n"), defdemoname); + snprintf(msg, sizeof(msg), M_GetText("Failed to read file '%s'.\n"), defdemoname); CONS_Alert(CONS_ERROR, "%s", msg); gameaction = ga_nothing; M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); @@ -2646,7 +2645,7 @@ void G_DoPlayDemo(char *defdemoname) // load demo resource from WAD else if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR) { - snprintf(msg, 1024, M_GetText("Failed to read lump '%s'.\n"), defdemoname); + snprintf(msg, sizeof(msg), M_GetText("Failed to read lump '%s'.\n"), defdemoname); CONS_Alert(CONS_ERROR, "%s", msg); gameaction = ga_nothing; M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); @@ -2667,7 +2666,7 @@ void G_DoPlayDemo(char *defdemoname) if (memcmp(demobuf.p, DEMOHEADER, 12)) { - snprintf(msg, 1024, M_GetText("%s is not a SRB2Kart replay file.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s is not a SRB2Kart replay file.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2693,7 +2692,7 @@ void G_DoPlayDemo(char *defdemoname) #endif // too old, cannot support. default: - snprintf(msg, 1024, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2704,7 +2703,7 @@ void G_DoPlayDemo(char *defdemoname) if (memcmp(demobuf.p, "PLAY", 4)) { - snprintf(msg, 1024, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2721,7 +2720,7 @@ void G_DoPlayDemo(char *defdemoname) { if (demoflags & DF_MULTIPLAYER) { - snprintf(msg, 1024, M_GetText("%s is an alpha multiplayer replay and cannot be played.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s is an alpha multiplayer replay and cannot be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2748,31 +2747,31 @@ void G_DoPlayDemo(char *defdemoname) switch (error) { case DFILE_ERROR_NOTLOADED: - snprintf(msg, 1024, + snprintf(msg, sizeof(msg), "Required files for this demo are not loaded.\n\nUse\n\"playdemo %s -addfiles\"\nto load them and play the demo.\n", pdemoname); break; case DFILE_ERROR_OUTOFORDER: - snprintf(msg, 1024, + snprintf(msg, sizeof(msg), "Required files for this demo are loaded out of order.\n\nUse\n\"playdemo %s -force\"\nto play the demo anyway.\n", pdemoname); break; case DFILE_ERROR_INCOMPLETEOUTOFORDER: - snprintf(msg, 1024, + snprintf(msg, sizeof(msg), "Required files for this demo are not loaded, and some are out of order.\n\nUse\n\"playdemo %s -addfiles\"\nto load needed files and play the demo.\n", pdemoname); break; case DFILE_ERROR_CANNOTLOAD: - snprintf(msg, 1024, + snprintf(msg, sizeof(msg), "Required files for this demo cannot be loaded.\n\nUse\n\"playdemo %s -force\"\nto play the demo anyway.\n", pdemoname); break; case DFILE_ERROR_EXTRAFILES: - snprintf(msg, 1024, + snprintf(msg, sizeof(msg), "You have additional files loaded beyond the demo's file list.\n\nUse\n\"playdemo %s -force\"\nto play the demo anyway.\n", pdemoname); break; @@ -2822,7 +2821,7 @@ void G_DoPlayDemo(char *defdemoname) // ...*map* not loaded? if (!gamemap || (gamemap > NUMMAPS) || (W_CheckNumForName(G_BuildMapName(gamemap)) == LUMPERROR)) { - snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2854,7 +2853,7 @@ void G_DoPlayDemo(char *defdemoname) // Skin not loaded? if (!SetPlayerSkin(0, skin)) { - snprintf(msg, 1024, M_GetText("%s features a character that is not currently loaded.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s features a character that is not currently loaded.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2864,7 +2863,7 @@ void G_DoPlayDemo(char *defdemoname) // ...*map* not loaded? if (!gamemap || (gamemap > NUMMAPS) || !mapheaderinfo[gamemap-1] || !(mapheaderinfo[gamemap-1]->menuflags & LF2_EXISTSHACK)) { - snprintf(msg, 1024, M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s features a course that is not currently loaded.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2887,7 +2886,7 @@ void G_DoPlayDemo(char *defdemoname) // Sigh ... it's an empty demo. if (*demobuf.p == DEMOMARKER) { - snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s contains no data to be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2925,7 +2924,7 @@ void G_DoPlayDemo(char *defdemoname) // Sigh ... it's an empty demo. if (*demobuf.p == DEMOMARKER) { - snprintf(msg, 1024, M_GetText("%s contains no data to be played.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s contains no data to be played.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2974,7 +2973,7 @@ void G_DoPlayDemo(char *defdemoname) if (modeattacking) { - snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with spectators, and is thus invalid.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s is a Record Attack replay with spectators, and is thus invalid.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); @@ -2986,7 +2985,7 @@ void G_DoPlayDemo(char *defdemoname) if (modeattacking && numslots > 1) { - snprintf(msg, 1024, M_GetText("%s is a Record Attack replay with multiple players, and is thus invalid.\n"), pdemoname); + snprintf(msg, sizeof(msg), M_GetText("%s is a Record Attack replay with multiple players, and is thus invalid.\n"), pdemoname); CONS_Alert(CONS_ERROR, "%s", msg); M_StartMessage(msg, M_ReturnToTitleFromError, MM_EVENTHANDLER); G_ResetDemoPlayback(); diff --git a/src/g_game.c b/src/g_game.c index c2b6499f9..9cc58d19e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3849,7 +3849,7 @@ void G_SaveGame(UINT32 savegameslot) savebuffer_t save = {}; snprintf(savename, sizeof(savename), savegamename, savegameslot); - backup = va("%s",savename); + backup = va("%s", savename); // save during evaluation or credits? game's over, folks! if (gamestate == GS_CREDITS || gamestate == GS_EVALUATION) @@ -3867,7 +3867,7 @@ void G_SaveGame(UINT32 savegameslot) return; } - memset(name, 0, sizeof (name)); + memset(name, 0, sizeof(name)); snprintf(name, sizeof(name), "version %d", VERSION); WRITEMEM(save.p, name, VERSIONSIZE); diff --git a/src/k_hud.c b/src/k_hud.c index 71bd018c0..545cd957a 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1974,7 +1974,7 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI goto bademblem; } - snprintf(targettext, 9, "%i'%02i\"%02i", + snprintf(targettext, sizeof(targettext), "%i'%02i\"%02i", G_TicsToMinutes(timetoreach, false), G_TicsToSeconds(timetoreach), G_TicsToCentiseconds(timetoreach)); diff --git a/src/lua_script.c b/src/lua_script.c index eb78cd201..0943eef68 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -277,14 +277,14 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump) if (wadfiles[wad]->type == RET_LUA) { - name = malloc(len+1); - strcpy(name, wadfiles[wad]->filename); + name = malloc(len + 1); + snprintf(name, len + 1, "%s", wadfiles[wad]->filename); } else // If it's not a .lua file, copy the lump name in too. { lumpinfo_t *lump_p = &wadfiles[wad]->lumpinfo[lump]; len += 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name - name = malloc(len+1); + name = malloc(len + 1); if (!name) I_Error("LUA_LoadLump: Out of memory!\n"); diff --git a/src/m_misc.c b/src/m_misc.c index 41dea5517..a8dc0269d 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -515,8 +515,8 @@ static boolean M_BackupConfig(const char *filename) { char backupfile[MAX_WADPATH+4]; - snprintf(backupfile, sizeof backupfile, "%s.bak", filename); - backupfile[sizeof backupfile - 1] = '\0'; + snprintf(backupfile, sizeof(backupfile), "%s.bak", filename); + backupfile[sizeof(backupfile) - 1] = '\0'; FILE *config = fopen(filename, "r"); @@ -766,27 +766,27 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png } if (gamestate == GS_LEVEL) - snprintf(maptext, 8, "%s", G_BuildMapName(gamemap)); + snprintf(maptext, sizeof(maptext), "%s", G_BuildMapName(gamemap)); else - snprintf(maptext, 8, "Unknown"); + snprintf(maptext, sizeof(maptext), "Unknown"); if (gamestate == GS_LEVEL && mapheaderinfo[gamemap-1]->lvlttl[0] != '\0') - snprintf(lvlttltext, 48, "%s%s%s", + snprintf(lvlttltext, sizeof(lvlttltext), "%s%s%s", mapheaderinfo[gamemap-1]->lvlttl, (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart ((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " ZONE"), (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->actnum) : ""); else - snprintf(lvlttltext, 48, "Unknown"); + snprintf(lvlttltext, sizeof(lvlttltext), "Unknown"); if (gamestate == GS_LEVEL && players[displayplayers[0]].mo) - snprintf(locationtxt, 40, "X:%d Y:%d Z:%d A:%d", + snprintf(locationtxt, sizeof(locationtxt), "X:%d Y:%d Z:%d A:%d", players[displayplayers[0]].mo->x>>FRACBITS, players[displayplayers[0]].mo->y>>FRACBITS, players[displayplayers[0]].mo->z>>FRACBITS, FixedInt(AngleFixed(players[displayplayers[0]].mo->angle))); else - snprintf(locationtxt, 40, "Unknown"); + snprintf(locationtxt, sizeof(locationtxt), "Unknown"); memset(png_infotext, 0x00, sizeof(png_infotext)); @@ -1393,7 +1393,7 @@ char *va(const char *format, ...) static char string[1024]; va_start(argptr, format); - vsnprintf(string, 1024, format, argptr); + vsnprintf(string, sizeof(string), format, argptr); va_end(argptr); return string; @@ -1735,6 +1735,7 @@ UINT8 M_CountBits(UINT32 num, UINT8 size) const char *GetRevisionString(void) { static char rev[9] = {0}; + if (rev[0]) return rev; @@ -1742,6 +1743,7 @@ const char *GetRevisionString(void) strncpy(rev, comprevision, 7); else snprintf(rev, 7, "r%s", comprevision); + rev[7] = '\0'; return rev; diff --git a/src/p_setup.c b/src/p_setup.c index 1d9586406..17a0b9d77 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -266,8 +266,8 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->actnum[0] = '\0'; mapheaderinfo[num]->typeoflevel = 0; mapheaderinfo[num]->nextlevel = (INT16)(i + 1); - snprintf(mapheaderinfo[num]->musname, 7, "%sM", G_BuildMapName(i)); - mapheaderinfo[num]->musname[6] = 0; + snprintf(mapheaderinfo[num]->musname, sizeof(mapheaderinfo[num]->musname), "%sM", G_BuildMapName(i)); + mapheaderinfo[num]->musname[sizeof(mapheaderinfo[num]->musname)-1] = 0; mapheaderinfo[num]->mustrack = 0; mapheaderinfo[num]->muspos = 0; mapheaderinfo[num]->forcecharacter[0] = '\0'; @@ -3065,7 +3065,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // Don't include these in the fade! char tx[64]; V_DrawSmallString(1, 191, V_ALLOWLOWERCASE, M_GetText("Speeding off to...")); - snprintf(tx, 63, "%s%s%s", + snprintf(tx, sizeof(tx), "%s%s%s", mapheader->lvlttl, (strlen(mapheader->zonttl) > 0) ? va(" %s",mapheader->zonttl) : // SRB2kart ((mapheader->levelflags & LF_NOZONE) ? "" : " Zone"), diff --git a/src/s_sound.c b/src/s_sound.c index a1165cbdf..d7f4a2853 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2193,7 +2193,7 @@ static void Command_Tunes_f(void) track = (UINT16)atoi(COM_Argv(2))-1; if (tunenum) - snprintf(mapmusic.name, 7, "%sM", G_BuildMapName(tunenum)); + snprintf(mapmusic.name, sizeof(mapmusic.name), "%sM", G_BuildMapName(tunenum)); else strlcpy(mapmusic.name, tunearg, sizeof(mapmusic.name)); diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index a505f7002..ae009928b 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1278,7 +1278,7 @@ static void I_SetupMumble(void) int shmfd; char memname[256]; - snprintf(memname, 256, "/MumbleLink.%d", getuid()); + snprintf(memname, sizeof(memname), "/MumbleLink.%d", getuid()); shmfd = shm_open(memname, O_RDWR, S_IRUSR | S_IWUSR); if (shmfd < 0) @@ -1887,7 +1887,7 @@ FUNCNORETURN static ATTRNORETURN void newsignalhandler_Warn(const char *pr) { char text[128]; - snprintf(text, sizeof text, + snprintf(text, sizeof(text), "Error while setting up signal reporting: %s: %s", pr, strerror(errno) @@ -2103,7 +2103,7 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) if (errorcount > 20) { va_start(argptr, error); - vsnprintf(buffer, 8192, error, argptr); + vsnprintf(buffer, sizeof(buffer), error, argptr); va_end(argptr); sigttl = "SRB2Kart " VERSIONSTRING " Recursive Error"; @@ -2117,7 +2117,7 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) // Display error message in the console before we start shutting it down va_start(argptr, error); - vsnprintf(buffer, 8192, error, argptr); + vsnprintf(buffer, sizeof(buffer), error, argptr); va_end(argptr); I_OutputMsg("\nI_Error(): %s\n", buffer); diff --git a/src/y_inter.c b/src/y_inter.c index bcb6a649e..4ea042aa7 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -369,9 +369,9 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) if (standings->increase[pnum] != UINT8_MAX) { if (standings->increase[pnum] > 9) - snprintf(strtime, sizeof strtime, "(+%02d)", standings->increase[pnum]); + snprintf(strtime, sizeof(strtime), "(+%02d)", standings->increase[pnum]); else - snprintf(strtime, sizeof strtime, "(+ %d)", standings->increase[pnum]); + snprintf(strtime, sizeof(strtime), "(+ %d)", standings->increase[pnum]); if (standings->numplayers > NUMFORNEWCOLUMN) V_DrawRightAlignedThinString(x+135+gutter, y-1, V_6WIDTHSPACE, strtime); @@ -379,7 +379,7 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) V_DrawRightAlignedString(x+120+gutter, y, 0, strtime); } - snprintf(strtime, sizeof strtime, "%d", standings->val[i]); + snprintf(strtime, sizeof(strtime), "%d", standings->val[i]); if (standings->numplayers > NUMFORNEWCOLUMN) V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, strtime); @@ -394,9 +394,9 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) { if (intertype == int_race) { - snprintf(strtime, sizeof strtime, "%i'%02i\"%02i", G_TicsToMinutes(standings->val[i], true), + snprintf(strtime, sizeof(strtime), "%i'%02i\"%02i", G_TicsToMinutes(standings->val[i], true), G_TicsToSeconds(standings->val[i]), G_TicsToCentiseconds(standings->val[i])); - strtime[sizeof strtime - 1] = '\0'; + strtime[sizeof(strtime) - 1] = '\0'; if (standings->numplayers > NUMFORNEWCOLUMN) V_DrawRightAlignedThinString(x+152+gutter, y-1, V_6WIDTHSPACE, strtime); @@ -663,14 +663,14 @@ static void Y_UpdateRecordReplays(void) snprintf(gpath, glen, "%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); - snprintf(lastdemo, 255, "%s-%s-last.lmp", gpath, cv_chooseskin.string); + snprintf(lastdemo, sizeof(lastdemo), "%s-%s-last.lmp", gpath, cv_chooseskin.string); if (FIL_FileExists(lastdemo)) { UINT8 *buf; size_t len = FIL_ReadFile(lastdemo, &buf); - snprintf(bestdemo, 255, "%s-%s-time-best.lmp", gpath, cv_chooseskin.string); + snprintf(bestdemo, sizeof(bestdemo), "%s-%s-time-best.lmp", gpath, cv_chooseskin.string); if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & 1) { // Better time, save this demo. if (FIL_FileExists(bestdemo)) @@ -679,7 +679,7 @@ static void Y_UpdateRecordReplays(void) CONS_Printf("\x83%s\x80 %s '%s'\n", M_GetText("NEW RECORD TIME!"), M_GetText("Saved replay as"), bestdemo); } - snprintf(bestdemo, 255, "%s-%s-lap-best.lmp", gpath, cv_chooseskin.string); + snprintf(bestdemo, sizeof(bestdemo), "%s-%s-lap-best.lmp", gpath, cv_chooseskin.string); if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & (1<<1)) { // Better lap time, save this demo. if (FIL_FileExists(bestdemo)) @@ -1509,12 +1509,12 @@ void Y_StartVote(void) { if (mapheaderinfo[votelevels[i][0]]->actnum[0]) snprintf(levelinfo[i].str, - sizeof levelinfo[i].str, + sizeof(levelinfo[i].str), "%s %s", mapheaderinfo[votelevels[i][0]]->lvlttl, mapheaderinfo[votelevels[i][0]]->actnum); else snprintf(levelinfo[i].str, - sizeof levelinfo[i].str, + sizeof(levelinfo[i].str), "%s", mapheaderinfo[votelevels[i][0]]->lvlttl); } @@ -1522,12 +1522,12 @@ void Y_StartVote(void) { if (mapheaderinfo[votelevels[i][0]]->actnum[0]) snprintf(levelinfo[i].str, - sizeof levelinfo[i].str, + sizeof(levelinfo[i].str), "%s %s %s", mapheaderinfo[votelevels[i][0]]->lvlttl, mapheaderinfo[votelevels[i][0]]->zonttl, mapheaderinfo[votelevels[i][0]]->actnum); else snprintf(levelinfo[i].str, - sizeof levelinfo[i].str, + sizeof(levelinfo[i].str), "%s %s", mapheaderinfo[votelevels[i][0]]->lvlttl, mapheaderinfo[votelevels[i][0]]->zonttl); } From eeb7d48a6ff6c496ae46fd41618b8145fa64dd1f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 9 Aug 2026 17:51:39 +0200 Subject: [PATCH 565/589] one more snprintf replacement for next branch --- src/sdl/i_video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index c6554c2b9..ae9b61446 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1538,9 +1538,9 @@ const char *VID_GetModeName(INT32 modeNum) if (modeNum > MAXWINMODES) return NULL; - sprintf(&vidModeName[modeNum][0], "%dx%d", - windowedModes[modeNum][0], - windowedModes[modeNum][1]); + snprintf(&vidModeName[modeNum][0], sizeof(vidModeName[modeNum]), "%dx%d", + windowedModes[modeNum][0], + windowedModes[modeNum][1]); return &vidModeName[modeNum][0]; } From e0fa53e4dfe4d919bc3d887b3553672e72d8dc5b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 9 Aug 2026 17:57:18 +0200 Subject: [PATCH 566/589] demonames apparently should write one less character better keep it like this --- src/d_netcmd.c | 4 ++-- src/g_demo.c | 4 ++-- src/y_inter.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 24d01bef1..f05668c8f 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2762,11 +2762,11 @@ static void Command_ReplayMarker(void) if (title) { - snprintf(demo.titlename, sizeof(demo.titlename), "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + snprintf(demo.titlename, sizeof(demo.titlename)-1, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); Z_Free(title); } else - snprintf(demo.titlename, sizeof(demo.titlename), "[%i:%02d/%.5s]", G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); + snprintf(demo.titlename, sizeof(demo.titlename)-1, "[%i:%02d/%.5s]", G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); CONS_Printf("Replay will be saved!\n"); } diff --git a/src/g_demo.c b/src/g_demo.c index cb24999e6..049cf4bfd 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1723,11 +1723,11 @@ void G_BeginRecording(void) // Print to a separate temp buffer instead of demo.titlename, so we can use it in M_TextInputSetString if (title) { - snprintf(demotitlename, sizeof(demotitlename), "%s - %s", title, modeattacking ? "Time Attack" : connectedservername); + snprintf(demotitlename, sizeof(demotitlename)-1, "%s - %s", title, modeattacking ? "Time Attack" : connectedservername); Z_Free(title); } else - snprintf(demotitlename, sizeof(demotitlename), "%s", modeattacking ? "Time Attack" : connectedservername); + snprintf(demotitlename, sizeof(demotitlename)-1, "%s", modeattacking ? "Time Attack" : connectedservername); // Init just in case it isn't initialized already M_TextInputInit(&demo.titlenameinput, demo.titlename, sizeof(demo.titlename)); diff --git a/src/y_inter.c b/src/y_inter.c index 4ea042aa7..97df280c5 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -663,14 +663,14 @@ static void Y_UpdateRecordReplays(void) snprintf(gpath, glen, "%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); - snprintf(lastdemo, sizeof(lastdemo), "%s-%s-last.lmp", gpath, cv_chooseskin.string); + snprintf(lastdemo, sizeof(lastdemo)-1, "%s-%s-last.lmp", gpath, cv_chooseskin.string); if (FIL_FileExists(lastdemo)) { UINT8 *buf; size_t len = FIL_ReadFile(lastdemo, &buf); - snprintf(bestdemo, sizeof(bestdemo), "%s-%s-time-best.lmp", gpath, cv_chooseskin.string); + snprintf(bestdemo, sizeof(bestdemo)-1, "%s-%s-time-best.lmp", gpath, cv_chooseskin.string); if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & 1) { // Better time, save this demo. if (FIL_FileExists(bestdemo)) @@ -679,7 +679,7 @@ static void Y_UpdateRecordReplays(void) CONS_Printf("\x83%s\x80 %s '%s'\n", M_GetText("NEW RECORD TIME!"), M_GetText("Saved replay as"), bestdemo); } - snprintf(bestdemo, sizeof(bestdemo), "%s-%s-lap-best.lmp", gpath, cv_chooseskin.string); + snprintf(bestdemo, sizeof(bestdemo)-1, "%s-%s-lap-best.lmp", gpath, cv_chooseskin.string); if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & (1<<1)) { // Better lap time, save this demo. if (FIL_FileExists(bestdemo)) From 924f9c21510268632e4f106f028226ed4aa0af06 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 10 Aug 2026 15:35:39 +0200 Subject: [PATCH 567/589] put directory changing and getting stuff into functions from https://gitlab.com/kart-krew-dev/ring-racers/-/commit/7ef40f5d743bf6bf251e2edc89cda23e8fb36ee5 changed a bit so windows also can print the "warning" on failure --- src/d_main.c | 2 +- src/dedicated/i_system.c | 23 ++++++++++++++++++++--- src/i_system.h | 15 +++++++++++++++ src/sdl/i_system.cpp | 28 +++++++++++++++++++++++++--- 4 files changed, 61 insertions(+), 7 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 8a7170ce2..a3a769dac 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1245,7 +1245,7 @@ static void IdentifyVersion(void) #endif char tempsrb2path[256] = "."; - if (getcwd(tempsrb2path, 256) == NULL) + if (I_GetCwd(tempsrb2path, 256) == NULL) strcpy(tempsrb2path, "."); // get the current directory (possible problem on NT with "." as current dir) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index e37b9502b..70e7ea86c 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1793,6 +1793,24 @@ INT32 I_mkdir(const char *dirname, INT32 unixright) #endif } +INT32 I_ChDir(const char *path) +{ +#ifdef _WIN32 + return (SetCurrentDirectoryA(path) ? 0 : -1); +#else + return chdir(path); +#endif +} + +char *I_GetCwd(char *buf, size_t size) +{ +#ifdef _WIN32 + return (GetCurrentDirectoryA((DWORD)size, buf) ? buf : NULL); +#else + return getcwd(buf, size); +#endif +} + char *I_GetEnv(const char *name) { return getenv(name); @@ -1965,12 +1983,11 @@ const char *I_LocateWad(void) // change to the directory where we found srb2.srb #if defined (_WIN32) waddir = _fullpath(NULL, waddir, MAX_PATH); - SetCurrentDirectoryA(waddir); #else waddir = realpath(waddir, NULL); - if (waddir == NULL || chdir(waddir) == -1) - I_OutputMsg("Couldn't change working directory\n"); #endif + if (waddir == NULL || I_ChDir(waddir) == -1) + I_OutputMsg("Couldn't change working directory\n"); } return waddir; diff --git a/src/i_system.h b/src/i_system.h index 9f7b0ae2e..823361ce3 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -237,6 +237,21 @@ char *I_GetUserName(void); */ INT32 I_mkdir(const char *dirname, INT32 unixright); +/** \brief Change current working directory + + \param path directory path + \return 0 on success, -1 on error +*/ +INT32 I_ChDir(const char *path); + +/** \brief Get current working directory + + \param buf buffer to store path + \param size size of buffer + \return buf on success, NULL on error +*/ +char *I_GetCwd(char *buf, size_t size); + /** \brief Find main WAD \return path to main WAD */ diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index ae009928b..7be401f40 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -57,10 +57,13 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include #include #include + #ifdef __GNUC__ #include #endif + #if defined (__unix__) || defined (UNIXCOMMON) +#include #include #endif @@ -2260,6 +2263,7 @@ void I_ShutdownSystem(void) for (c = MAX_QUIT_FUNCS-1; c >= 0; c--) if (quit_funcs[c]) (*quit_funcs[c])(); + #ifdef LOGMESSAGES if (logstream) { @@ -2369,6 +2373,24 @@ INT32 I_mkdir(const char *dirname, INT32 unixright) #endif } +INT32 I_ChDir(const char *path) +{ +#ifdef _WIN32 + return (SetCurrentDirectoryA(path) ? 0 : -1); +#else + return chdir(path); +#endif +} + +char *I_GetCwd(char *buf, size_t size) +{ +#ifdef _WIN32 + return (GetCurrentDirectoryA((DWORD)size, buf) ? buf : NULL); +#else + return getcwd(buf, size); +#endif +} + char *I_GetEnv(const char *name) { #ifdef NEED_SDL_GETENV @@ -2427,6 +2449,7 @@ const char *I_ClipboardPaste(void) *i = '?'; // Nonprintable chars become question marks ++i; } + return (const char *)&clipboard_modified; } @@ -2580,12 +2603,11 @@ extern "C" const char *I_LocateWad(void) // change to the directory where we found srb2.srb #if defined (_WIN32) waddir = _fullpath(NULL, waddir, MAX_PATH); - SetCurrentDirectoryA(waddir); #else waddir = realpath(waddir, NULL); - if (waddir == NULL || chdir(waddir) == -1) - I_OutputMsg("Couldn't change working directory\n"); #endif + if (waddir == NULL || I_ChDir(waddir) == -1) + I_OutputMsg("Couldn't change working directory\n"); } return waddir; From c5116dea1acd12dbcb9c8538dc19c9119f264dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Sun, 27 Jul 2025 20:06:19 +0200 Subject: [PATCH 568/589] Add support for OpenBSD --- src/dedicated/i_system.c | 6 +++++- src/sdl/CMakeLists.txt | 4 ++++ src/sdl/i_system.cpp | 10 +++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 70e7ea86c..ec469620b 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -968,14 +968,18 @@ void I_Sleep(UINT32 ms) void I_SleepDuration(precise_t duration) { -#if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__OpenBSD__) UINT64 precision = I_GetPrecisePrecision(); struct timespec ts = { .tv_sec = duration / precision, .tv_nsec = duration * 1000000000 / precision % 1000000000, }; int status; +#ifdef __OpenBSD__ + do status = nanosleep(&ts, &ts); +#else do status = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &ts); +#endif while (status == EINTR); #elif defined (MIN_SLEEP_DURATION_MS) UINT64 precision = I_GetPrecisePrecision(); diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index 13b41323e..664010072 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -177,6 +177,10 @@ if(${SDL2_FOUND}) ) endif() + if("${CMAKE_SYSTEM_NAME}" MATCHES "OpenBSD") + target_link_libraries(SRB2SDL2 PRIVATE pthread execinfo) + endif() + if(${CMAKE_SYSTEM} MATCHES Windows AND ${CMAKE_C_COMPILER_ID} MATCHES "GNU" AND ${SRB2_SYSTEM_BITS} EQUAL 32) target_link_libraries(SRB2SDL2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../libs/drmingw/lib/win32/libexchndl.a" diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 7be401f40..6f7478f81 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1398,10 +1398,14 @@ void I_Sleep(UINT32 ms) void I_SleepDuration(precise_t duration) { -#if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__HAIKU__) || defined(__OpenBSD__) UINT64 precision = I_GetPrecisePrecision(); precise_t dest = I_GetPreciseTime() + duration; +#ifdef __OpenBSD__ + precise_t slack = (precision / 50); // 20 ms slack +#else precise_t slack = (precision / 5000); // 0.2 ms slack +#endif if (duration > slack) { duration -= slack; @@ -1414,7 +1418,11 @@ void I_SleepDuration(precise_t duration) #endif }; int status; +#ifdef __OpenBSD__ + do status = nanosleep(&ts, &ts); +#else do status = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, &ts); +#endif while (status == EINTR); } From 4e606fc7ded8a88f2f2fc6e836528563d623b8e9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 10 Aug 2026 15:50:25 +0200 Subject: [PATCH 569/589] fix indentation --- src/p_inter.c | 1 + src/p_maputl.cpp | 2 +- src/p_mobj.h | 2 +- src/p_setup.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 0cf70f7a0..e6f753b56 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2632,6 +2632,7 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) if (i & 1) P_SetObjectMomZ(mo, ns, true); } + if (player->mo->eflags & MFE_VERTICALFLIP) mo->momz *= -1; } diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 6e7f926b3..122311903 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -466,7 +466,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // Check for collision with front side's midtexture if Effect 4 is set if (linedef->flags & ML_EFFECT4 && !linedef->polyobj) // don't do anything for polyobjects! ...for now - { + { side_t *side = &sides[linedef->sidenum[0]]; fixed_t textop, texbottom, texheight; fixed_t texmid, delta1, delta2; diff --git a/src/p_mobj.h b/src/p_mobj.h index c348c925c..face77ed2 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -113,7 +113,7 @@ typedef enum // Don't use the blocklinks (inert but displayable) MF_NOBLOCKMAP = 1<<4, // Thin, paper-like collision bound (for visual equivalent, see FF_PAPERSPRITE) - MF_PAPERCOLLISION = 1<<5, + MF_PAPERCOLLISION = 1<<5, // You can push this object. It can activate switches and things by pushing it on top. MF_PUSHABLE = 1<<6, // Object is a boss. diff --git a/src/p_setup.c b/src/p_setup.c index 17a0b9d77..4667f5af5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3065,7 +3065,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // Don't include these in the fade! char tx[64]; V_DrawSmallString(1, 191, V_ALLOWLOWERCASE, M_GetText("Speeding off to...")); - snprintf(tx, sizeof(tx), "%s%s%s", + snprintf(tx, sizeof(tx)-1, "%s%s%s", mapheader->lvlttl, (strlen(mapheader->zonttl) > 0) ? va(" %s",mapheader->zonttl) : // SRB2kart ((mapheader->levelflags & LF_NOZONE) ? "" : " Zone"), From 2eb175c356537215e56604c2a549859de5bef25f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Aug 2026 16:33:03 +0200 Subject: [PATCH 570/589] few more smaller code cleanups --- src/hardware/hw_cache.c | 3 ++- src/lua_hooklib.c | 15 +++++++-------- src/lua_script.c | 2 ++ src/p_map.c | 6 +++--- src/p_spec.c | 8 ++++---- src/s_sound.c | 18 +++++++++--------- src/s_sound.h | 4 ++-- 7 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c4cd7d383..423a75b32 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -555,7 +555,8 @@ static void HWR_FreePatchCache(boolean freeall) callback = FreeColormapsCallback; //Z_IterateTags(PU_PATCH, PU_PATCH_ROTATED, callback); - Z_IterateTags(PU_PATCH, PU_PATCH, callback); + //Z_IterateTags(PU_PATCH, PU_PATCH_LOWPRIORITY, callback); // we dont really need to free low priority patches here as P_FreeLevelState takes care of them + Z_IterateTag(PU_PATCH, callback); Z_IterateTags(PU_SPRITE, PU_HUDGFX, callback); } diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 82c1a00d6..d8778263c 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -579,8 +579,8 @@ FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype static UINT8 seen = 0; // so we dont have to check all this shit constantly int numCalls = call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); - if (!seen && numCalls > 0 && mobj_type == MT_NULL && ( - hook->hook_type == MOBJ_HOOK(MobjThinker ) + if (!seen && numCalls > 0 && mobj_type == MT_NULL && + ( hook->hook_type == MOBJ_HOOK(MobjThinker ) || hook->hook_type == MOBJ_HOOK(MobjCollide ) || hook->hook_type == MOBJ_HOOK(MobjMoveCollide) || hook->hook_type == MOBJ_HOOK(MobjFuse ) @@ -588,6 +588,7 @@ FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype )) { seen = 1; + CONS_Alert( CONS_WARNING, "%s\n", va( "%s hooks not attached to a specific mobj type may cause performance issues!", @@ -609,12 +610,10 @@ FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype return numCalls; } -/* -FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) +/*FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) { return call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); -} -*/ +}*/ static int call_hooks ( @@ -899,7 +898,7 @@ int LUA_HookShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT3 int LUA_HookMobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) { return damage_hook(target, inflictor, source, damage, - MOBJ_HOOK(MobjDamage), res_true); + MOBJ_HOOK(MobjDamage), res_true); } int LUA_HookMobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source) @@ -988,7 +987,7 @@ void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) { Hook_State hook = {}; if (prepare_string_hook - (&hook, 0, STRING_HOOK(LinedefExecute), line->text)) + (&hook, 0, STRING_HOOK(LinedefExecute), line->text)) { LUA_PushUserdata(gL, line, META_LINE); LUA_PushUserdata(gL, mo, META_MOBJ); diff --git a/src/lua_script.c b/src/lua_script.c index 0943eef68..14cdee2d7 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -591,6 +591,7 @@ void LUA_InvalidateLevel(void) for (i = 0; i < numsubsectors; i++) LUA_InvalidateUserdata(&subsectors[i]); + for (i = 0; i < numsectors; i++) { LUA_InvalidateUserdata(§ors[i]); @@ -611,6 +612,7 @@ void LUA_InvalidateLevel(void) for (i = 0; i < numsides; i++) LUA_InvalidateUserdata(&sides[i]); + for (i = 0; i < numvertexes; i++) LUA_InvalidateUserdata(&vertexes[i]); diff --git a/src/p_map.c b/src/p_map.c index 753d576b6..9c974ce44 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -245,12 +245,12 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) { - player_t *p = object->player; // will be NULL if not a player + player_t *player = object->player; // will be NULL if not a player fixed_t zdist; // distance between bottoms fixed_t speed = spring->info->mass; // conveniently, both fans and gas jets use this for the vertical thrust SINT8 flipval = P_MobjFlip(spring); // virtually everything here centers around the thruster's gravity, not the object's! - if (p && object->state == &states[object->info->painstate]) // can't use fans and gas jets when player is in pain! + if (player && object->state == &states[object->info->painstate]) // can't use fans and gas jets when player is in pain! return; // is object's top below thruster's position? if not, calculate distance between their bottoms @@ -276,7 +276,7 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) break; if (flipval*object->momz >= FixedMul(speed, spring->scale)) // if object's already moving faster than your best, don't bother break; - if (p && (p->climbing || p->pflags & PF_GLIDING)) // doesn't affect Knux when he's using his abilities! + if (player && (player->climbing || player->pflags & PF_GLIDING)) // doesn't affect Knux when he's using his abilities! break; object->momz += flipval*FixedMul(speed/4, spring->scale); diff --git a/src/p_spec.c b/src/p_spec.c index 560ac0b2a..fd69275a0 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2161,7 +2161,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) newname[1] = 'C'; newname[2] = 'R'; - scrnum = sides[line->sidenum[0]].textureoffset>>FRACBITS; + scrnum = sides[line->sidenum[0]].textureoffset >> FRACBITS; if (scrnum < 0 || scrnum > 999) { scrnum = 0; @@ -2169,9 +2169,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } else { - newname[5] = (char)('0' + (char)((scrnum/100))); - newname[6] = (char)('0' + (char)((scrnum%100)/10)); - newname[7] = (char)('0' + (char)(scrnum%10)); + newname[5] = (char)('0' + (char)((scrnum / 100))); + newname[6] = (char)('0' + (char)((scrnum % 100) / 10)); + newname[7] = (char)('0' + (char)(scrnum % 10)); } newname[8] = '\0'; diff --git a/src/s_sound.c b/src/s_sound.c index d7f4a2853..278c87853 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -433,7 +433,7 @@ static boolean S_CheckSameSoundLimit(sfxenum_t sfx_id) return true; for (cnum = 0; cnum < numofchannels; cnum++) - if ((size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)sfx_id) + if (channels[cnum].sfxinfo == &S_sfx[sfx_id]) scount++; //CONS_Printf("same sound count: %d for sfx: %d\n", scount, sfx_id); @@ -864,18 +864,18 @@ void S_SetSfxVolume(INT32 volume) if (volume < 0 || volume > 31) CONS_Alert(CONS_WARNING, "sfxvolume should be between 0-31\n"); - CV_SetValue(&cv_soundvolume, volume&0x1F); + CV_SetValue(&cv_soundvolume, volume & 0x1F); actualsfxvolume = cv_soundvolume.value; // check for change of var // now hardware volume - I_SetSfxVolume(volume&0x1F); + I_SetSfxVolume(volume & 0x1F); } void S_ClearSfx(void) { size_t i; for (i = 1; i < NUMSFX; i++) - I_FreeSfx(S_sfx + i); + I_FreeSfx(&S_sfx[i]); } static void S_StopChannel(INT32 cnum) @@ -1067,12 +1067,12 @@ INT32 S_OriginPlaying(void *origin) // Searches through the channels and checks if a given id // is playing anywhere. -INT32 S_IdPlaying(sfxenum_t id) +INT32 S_IdPlaying(sfxenum_t sfx_id) { INT32 cnum; for (cnum = 0; cnum < numofchannels; cnum++) - if ((size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)id) + if (channels[cnum].sfxinfo == &S_sfx[sfx_id]) return 1; return 0; @@ -1080,7 +1080,7 @@ INT32 S_IdPlaying(sfxenum_t id) // Searches through the channels and checks for // origin x playing sound id y. -INT32 S_SoundPlaying(void *origin, sfxenum_t id) +INT32 S_SoundPlaying(void *origin, sfxenum_t sfx_id) { INT32 cnum; @@ -1089,8 +1089,8 @@ INT32 S_SoundPlaying(void *origin, sfxenum_t id) for (cnum = 0; cnum < numofchannels; cnum++) { - if (channels[cnum].origin == origin - && (size_t)(channels[cnum].sfxinfo - S_sfx) == (size_t)id) + if (channels[cnum].origin == origin && + channels[cnum].sfxinfo == &S_sfx[sfx_id]) return 1; } diff --git a/src/s_sound.h b/src/s_sound.h index 077fd325e..5d9d9949f 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -286,8 +286,8 @@ void S_SetSfxVolume(INT32 volume); void S_SetMusicVolume(INT32 volume); INT32 S_OriginPlaying(void *origin); -INT32 S_IdPlaying(sfxenum_t id); -INT32 S_SoundPlaying(void *origin, sfxenum_t id); +INT32 S_IdPlaying(sfxenum_t sfx_id); +INT32 S_SoundPlaying(void *origin, sfxenum_t sfx_id); void S_StartSoundName(void *mo, const char *soundname); From 8ffeab1646bbe32ce2f0291f9aafddbd730ccb66 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 21 Oct 2020 12:34:26 -0700 Subject: [PATCH 571/589] Reset wait period for COM_BufInsertText --- src/command.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/command.c b/src/command.c index 93d99f4ef..9996635e9 100644 --- a/src/command.c +++ b/src/command.c @@ -134,6 +134,8 @@ void COM_BufAddText(const char *ptext) */ void COM_BufInsertText(const char *ptext) { + const INT32 old_wait = com_wait; + char *temp = NULL; size_t templen; @@ -145,10 +147,14 @@ void COM_BufInsertText(const char *ptext) VS_Clear(&com_text); } + com_wait = 0; + // add the entire text of the file (or alias) COM_BufAddText(ptext); COM_BufExecute(); // do it right away + com_wait += old_wait; + // add the copied off data if (templen) { From f1380a276e2e6fa44683b62b4fc4d8c7bdbfe591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Sat, 19 Apr 2025 12:16:59 +0200 Subject: [PATCH 572/589] Fix buffer overflow when running map scripts --- src/command.c | 24 +++++++++++++++++------- src/command.h | 6 ++++-- src/p_setup.c | 5 +++-- src/p_spec.c | 9 +-------- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/command.c b/src/command.c index 9996635e9..3ba7a2972 100644 --- a/src/command.c +++ b/src/command.c @@ -113,18 +113,29 @@ static vsbuf_t com_text; // variable sized buffer * \param ptext The text to add. * \sa COM_BufInsertText */ -void COM_BufAddText(const char *ptext) +void COM_BufAddTextEx(const char *ptext, size_t plen) { size_t l; + char *text; - l = strlen(ptext); + if (plen == 0) + plen = strlen(ptext); + + text = Z_Malloc(sizeof(char) * (plen+1), PU_STATIC, NULL); + memcpy(text, ptext, plen); + text[plen] = '\0'; + + l = strlen(text); if (com_text.cursize + l >= com_text.maxsize) { CONS_Alert(CONS_WARNING, M_GetText("Command buffer full!\n")); return; } - VS_Write(&com_text, ptext, l); + + VS_Write(&com_text, text, l); + + Z_Free(text); } /** Adds command text and executes it immediately. @@ -132,7 +143,7 @@ void COM_BufAddText(const char *ptext) * \param ptext The text to execute. A newline is automatically added. * \sa COM_BufAddText */ -void COM_BufInsertText(const char *ptext) +void COM_BufInsertTextEx(const char *ptext, size_t plen) { const INT32 old_wait = com_wait; @@ -150,7 +161,7 @@ void COM_BufInsertText(const char *ptext) com_wait = 0; // add the entire text of the file (or alias) - COM_BufAddText(ptext); + COM_BufAddTextEx(ptext, plen); COM_BufExecute(); // do it right away com_wait += old_wait; @@ -165,8 +176,7 @@ void COM_BufInsertText(const char *ptext) /** Progress the wait timer and flush waiting console commands when ready. */ -void -COM_BufTicker(void) +void COM_BufTicker(void) { if (com_wait) { diff --git a/src/command.h b/src/command.h index d3bf09127..bfff2dd11 100644 --- a/src/command.h +++ b/src/command.h @@ -52,10 +52,12 @@ size_t COM_FirstOption(void); const char *COM_CompleteCommand(const char *partial, INT32 skips); // insert at queu (at end of other command) -void COM_BufAddText(const char *btext); +#define COM_BufAddText(s) COM_BufAddTextEx(s, 0) +void COM_BufAddTextEx(const char *ptext, size_t plen); // insert in head (before other command) -void COM_BufInsertText(const char *btext); +#define COM_BufInsertText(s) COM_BufInsertTextEx(s, 0) +void COM_BufInsertTextEx(const char *ptext, size_t plen); // don't bother inserting, just do immediately void COM_ImmedExecute(const char *ptext); diff --git a/src/p_setup.c b/src/p_setup.c index 4667f5af5..8dc28f359 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2425,7 +2425,8 @@ static void P_RunLevelScript(const char *scriptname) lumpnum_t lumpnum; char newname[9]; - strlcpy(newname, scriptname, sizeof(newname)); + strncpy(newname, scriptname, sizeof(newname)-1); + newname[sizeof(newname)-1] = '\0'; lumpnum = W_CheckNumForName(newname); @@ -2435,7 +2436,7 @@ static void P_RunLevelScript(const char *scriptname) return; } - COM_BufInsertText(W_CacheLumpNum(lumpnum, PU_CACHE)); + COM_BufInsertTextEx(W_CacheLumpNum(lumpnum, PU_CACHE), W_LumpLength(lumpnum)); } else { diff --git a/src/p_spec.c b/src/p_spec.c index fd69275a0..1ae50c614 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2184,14 +2184,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) else { // W_CacheLumpNum may not have null terminator, so we need to do this :blobcatgooglyholditsheadinitshands: - size_t len = W_LumpLength(lumpnum); - char *script = Z_Malloc(len+1, PU_STATIC, NULL); - memcpy(script, W_CacheLumpNum(lumpnum, PU_CACHE), len); - script[len] = 0; - - COM_BufInsertText(script); - - Z_Free(script); + COM_BufInsertTextEx(W_CacheLumpNum(lumpnum, PU_CACHE), W_LumpLength(lumpnum)); } } break; From eca3effb3b0449b4b8da3f99ff0ffc7ab21a8daa Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Aug 2026 18:47:42 +0200 Subject: [PATCH 573/589] raise version to v10 was originally be 9.3 but this update is too massive to be a minor version update --- src/doomdef.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index b57ab0bfb..6fabd9744 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -130,8 +130,8 @@ extern char logfilename[1024]; #else #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number -#define VERSIONSTRING "Saturn v9.3" -#define VERSIONSTRINGW L"Saturn v9.3" +#define VERSIONSTRING "Saturn v10" +#define VERSIONSTRINGW L"Saturn v10" #define SATURN_TESTING // comment out for saturn release builds! From bcbe765b9d9ddc855da1f38573649453994c7934 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 17 Aug 2026 19:16:39 +0200 Subject: [PATCH 574/589] fix potential buffer underflow in portal handling P_FindSpecialLineFromTag may return -1 in some cases --- src/hardware/hw_bsp.c | 8 ++++---- src/hardware/hw_main.cpp | 2 +- src/r_bsp.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 07b7c1e5e..0a4b0af36 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -346,15 +346,15 @@ static void SplitPoly (fdivline_t *dlnp, // splitting parametric line } // checks if any line is a portal or horizonline, for optimization -static inline void CheckForPortalsAndHorizonLines(seg_t *lseg, const line_t *line) +static inline void CheckForPortalsAndHorizonLines(boolean firstside, const line_t *line) { // portal check - if (!gl_maphasportals && lseg->side == 0 && line->special == PORTALSPECIAL) + if (!gl_maphasportals && firstside && line->special == PORTALSPECIAL) { // Find the other side! INT32 line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->tag, -1); - if (line == &lines[line2]) + if (line2 >= 0 && line == &lines[line2]) line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->tag, line2); if (line2 >= 0) // found it! @@ -397,7 +397,7 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 segcount, poly_t *poly) if (!line) continue; - CheckForPortalsAndHorizonLines(lseg, line); + CheckForPortalsAndHorizonLines(lseg->side == 0, line); if (line->sidenum[1] != NO_INDEX) { diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index f7c689525..cc3c55e2f 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2306,7 +2306,7 @@ static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2) // Find the other side! INT32 line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->linedef->tag, -1); - if (line->linedef == &lines[line2]) + if (line2 >= 0 && line->linedef == &lines[line2]) line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->linedef->tag, line2); if (line2 >= 0) // found it! diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 68de16478..b118e8e84 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -395,7 +395,7 @@ static void R_AddLine(seg_t *line) // Find the other side! INT32 line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->linedef->tag, -1); - if (line->linedef == &lines[line2]) + if (line2 >= 0 && line->linedef == &lines[line2]) line2 = P_FindSpecialLineFromTag(PORTALSPECIAL, line->linedef->tag, line2); if (line2 >= 0) // found it! From 0cf1cabcc2876e2933a401792fb8118ef32216d0 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 18 Aug 2026 17:31:31 +0200 Subject: [PATCH 575/589] basic 32 player support can just be enabled per MAXPLAYERS define in doomdef this will also auto undefine COMPAT_VANILLA no support for tab rankings or intermission rankings at all yet will port those over eventually from saturn 32p or blankart and clean stuff up please note this may have bugs since not everything is ported over yet --- src/doomdef.h | 4 ++-- src/g_game.c | 6 ++++++ src/hu_stuff.c | 5 +++-- src/k_hud.c | 14 ++++++++++++++ src/k_kart.c | 6 ++++++ src/m_menu.c | 5 +---- src/y_inter.c | 10 ++++++++-- 7 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 6fabd9744..afbe61b21 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -604,8 +604,8 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // undefine to enable fixes and features that are not vanilla compatible #define COMPAT_VANILLA -// if we build with 32 player (or more!) support we dont need to care vanilla compat -#if MAXPLAYERS > 16 +// if we build with 32 player (or more or less!) support we dont need to care vanilla compat +#if MAXPLAYERS != 16 #undef COMPAT_VANILLA #endif diff --git a/src/g_game.c b/src/g_game.c index 9cc58d19e..c133050d8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2630,12 +2630,18 @@ mapthing_t *G_FindRaceStart(INT32 playernum) // Just spawn there. //return playerstarts[0]; +#if MAXPLAYERS > 16 + //this section courtesy of fickle - v1.1 battle royale + // screw collision chex + return playerstarts[pos % numcoopstarts]; +#else if (P_IsLocalPlayerNum(playernum)) { CONS_Alert(CONS_WARNING, "Could not spawn at any Race starts!\n"); } return NULL; +#endif } if (P_IsLocalPlayerNum(playernum)) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index c61ecc9f2..8f131b3d2 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2830,8 +2830,9 @@ static void HU_DrawRankings(void) scorelines++; #if MAXPLAYERS > 16 - if (scorelines > 16) - break; //dont draw past bottom of screen, show the best only + // 32 Player TODO: port over and cleanup scoreboard from sat-32p/blankart + if (scorelines >= 16) + break; // dont draw past bottom of screen, show the best only #endif } diff --git a/src/k_hud.c b/src/k_hud.c index 545cd957a..97f927a06 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -695,6 +695,9 @@ void K_LoadKartHUDGraphics(void) kp_winnernum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } + // 32 player note: there are only 16 of those! + // so slots after this will just be missing patches! + // but keeping like this incase of missed adjustments which might cause crashes otherwise snprintf(buffer, sizeof(buffer), "OPPRNKxx"); for (i = 0; i <= MAXPLAYERS; i++) { @@ -2294,6 +2297,11 @@ static boolean K_drawKartPositionFaces(void) if (pos < 0 || pos > MAXPLAYERS) pos = 0; +#if MAXPLAYERS > 16 + if (pos > 16) + V_DrawPingNum(FACE_X+2, Y+10, V_HUDTRANS|V_SNAPTOLEFT, pos, NULL); + else +#endif // Draws the little number over the face V_DrawScaledPatch(FACE_X-5, Y+10, V_HUDTRANS|V_SNAPTOLEFT, kp_facenum[pos]); } @@ -2385,6 +2393,12 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I INT32 pos = player->kartstuff[k_position]; if (pos < 0 || pos > MAXPLAYERS) pos = 0; + +#if MAXPLAYERS > 16 + if (pos > 16) + V_DrawPingNum(x+2, y+10, 0, pos, NULL); + else +#endif // Draws the little number over the face V_DrawScaledPatch(x-5, y+6, 0, kp_facenum[pos]); } diff --git a/src/k_kart.c b/src/k_kart.c index e77c0b5ee..e8b48e7d8 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1033,6 +1033,12 @@ INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean spbrush) } } +#if MAXPLAYERS > 16 + // courtesy of fickle from 1.1 battleroyale + // battleroyale: limit how much items will scale to try to prevent shit-tier items in shit-huge netames + pingame = min(pingame, 12); +#endif + if (first != -1 && second != -1) // calculate 2nd's distance from 1st, for SPB { secondist = P_AproxDistance(P_AproxDistance(players[first].mo->x - players[second].mo->x, diff --git a/src/m_menu.c b/src/m_menu.c index cabcadf7f..3c9779d65 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -7650,11 +7650,8 @@ static void M_DrawMPMainMenu(void) // use generic drawer for cursor, items and title M_DrawGenericMenu(); -#if MAXPLAYERS != 16 -Update the maxplayers label... -#endif V_DrawRightAlignedString(BASEVIDWIDTH-x, y+MP_MainMenu[4].alphaKey, - ((itemOn == 4) ? highlightflags : 0)|MENUCAPS, "(2-16 Players)"); + ((itemOn == 4) ? highlightflags : 0)|MENUCAPS, va("(2-%d Players)", MAXPLAYERS)); V_DrawRightAlignedString(BASEVIDWIDTH-x, y+MP_MainMenu[5].alphaKey, ((itemOn == 5) ? highlightflags : 0)|MENUCAPS, diff --git a/src/y_inter.c b/src/y_inter.c index 97df280c5..9c5fc9c0f 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -274,13 +274,13 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32)) // static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) { + INT32 i; + if (standings->numplayers == 0) { return; } - INT32 i; - #define NUMFORNEWCOLUMN 8 INT32 y = 41, gutter = ((standings->numplayers > NUMFORNEWCOLUMN) ? 0 : (BASEVIDWIDTH/2)); INT32 dupadjust = cv_betainterscreen.value ? 314 : vid.scaledwidth, duptweak = cv_betainterscreen.value ? -3 : (dupadjust - BASEVIDWIDTH)/2; @@ -321,6 +321,12 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) const UINT8 pnum = standings->num[i]; player_t *player = &players[pnum]; +#if MAXPLAYERS > 16 + // 32 Player TODO: port over and cleanup standings drawer from sat-32p/blankart + if (i > 16) + break; +#endif + if (pnum == MAXPLAYERS) ; else if (!playeringame[pnum] || player->spectator) From fd349e2b378087c71aed0140672b79541a46c60b Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 18 Aug 2026 17:34:26 +0200 Subject: [PATCH 576/589] netsync mobj pmomz in non vanilla compat builds may help with some join desynchs --- src/p_saveg.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index 1b7f21c47..8c69d58c6 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1108,7 +1108,11 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 diff2 = 0; // not the default but the most probable +#ifdef COMPAT_VANILLA if (mobj->momx != 0 || mobj->momy != 0 || mobj->momz != 0) +#else + if (mobj->momx != 0 || mobj->momy != 0 || mobj->momz != 0 || mobj->pmomz !=0) +#endif diff |= MD_MOM; if (mobj->radius != mobj->info->radius) diff |= MD_RADIUS; @@ -1236,6 +1240,9 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 WRITEFIXED(save->p, mobj->momx); WRITEFIXED(save->p, mobj->momy); WRITEFIXED(save->p, mobj->momz); +#ifndef COMPAT_VANILLA + WRITEFIXED(save->p, mobj->pmomz); +#endif } if (diff & MD_RADIUS) WRITEFIXED(save->p, mobj->radius); @@ -2055,6 +2062,9 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->momx = READFIXED(save->p); mobj->momy = READFIXED(save->p); mobj->momz = READFIXED(save->p); +#ifndef COMPAT_VANILLA + mobj->pmomz = READFIXED(save->p); +#endif } // otherwise they're zero, and the memset took care of it if (diff & MD_RADIUS) From 1552b1808fe06189732d592584ac5075adaf74fc Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 21 Aug 2026 16:51:04 +0200 Subject: [PATCH 577/589] "about" --- src/doomdef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doomdef.h b/src/doomdef.h index afbe61b21..e4dd2ba65 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -604,7 +604,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // undefine to enable fixes and features that are not vanilla compatible #define COMPAT_VANILLA -// if we build with 32 player (or more or less!) support we dont need to care vanilla compat +// if we build with 32 player (or more or less!) support we dont need to care about vanilla compat #if MAXPLAYERS != 16 #undef COMPAT_VANILLA #endif From de74c9251f721cd838a33536281396018541c9c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Aug 2026 16:40:22 +0200 Subject: [PATCH 578/589] make HWR_AddPolyObjectPlanes a little less ugly --- src/hardware/hw_main.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index cc3c55e2f..ad5137eaa 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2662,11 +2662,13 @@ static void HWR_AddPolyObjectPlanes(void) polyobjsector = po_ptrs[i]->lines[0]->backsector; // the in-level polyobject sector - if (polyobjsector->floorheight <= gl_frontsector->ceilingheight - && polyobjsector->floorheight >= gl_frontsector->floorheight - && (viewz < polyobjsector->floorheight)) + if (polyobjsector->floorheight <= gl_frontsector->ceilingheight && + polyobjsector->floorheight >= gl_frontsector->floorheight && + (viewz < polyobjsector->floorheight)) { light = R_GetPlaneLight(gl_frontsector, polyobjsector->floorheight, true); + const INT16 llevel = (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel); + extracolormap_t *colmap = (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap); if (po_ptrs[i]->translucency > 0) { @@ -2674,22 +2676,24 @@ static void HWR_AddPolyObjectPlanes(void) FBITFIELD blendmode; blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight, - (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap)); + llevel, Surf.PolyColor.s.alpha, polyobjsector, blendmode, colmap); } else { HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum, R_NoEncore(polyobjsector, false)); HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude, - (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), levelflats[polyobjsector->floorpic].lumpnum, - polyobjsector, 255, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap)); + llevel, levelflats[polyobjsector->floorpic].lumpnum, + polyobjsector, 255, colmap); } } - if (polyobjsector->ceilingheight >= gl_frontsector->floorheight - && polyobjsector->ceilingheight <= gl_frontsector->ceilingheight - && (viewz > polyobjsector->ceilingheight)) + if (polyobjsector->ceilingheight >= gl_frontsector->floorheight && + polyobjsector->ceilingheight <= gl_frontsector->ceilingheight && + (viewz > polyobjsector->ceilingheight)) { light = R_GetPlaneLight(gl_frontsector, polyobjsector->ceilingheight, true); + const INT16 llevel = (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel); + extracolormap_t *colmap = (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap); if (po_ptrs[i]->translucency > 0) { @@ -2697,14 +2701,14 @@ static void HWR_AddPolyObjectPlanes(void) FBITFIELD blendmode; blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight, - (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap)); + llevel, Surf.PolyColor.s.alpha, polyobjsector, blendmode, colmap); } else { HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum, R_NoEncore(polyobjsector, true)); HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude, - (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), levelflats[polyobjsector->ceilingpic].lumpnum, - polyobjsector, 255, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap)); + llevel, levelflats[polyobjsector->ceilingpic].lumpnum, + polyobjsector, 255, colmap); } } } @@ -3717,7 +3721,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) Surf.PolyColor.s.alpha = alpha; - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); // sprite shader + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); top = bot; endtop = endbot; @@ -3744,7 +3748,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) Surf.PolyColor.s.alpha = alpha; - HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); // sprite shader + HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false); } // -----------------+ From 5644036d25a60e37785214b60c1b8e898a9cffd7 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Aug 2026 10:30:28 +0200 Subject: [PATCH 579/589] macrofy Z_CheckHeap errors stuff was slightly ugly and unwieldy. making it a macro also makes adding new errors less messy --- src/z_zone.cpp | 102 +++++++++---------------------------------------- 1 file changed, 17 insertions(+), 85 deletions(-) diff --git a/src/z_zone.cpp b/src/z_zone.cpp index f688dd831..ccf3f9bd0 100644 --- a/src/z_zone.cpp +++ b/src/z_zone.cpp @@ -513,6 +513,16 @@ void Z_CheckHeap(INT32 tag) (void)tag; #endif +#ifdef ZDEBUG +#define HeapError(msg) \ + I_Error("Z_CheckHeap : %s:%d, block %u (owned by %s:%d) %s", \ + file, line, blocknumon, block->ownerfile, block->ownerline, msg) +#else +#define HeapError(msg) \ + I_Error("Z_CheckHeap : block %u (owned by %s:%d) %s", \ + blocknumon, block->ownerfile, block->ownerline, msg) +#endif + for (block = head.next; block != &head; block = block->next) { blocknumon++; @@ -524,105 +534,27 @@ void Z_CheckHeap(INT32 tag) #ifdef VALGRIND_MEMPOOL_EXISTS if (!VALGRIND_MEMPOOL_EXISTS(block)) { - I_Error("Z_CheckHeap :" -#ifdef ZDEBUG - " %s %d" -#endif - " block %u" -#ifdef ZDEBUG - " (owned by %s:%d)" -#endif - " should not exist" -#ifdef ZDEBUG - , file, line -#endif - , blocknumon -#ifdef ZDEBUG - , block->ownerfile, block->ownerline -#endif - ); + HeapError(" should not exist"); } #endif if (block->user != NULL && *(block->user) != given) { - I_Error("Z_CheckHeap :" -#ifdef ZDEBUG - " %s %d" -#endif - " block %u" -#ifdef ZDEBUG - " (owned by %s:%d)" -#endif - " doesn't have a proper user" -#ifdef ZDEBUG - , file, line -#endif - , blocknumon -#ifdef ZDEBUG - , block->ownerfile, block->ownerline -#endif - ); + HeapError(" doesn't have a proper user"); } + if (block->next->prev != block) { - I_Error("Z_CheckHeap :" -#ifdef ZDEBUG - " %s %d" -#endif - " block %u" -#ifdef ZDEBUG - " (owned by %s:%d)" -#endif - " lacks proper backlink" -#ifdef ZDEBUG - , file, line -#endif - , blocknumon -#ifdef ZDEBUG - , block->ownerfile, block->ownerline -#endif - ); + HeapError(" lacks proper backlink"); } + if (block->prev->next != block) { - I_Error("Z_CheckHeap :" -#ifdef ZDEBUG - " %s %d" -#endif - " block %u" -#ifdef ZDEBUG - " (owned by %s:%d)" -#endif - " lacks proper forward link" -#ifdef ZDEBUG - , file, line -#endif - , blocknumon -#ifdef ZDEBUG - , block->ownerfile, block->ownerline -#endif - ); + HeapError(" lacks proper forward link"); } #ifdef PARANOIA if (block->id != ZONEID) { - I_Error("Z_CheckHeap :" -#ifdef ZDEBUG - " %s %d" -#endif - " block %u" -#ifdef ZDEBUG - " (owned by %s:%d)" -#endif - " have the wrong ID" -#ifdef ZDEBUG - , file, line -#endif - , blocknumon -#ifdef ZDEBUG - , block->ownerfile, block->ownerline -#endif - ); + HeapError(" has the wrong ID"); } #endif } From 882716e9117278dc191b3ead62fd97441fc18503 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Sun, 9 Feb 2025 23:05:11 +0100 Subject: [PATCH 580/589] Make Valgrind builds usable when not running with Valgrind + cleanup --- src/z_zone.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/z_zone.cpp b/src/z_zone.cpp index ccf3f9bd0..3a78c7079 100644 --- a/src/z_zone.cpp +++ b/src/z_zone.cpp @@ -44,7 +44,6 @@ #ifdef HAVE_VALGRIND #include "valgrind.h" static boolean Z_calloc = false; -#include "memcheck.h" #endif #define ZONEID 0xa441d13d @@ -180,7 +179,7 @@ void Z_Free(void *ptr) if (block->user != NULL) *block->user = NULL; -#ifdef VALGRIND_DESTROY_MEMPOOL +#ifdef HAVE_VALGRIND VALGRIND_DESTROY_MEMPOOL(block); #endif block->prev->next = block->next; @@ -246,10 +245,6 @@ void *Z_Malloc(size_t size, INT32 tag, void *user) ptr = MEMORY(block); I_Assert((intptr_t)ptr % alignof (max_align_t) == 0); -#ifdef HAVE_VALGRIND - Z_calloc = false; -#endif - block->next = head.next; block->prev = &head; head.next = block; @@ -263,8 +258,9 @@ void *Z_Malloc(size_t size, INT32 tag, void *user) #endif block->size = size; -#ifdef VALGRIND_CREATE_MEMPOOL +#ifdef HAVE_VALGRIND VALGRIND_CREATE_MEMPOOL(block, size, Z_calloc); + Z_calloc = false; #endif #ifdef PARANOIA @@ -301,7 +297,8 @@ void *Z_Calloc2(size_t size, INT32 tag, void *user, const char *file, INT32 line void *Z_Calloc(size_t size, INT32 tag, void *user) #endif { -#ifdef VALGRIND_MEMPOOL_ALLOC + +#ifdef HAVE_VALGRIND Z_calloc = true; #endif #ifdef ZDEBUG @@ -531,8 +528,8 @@ void Z_CheckHeap(INT32 tag) CONS_Debug(DBG_MEMORY, "block %u owned by %s:%d\n", blocknumon, block->ownerfile, block->ownerline); #endif -#ifdef VALGRIND_MEMPOOL_EXISTS - if (!VALGRIND_MEMPOOL_EXISTS(block)) +#ifdef HAVE_VALGRIND + if (RUNNING_ON_VALGRIND && !VALGRIND_MEMPOOL_EXISTS(block)) { HeapError(" should not exist"); } From 819b171d903c30e7145bda9615996b8c66c2c3f7 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 28 Aug 2026 00:44:44 +0300 Subject: [PATCH 581/589] Do a full garbage collection after LUA_InvalidateLevel --- src/lua_script.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index 14cdee2d7..0db0bd1e0 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -623,6 +623,10 @@ void LUA_InvalidateLevel(void) LUA_InvalidateUserdata(&slope->o); LUA_InvalidateUserdata(&slope->d); } + + // We invalidated a lot of userdata objects, a lot of them probably ended up unreachable so they can be + // GC'd right away + lua_gc(gL, LUA_GCCOLLECT, 0); } void LUA_InvalidateMapthings(void) From ade7db900429ff7011f286aea6ee9a10db413bc5 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Sep 2026 14:09:23 +0200 Subject: [PATCH 582/589] fix replayhut exploding due to sega fishe "sega_bass_fishin" is exactly 16 characters which caused stuff to not be terminated --- src/g_demo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/g_demo.c b/src/g_demo.c index 049cf4bfd..d39bbaec7 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2335,7 +2335,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) while (READUINT8(extrainfo_p) == DW_STANDING) // Assume standings are always first in the extrainfo { INT32 i; - char temp[16]; + char temp[17]; pdemo->standings[count].ranking = READUINT8(extrainfo_p); @@ -2345,6 +2345,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) // Skin memcpy(temp, extrainfo_p, 16); + temp[16] = '\0'; extrainfo_p += 16; pdemo->standings[count].skin = UINT8_MAX; @@ -2359,6 +2360,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo) // Color memcpy(temp, extrainfo_p, 16); + temp[16] = '\0'; extrainfo_p += 16; for (i = 0; i < MAXSKINCOLORS; i++) From 24e5b1d84bb6c7199fc4912163f2b2e2bc293c4c Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Sep 2026 14:40:40 +0200 Subject: [PATCH 583/589] fix buffer overflow when opening "Advanced Color Options" idk if this is the intended thing, but works fine --- 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 3c9779d65..d0a2b661e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -10060,7 +10060,7 @@ static void M_DrawColorMenu(void) for (max = currentMenu->numitems; max > 0; max--) { - if (currentMenu->menuitems[max].status != IT_DISABLED && currentMenu->menuitems[max-1].alphaKey*2 + tempcentery <= (currentMenu->y + 2*scrollareaheight)) + if (currentMenu->menuitems[max-1].status != IT_DISABLED && currentMenu->menuitems[max-1].alphaKey*2 + tempcentery <= (currentMenu->y + 2*scrollareaheight)) break; } From a6e5edabd2adb75dc068b72c77ca4056ccfd96df Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 2 Sep 2026 15:05:32 +0200 Subject: [PATCH 584/589] fix M_TextInputSetString not null terminating in some cases if input string is longer than the buffer this may never be null terminated properly --- src/m_textinput.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/m_textinput.c b/src/m_textinput.c index 0d68b2b5d..9e1819b6a 100644 --- a/src/m_textinput.c +++ b/src/m_textinput.c @@ -238,8 +238,8 @@ void M_TextInputClear(textinput_t *input) void M_TextInputSetString(textinput_t *input, const char *c) { - memset(input->buffer, 0, input->buffer_size); - strncpy(input->buffer, c, input->buffer_size); + strncpy(input->buffer, c, input->buffer_size-1); + input->buffer[input->buffer_size-1] = '\0'; input->cursor = input->select = input->length = strlen(input->buffer); } From ac87678708072452e0e4876a5b5a0761c18855e7 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Sep 2026 18:46:44 +0200 Subject: [PATCH 585/589] rename COMPAT_VANILLA to PHOBOS_BUILD have a distinct name for that build "Phobos", as a nod to Doom also invert the flag, as it should make adding stuff less headachey will make this a compiler flag later but too lazy atm --- src/doomdef.h | 39 +++++++++++++++++++++++++-------------- src/info.h | 6 +++--- src/p_local.h | 6 +++--- src/p_saveg.c | 10 +++++----- src/p_setup.c | 8 ++++---- src/p_spec.c | 2 +- src/p_tick.c | 2 +- 7 files changed, 42 insertions(+), 31 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index e4dd2ba65..269e9a416 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -130,8 +130,17 @@ extern char logfilename[1024]; #else #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number -#define VERSIONSTRING "Saturn v10" -#define VERSIONSTRINGW L"Saturn v10" + +#ifdef PHOBOS_BUILD +#define CLIENTNAME "Phobos" +#define CLIENTNAMEW L"Phobos" +#else +#define CLIENTNAME "Saturn" +#define CLIENTNAMEW L"Saturn" +#endif + +#define VERSIONSTRING CLIENTNAME " v10" +#define VERSIONSTRINGW CLIENTNAMEW L" v10" #define SATURN_TESTING // comment out for saturn release builds! @@ -602,11 +611,20 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! -// undefine to enable fixes and features that are not vanilla compatible -#define COMPAT_VANILLA -// if we build with 32 player (or more or less!) support we dont need to care about vanilla compat -#if MAXPLAYERS != 16 -#undef COMPAT_VANILLA +// TODO: make this a compile flag! +// define to enable fixes and features that are not vanilla compatible +//#define PHOBOS_BUILD + +#ifdef PHOBOS_BUILD +// compiler cries otherwise :chaosleep: +#undef MAXPLAYERS +// we want 32 players yesss +#define MAXPLAYERS 32 + +// overwrite some of those +// when not compiling in vanilla compat mode +#define SATURNJOIN +#define SATURNPAK #endif //-- SATURN __ @@ -673,13 +691,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #undef UPDATE_ALERT #endif -// overwrite some of those -// when not compiling in vanilla compat mode -#ifndef COMPAT_VANILLA - #define SATURNJOIN - #define SATURNPAK -#endif - #ifdef __cplusplus } // extern "C" #endif diff --git a/src/info.h b/src/info.h index 59dd2daca..2baae10c2 100644 --- a/src/info.h +++ b/src/info.h @@ -452,10 +452,10 @@ void A_SpawnFreshCopy(void *actor); extern boolean actionsoverridden[NUMACTIONS]; // ratio of states to sprites to mobj types is roughly 6 : 1 : 1 -#ifdef COMPAT_VANILLA -#define NUMMOBJFREESLOTS 1024 -#else +#ifdef PHOBOS_BUILD #define NUMMOBJFREESLOTS 4096 // should be sufficient +#else +#define NUMMOBJFREESLOTS 1024 #endif #define NUMSPRITEFREESLOTS NUMMOBJFREESLOTS #define NUMSTATEFREESLOTS (NUMMOBJFREESLOTS*8) diff --git a/src/p_local.h b/src/p_local.h index 1198335ec..4f59246fc 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -295,10 +295,10 @@ FUNCINLINE static ATTRINLINE boolean P_MobjWasRemoved(const mobj_t *mobj) // so can only check if its not NULL in vanilla compat mode FUNCINLINE static ATTRINLINE boolean P_MobjWasRemovedCompat(const mobj_t *mobj) { -#ifdef COMPAT_VANILLA - return (!mobj); -#else +#ifdef PHOBOS_BUILD return P_MobjWasRemoved(mobj); +#else + return !mobj; #endif } diff --git a/src/p_saveg.c b/src/p_saveg.c index 8c69d58c6..23967cab1 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1108,10 +1108,10 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 diff2 = 0; // not the default but the most probable -#ifdef COMPAT_VANILLA - if (mobj->momx != 0 || mobj->momy != 0 || mobj->momz != 0) -#else +#ifdef PHOBOS_BUILD if (mobj->momx != 0 || mobj->momy != 0 || mobj->momz != 0 || mobj->pmomz !=0) +#else + if (mobj->momx != 0 || mobj->momy != 0 || mobj->momz != 0) #endif diff |= MD_MOM; if (mobj->radius != mobj->info->radius) @@ -1240,7 +1240,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 WRITEFIXED(save->p, mobj->momx); WRITEFIXED(save->p, mobj->momy); WRITEFIXED(save->p, mobj->momz); -#ifndef COMPAT_VANILLA +#ifdef PHOBOS_BUILD WRITEFIXED(save->p, mobj->pmomz); #endif } @@ -2062,7 +2062,7 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->momx = READFIXED(save->p); mobj->momy = READFIXED(save->p); mobj->momz = READFIXED(save->p); -#ifndef COMPAT_VANILLA +#ifdef PHOBOS_BUILD mobj->pmomz = READFIXED(save->p); #endif } // otherwise they're zero, and the memset took care of it diff --git a/src/p_setup.c b/src/p_setup.c index 8dc28f359..2201c0b9f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2074,14 +2074,14 @@ static void P_LoadReject(UINT8 *data, size_t rejectsize) if (rejectsize < neededsize) { CorruptMapWarning(va("P_LoadReject: REJECT is %s byte%s too small. REJECT might be invalid!\n", sizeu1(neededsize - rejectsize), (neededsize - rejectsize) == 1 ? "" : "s")); -#ifdef COMPAT_VANILLA +#ifdef PHOBOS_BUILD + rejectmatrix = NULL; + return; +#else // we can pad this and somewhat prevent desyncs // probs not cool if the reject is from a completely different map // but whatever allocsize = neededsize; -#else - rejectmatrix = NULL; - return; #endif } diff --git a/src/p_spec.c b/src/p_spec.c index 1ae50c614..8b526798e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4604,7 +4604,7 @@ void P_UpdateSpecials(void) // POINT LIMIT P_CheckPointLimit(); -#ifdef COMPAT_VANILLA +#ifndef PHOBOS_BUILD // Dynamic slopeness // we run this here only when not joined midrace // for vanilla compat reasons :chaosleep: diff --git a/src/p_tick.c b/src/p_tick.c index 455a8d5ac..645d7dd31 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -651,7 +651,7 @@ void P_Ticker(boolean run) if (run) { // Dynamic slopeness -#ifdef COMPAT_VANILLA +#ifndef PHOBOS_BUILD if (midgamejoin) // only run here if we joined midgame to fix some desynchs #endif P_RunDynamicSlopes(); From 4c3fa7d8260c3eefeab7ebab9594b19c303fd339 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Sep 2026 19:21:18 +0200 Subject: [PATCH 586/589] raise numlap limit to 255 for phobos client idk but this was wanted --- src/d_netcmd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f05668c8f..f68837052 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -435,10 +435,18 @@ consvar_t cv_pointlimit = {"pointlimit", "0", CV_NETVAR|CV_CALL|CV_NOINIT, point static CV_PossibleValue_t timelimit_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; consvar_t cv_timelimit = {"timelimit", "0", CV_NETVAR|CV_CALL|CV_NOINIT, timelimit_cons_t, TimeLimit_OnChange, 0, NULL, NULL, 0, 0, NULL}; +#ifdef PHOBOS_BUILD +static CV_PossibleValue_t numlaps_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; +#else static CV_PossibleValue_t numlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, NULL}}; +#endif consvar_t cv_numlaps = {"numlaps", "3", CV_NETVAR|CV_CALL|CV_NOINIT, numlaps_cons_t, NumLaps_OnChange, 0, NULL, NULL, 0, 0, NULL}; +#ifdef PHOBOS_BUILD +static CV_PossibleValue_t basenumlaps_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, "Map default"}, {0, NULL}}; +#else static CV_PossibleValue_t basenumlaps_cons_t[] = {{1, "MIN"}, {50, "MAX"}, {0, "Map default"}, {0, NULL}}; +#endif consvar_t cv_basenumlaps = {"basenumlaps", "Map default", CV_NETVAR|CV_CALL|CV_CHEAT, basenumlaps_cons_t, BaseNumLaps_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_forceskin = {"forceskin", "Off", CV_NETVAR|CV_CALL|CV_CHEAT, Forceskin_cons_t, ForceSkin_OnChange, 0, NULL, NULL, 0, 0, NULL}; From efc0681e0144b5a34ccac1db9b4c059deb89e589 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Sep 2026 19:29:32 +0200 Subject: [PATCH 587/589] make PHOBOS_BUILD a compile flag pass PHOBOS_BUILD=1 to build --- src/CMakeLists.txt | 7 +++++++ src/Makefile | 4 ++++ src/Makefile.d/features.mk | 1 + src/doomdef.h | 8 ++------ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 28f48cdad..c763ab3b8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -257,6 +257,9 @@ set(SRB2_CONFIG_SATURNJOIN ON CACHE BOOL set(SRB2_CONFIG_SCREENFBO ON CACHE BOOL "Enable hardware renderer (OpenGL) FBO downsampling support") +set(SRB2_CONFIG_PHOBOS ON CACHE BOOL + " Compile the Phobos client. Which contains things not compatible with vanilla, such as raised skinlimits, 32 player support, bugfixes, etc.") + if(${SRB2_CONFIG_DEDICATED}) set(SRB2_CONFIG_HAVE_GME NO) set(SRB2_CONFIG_HAVE_OPENMPT NO) @@ -583,6 +586,10 @@ if(${SRB2_CONFIG_SATURNJOIN}) add_definitions(-DDOSATURNJOIN) endif() +if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_SCREENFBO}) + add_definitions(-DPHOBOS_BUILD) +endif() + # Targets # Compatibility flag with later versions of GCC diff --git a/src/Makefile b/src/Makefile index 5b1f9f0fa..27831946a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -65,6 +65,10 @@ # DEBUGMODE=1 - Enable various debugging capabilities. # Also disables optimizations. # +# PHOBOS_BUILD=1 - Compile the Phobos client. +# Contains things not compatible with vanilla. +# such as raised skinlimits, 32 player support, bugfixes, etc. +# # Development flags: # # VALGRIND=1 - Enable Valgrind memory debugging support. diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk index af67a5494..6a63c9972 100644 --- a/src/Makefile.d/features.mk +++ b/src/Makefile.d/features.mk @@ -9,6 +9,7 @@ passthru_opts+=\ HAVE_DISCORDRPC DEVELOP\ NOHOLEPUNCH\ HAVE_IPV6\ + PHOBOS_BUILD\ # build with debugging information ifdef DEBUGMODE diff --git a/src/doomdef.h b/src/doomdef.h index 269e9a416..8b205cf51 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -611,16 +611,12 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! -// TODO: make this a compile flag! -// define to enable fixes and features that are not vanilla compatible -//#define PHOBOS_BUILD - #ifdef PHOBOS_BUILD -// compiler cries otherwise :chaosleep: -#undef MAXPLAYERS // we want 32 players yesss +#undef MAXPLAYERS #define MAXPLAYERS 32 + // overwrite some of those // when not compiling in vanilla compat mode #define SATURNJOIN From 521544f6ba2b4817d86975f1decb8ca8566ac942 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 3 Sep 2026 19:32:48 +0200 Subject: [PATCH 588/589] raise skinlimit to 1024 for phobos build not thoroughly tested by me, so might still be incomplete --- src/byteptr.h | 9 +++++++++ src/d_clisrv.c | 21 ++++++++++++++++++--- src/d_clisrv.h | 10 ++++++++-- src/d_netcmd.c | 8 +++++--- src/doomdef.h | 3 +++ src/doomtype.h | 6 ++++++ src/g_demo.h | 3 ++- src/g_game.c | 2 +- src/g_state.h | 3 ++- src/m_menu.c | 28 ++++++++++++++-------------- src/m_menu.h | 4 ++-- src/p_saveg.c | 32 ++++++++++++++++++++++++++------ src/p_saveg.h | 4 ++-- src/r_skins.c | 12 ++++++------ src/r_skins.h | 6 +++--- 15 files changed, 107 insertions(+), 44 deletions(-) diff --git a/src/byteptr.h b/src/byteptr.h index 0c82e6f40..558235a44 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -206,6 +206,15 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) p += n; \ } while (0) + +#ifdef PHOBOS_BUILD +#define WRITESKIN(p,b) WRITEUINT16(p,b) +#define READSKIN(p) READUINT16(p) +#else +#define WRITESKIN(p,b) WRITEUINT8(p,b) +#define READSKIN(p) READUINT8(p) +#endif + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c61ef182d..5a87b6da0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1125,7 +1125,7 @@ static cl_mode_t cl_mode = CL_SEARCHING; static UINT16 cl_lastcheckedfilecount = 0; // used for full file list // Player name send/load - +#ifndef PHOBOS_BUILD static void CV_SavePlayerNames(UINT8 **p) { INT32 i = 0; @@ -1161,6 +1161,7 @@ static void CV_LoadPlayerNames(UINT8 **p) memcpy(player_names[i], tmp_name, MAXPLAYERNAME+1); } } +#endif static void CL_DrawAddonTypes(void) { @@ -1772,7 +1773,7 @@ static void SV_SendPlayerInfo(INT32 node) // doesent really matter what we put here lel netbuffer->u.playerinfo[0].score = LONG(42069); netbuffer->u.playerinfo[0].timeinserver = SHORT(42069); - netbuffer->u.playerinfo[0].skin = (UINT8)1; // no clue wtf skin 1 is, tails maybe? + netbuffer->u.playerinfo[0].skin = (skinnum_t)1; // no clue wtf skin 1 is, tails maybe? netbuffer->u.playerinfo[0].data = 0; @@ -1817,7 +1818,7 @@ static void SV_SendPlayerInfo(INT32 node) netbuffer->u.playerinfo[i].score = LONG(players[i].score); netbuffer->u.playerinfo[i].timeinserver = SHORT((UINT16)(players[i].jointime / TICRATE)); - netbuffer->u.playerinfo[i].skin = (UINT8)players[i].skin; + netbuffer->u.playerinfo[i].skin = (skinnum_t)players[i].skin; // Extra data // Kart has extra skincolors, so we can't use this @@ -1927,8 +1928,10 @@ static void SV_SendMapIcon(INT32 node) */ static boolean SV_SendServerConfig(INT32 node) { +#ifndef PHOBOS_BUILD INT32 i; UINT8 *p, *op; +#endif boolean waspacketsent; doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); @@ -1946,6 +1949,7 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.gametype = (UINT8)gametype; netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; +#ifndef PHOBOS_BUILD // we fill these structs with FFs so that any players not in game get sent as 0xFFFF // which is nice and easy for us to detect memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins)); @@ -1961,6 +1965,7 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; } +#endif netbuffer->u.servercfg.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); netbuffer->u.servercfg.allownewplayer = cv_allownewplayer.value; @@ -1968,12 +1973,16 @@ static boolean SV_SendServerConfig(INT32 node) memcpy(netbuffer->u.servercfg.server_context, server_context, 8); +#ifdef PHOBOS_BUILD + const size_t len = sizeof(serverconfig_pak); +#else op = p = netbuffer->u.servercfg.varlengthinputs; CV_SavePlayerNames(&p); CV_SaveNetVars(&p, false); const size_t len = sizeof (serverconfig_pak) + (size_t)(p - op); +#endif #ifdef DEBUGFILE if (debugfile) @@ -5414,8 +5423,10 @@ static void PT_ServerRefuse(SINT8 node) // Positive response of client join request static void PT_ServerCFG(SINT8 node) { +#ifndef PHOBOS_BUILD INT32 j; UINT8 *scp; +#endif if (server && serverrunning && node != servernode) { // but wait I thought I'm the server? @@ -5438,8 +5449,10 @@ static void PT_ServerCFG(SINT8 node) if ((gametype = netbuffer->u.servercfg.gametype) >= NUMGAMETYPES) I_Error("Bad gametype %d in cliserv!", gametype); modifiedgame = netbuffer->u.servercfg.modifiedgame; +#ifndef PHOBOS_BUILD for (j = 0; j < MAXPLAYERS; j++) adminplayers[j] = netbuffer->u.servercfg.adminplayers[j]; +#endif memcpy(server_context, netbuffer->u.servercfg.server_context, 8); } @@ -5465,6 +5478,7 @@ static void PT_ServerCFG(SINT8 node) SendSaturnInfo(node); #endif +#ifndef PHOBOS_BUILD memset(playeringame, 0, sizeof(playeringame)); for (j = 0; j < MAXPLAYERS; j++) @@ -5481,6 +5495,7 @@ static void PT_ServerCFG(SINT8 node) scp = netbuffer->u.servercfg.varlengthinputs; CV_LoadPlayerNames(&scp); scp += CV_LoadNetVars(scp); +#endif /// \note Wait. What if a Lua script uses some global custom variables synched with the NetVars hook? /// Shouldn't them be downloaded even at intermission time? diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 29a33e351..16602976c 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -339,13 +339,17 @@ typedef struct UINT8 clientnode; UINT8 gamestate; +#ifndef PHOBOS_BUILD // 0xFF == not in game; else player skin num UINT8 playerskins[MAXPLAYERS]; UINT8 playercolor[MAXPLAYERS]; +#endif UINT8 gametype; UINT8 modifiedgame; +#ifndef PHOBOS_BUILD SINT8 adminplayers[MAXPLAYERS]; // Needs to be signed +#endif char server_context[8]; // Unique context id, generated at server startup. @@ -354,7 +358,9 @@ typedef struct boolean allownewplayer; boolean discordinvites; +#ifndef PHOBOS_BUILD UINT8 varlengthinputs[0]; // Playernames and netvars +#endif } ATTRPACK serverconfig_pak; typedef struct { @@ -444,7 +450,7 @@ typedef struct char name[MAXPLAYERNAME+1]; UINT8 address[4]; // sending another string would run us up against MAXPACKETLENGTH UINT8 team; - UINT8 skin; + skinnum_t skin; UINT8 data; // Color is first four bits, hasflag, isit and issuper have one bit each, the last is unused. UINT32 score; UINT16 timeinserver; // In seconds. @@ -454,7 +460,7 @@ typedef struct typedef struct { char name[MAXPLAYERNAME+1]; - UINT8 skin; + skinnum_t skin; UINT8 color; UINT32 pflags; UINT32 score; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f68837052..f0ebc5fc4 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1689,7 +1689,8 @@ static void SendNameAndColor(UINT8 splitplayer) // Finally write out the complete packet and send it off. WRITESTRINGN(p, playername->zstring, MAXPLAYERNAME); WRITEUINT8(p, (UINT8)playercolor->value); - WRITEUINT8(p, (UINT8)playerskin->value); + WRITESKIN(p, (skinnum_t)playerskin->value); + SendNetXCmdForPlayer(splitplayer, XD_NAMEANDCOLOR, buf, p - buf); } @@ -1697,7 +1698,8 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) { player_t *player; char name[MAXPLAYERNAME+1] = {}; - UINT8 color, skin; + UINT8 color; + skinnum_t skin; #ifdef PARANOIA if (playernum < 0 || playernum > MAXPLAYERS) @@ -1719,7 +1721,7 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) READSTRINGN(*cp, name, MAXPLAYERNAME); color = READUINT8(*cp); - skin = READUINT8(*cp); + skin = READSKIN(*cp); // set name if (player_name_changes[playernum] < MAXNAMECHANGES) diff --git a/src/doomdef.h b/src/doomdef.h index 8b205cf51..5a62d0a86 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -616,6 +616,9 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #undef MAXPLAYERS #define MAXPLAYERS 32 +// raise skinlimit to 1024 +#undef MAXSKINS +#define MAXSKINS 1024 // overwrite some of those // when not compiling in vanilla compat mode diff --git a/src/doomtype.h b/src/doomtype.h index 7d6017e27..2b5319bc2 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -42,6 +42,12 @@ extern "C" { #define INT64 int64_t #define UINT64 uint64_t +#ifdef PHOBOS_BUILD +typedef uint16_t skinnum_t; +#else +typedef uint8_t skinnum_t; +#endif + #ifdef __APPLE_CC__ #define DEBUG_LOG #define NOIPX diff --git a/src/g_demo.h b/src/g_demo.h index 5e430a2e8..280185ce6 100644 --- a/src/g_demo.h +++ b/src/g_demo.h @@ -82,7 +82,8 @@ typedef struct menudemo_s { struct { UINT8 ranking; char name[17]; - UINT8 skin, color; + skinnum_t skin; + UINT8 color; UINT32 timeorscore; } standings[MAXPLAYERS]; } menudemo_t; diff --git a/src/g_game.c b/src/g_game.c index c133050d8..b8c9a2530 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -63,7 +63,7 @@ gameaction_t gameaction = 0; gamestate_t gamestate = GS_NULL; boolean botingame = false; -UINT8 botskin = 0; +skinnum_t botskin = 0; UINT8 botcolor = 0; // SRB2kart diff --git a/src/g_state.h b/src/g_state.h index 02d876d49..fd3d7f062 100644 --- a/src/g_state.h +++ b/src/g_state.h @@ -55,6 +55,7 @@ extern gamestate_t gamestate; extern gameaction_t gameaction; extern boolean botingame; -extern UINT8 botskin, botcolor; +extern skinnum_t botskin; +extern UINT8 botcolor; #endif //__G_STATE__ diff --git a/src/m_menu.c b/src/m_menu.c index d0a2b661e..4a8344b3d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6451,7 +6451,7 @@ static void M_ChooseTimeAttack(INT32 choice) else G_RecordDemo(nameofdemo); - G_DeferedInitNew(false, mapname, (UINT8)(cv_chooseskin.value-1), 0, false); + G_DeferedInitNew(false, mapname, (skinnum_t)(cv_chooseskin.value-1), 0, false); } static void M_HandleStaffReplay(INT32 choice) @@ -7677,7 +7677,7 @@ static void M_DrawMPMainMenu(void) #define iconwidth 32 #define spacingwidth 32 #define incrwidth (iconwidth + spacingwidth) - UINT8 i = 0, pskin, pcol; + UINT16 i = 0, pskin, pcol; // player arrangement width, but there's also a chance i'm a furry, shhhhhh const INT32 paw = iconwidth + 3*incrwidth; INT32 trans = 0; @@ -7930,16 +7930,16 @@ static void M_DrawSetupMultiPlayerMenu(void) spritedef_t *sprdef; spriteframe_t *sprframe; patch_t *patch; - UINT8 frame; - UINT8 speed; - UINT8 weight; - UINT8 i; - UINT8 s, w; + UINT16 frame; + UINT16 speed; + UINT16 weight; + UINT16 i; + UINT16 s, w; INT32 skinnum = 0; INT32 statx, staty; UINT32 speenframe; INT32 sltw, actw, hetw; - UINT8 skintodisplay; + skinnum_t skintodisplay; INT32 nameboxaddy = 0; const UINT8 *flashcol = V_GetStringColormap(highlightflags); @@ -7996,7 +7996,7 @@ static void M_DrawSetupMultiPlayerMenu(void) break; case SKINMENUTYPE_2D: - skintodisplay = setupm_fakeskin; + skintodisplay = (skinnum_t)setupm_fakeskin; if (setupm_skinlockedselect) //show the skin we are trying to select skintodisplay = skinstats[setupm_skinxpos][setupm_skinypos][setupm_skinselect]; else if (skinstatscount[setupm_skinxpos][setupm_skinypos] && itemOn == 1) @@ -8376,7 +8376,7 @@ static void M_DrawSetupMultiPlayerMenu(void) colwidth = colwidth - 10; INT32 j = -colwidth; - INT16 col = setupm_fakecolor - colwidth; + INT32 col = setupm_fakecolor - colwidth; INT32 x = mx; INT32 cw = indexwidth; UINT8 ch; @@ -8404,7 +8404,7 @@ static void M_DrawSetupMultiPlayerMenu(void) { const INT32 icons = 4; INT32 k = -icons; - INT16 col = setupm_fakeskin - icons; + INT32 col = setupm_fakeskin - icons; INT32 x = BASEVIDWIDTH/2 - ((icons+1)*24) - 4; fixed_t scale = FRACUNIT/2; INT32 offx = 8, offy = 8; @@ -8467,7 +8467,7 @@ static void M_DrawSetupMultiPlayerMenu(void) switch (cv_skinselectmenu.value) { case SKINMENUTYPE_2D: - skintodisplay = (UINT8)setupm_fakeskin; + skintodisplay = (skinnum_t)setupm_fakeskin; if (setupm_skinlockedselect) // show the skin we are trying to select skintodisplay = skinstats[setupm_skinxpos][setupm_skinypos][setupm_skinselect]; else if (skinstatscount[setupm_skinxpos][setupm_skinypos] && itemOn == 1) @@ -8475,10 +8475,10 @@ static void M_DrawSetupMultiPlayerMenu(void) break; case SKINMENUTYPE_EXTENDED: case SKINMENUTYPE_GRID: - skintodisplay = ((itemOn == 1 && (setupm_skinselect < numskins)) ? skinsorted[setupm_skinselect] : (UINT8)setupm_fakeskin); + skintodisplay = ((itemOn == 1 && (setupm_skinselect < numskins)) ? skinsorted[setupm_skinselect] : (skinnum_t)setupm_fakeskin); break; default: - skintodisplay = (UINT8)setupm_fakeskin; + skintodisplay = (skinnum_t)setupm_fakeskin; break; } diff --git a/src/m_menu.h b/src/m_menu.h index c8fe7b4c2..2089900e3 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -230,8 +230,8 @@ typedef struct char levelname[32]; UINT8 actnum; UINT8 skincolor; - UINT8 skinnum; - UINT8 botskin; + skinnum_t skinnum; + skinnum_t botskin; UINT8 botcolor; UINT8 numemeralds; INT32 lives; diff --git a/src/p_saveg.c b/src/p_saveg.c index 23967cab1..cde5765c4 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -69,7 +69,7 @@ FUNCINLINE static ATTRINLINE void P_ArchivePlayer(savebuffer_t *save) pllives = 3; // has less than that. WRITEUINT8(save->p, player->skincolor); - WRITEUINT8(save->p, player->skin); + WRITESKIN(save->p, player->skin); WRITEUINT32(save->p, player->score); WRITEINT32(save->p, pllives); @@ -77,7 +77,7 @@ FUNCINLINE static ATTRINLINE void P_ArchivePlayer(savebuffer_t *save) if (botskin) { - WRITEUINT8(save->p, botskin); + WRITESKIN(save->p, botskin); WRITEUINT8(save->p, botcolor); } } @@ -88,7 +88,7 @@ FUNCINLINE static ATTRINLINE void P_ArchivePlayer(savebuffer_t *save) FUNCINLINE static ATTRINLINE void P_UnArchivePlayer(savebuffer_t *save) { savedata.skincolor = READUINT8(save->p); - savedata.skin = READUINT8(save->p); + savedata.skin = READSKIN(save->p); savedata.score = READINT32(save->p); savedata.lives = READINT32(save->p); @@ -96,9 +96,11 @@ FUNCINLINE static ATTRINLINE void P_UnArchivePlayer(savebuffer_t *save) if (savedata.botcolor) { - savedata.botskin = READUINT8(save->p); + savedata.botskin = READSKIN(save->p); + if (savedata.botskin-1 >= numskins) savedata.botskin = 0; + savedata.botcolor = READUINT8(save->p); } else @@ -117,7 +119,9 @@ static void P_NetArchivePlayers(savebuffer_t *save, boolean resending) for (i = 0; i < MAXPLAYERS; i++) { +#ifndef PHOBOS_BUILD if (resending) +#endif WRITESINT8(save->p, (SINT8)adminplayers[i]); if (!playeringame[i]) @@ -127,7 +131,9 @@ static void P_NetArchivePlayers(savebuffer_t *save, boolean resending) // no longer send ticcmds +#ifndef PHOBOS_BUILD if (resending) +#endif WRITESTRINGN(save->p, player_names[i], MAXPLAYERNAME); const player_t *player = &players[i]; @@ -156,11 +162,16 @@ static void P_NetArchivePlayers(savebuffer_t *save, boolean resending) WRITEUINT16(save->p, player->flashpal); WRITEUINT16(save->p, player->flashcount); +#ifdef PHOBOS_BUILD + WRITEUINT8(save->p, player->skincolor); + WRITEINT32(save->p, player->skin); +#else if (resending) { WRITEUINT8(save->p, player->skincolor); WRITEINT32(save->p, player->skin); } +#endif WRITEUINT32(save->p, player->score); WRITEFIXED(save->p, player->dashspeed); @@ -309,7 +320,9 @@ static void P_NetUnArchivePlayers(savebuffer_t *save, boolean reloading) for (i = 0; i < MAXPLAYERS; i++) { +#ifndef PHOBOS_BUILD if (reloading) +#endif adminplayers[i] = (INT32)READSINT8(save->p); // Do NOT memset player struct to 0 @@ -320,7 +333,9 @@ static void P_NetUnArchivePlayers(savebuffer_t *save, boolean reloading) // NOTE: sending tics should (hopefully) no longer be necessary +#ifndef PHOBOS_BUILD if (reloading) +#endif READSTRINGN(save->p, player_names[i], MAXPLAYERNAME); player_t *player = &players[i]; @@ -349,11 +364,16 @@ static void P_NetUnArchivePlayers(savebuffer_t *save, boolean reloading) player->flashpal = READUINT16(save->p); player->flashcount = READUINT16(save->p); +#ifdef PHOBOS_BUILD + player->skincolor = READUINT8(save->p); + player->skin = READINT32(save->p); +#else if (reloading) { player->skincolor = READUINT8(save->p); player->skin = READINT32(save->p); } +#endif player->score = READUINT32(save->p); player->dashspeed = READFIXED(save->p); // dashing speed @@ -1304,7 +1324,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 if (diff2 & MD2_CVMEM) WRITEINT32(save->p, mobj->cvmem); if (diff2 & MD2_SKIN) - WRITEUINT8(save->p, (UINT8)((skin_t *)mobj->skin - skins)); + WRITESKIN(save->p, (skinnum_t)((skin_t *)mobj->skin - skins)); if (diff2 & MD2_COLOR) WRITEUINT8(save->p, mobj->color); if (diff2 & MD2_EXTVAL1) @@ -2165,7 +2185,7 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) if (diff2 & MD2_CVMEM) mobj->cvmem = READINT32(save->p); if (diff2 & MD2_SKIN) - mobj->skin = &skins[READUINT8(save->p)]; + mobj->skin = &skins[READSKIN(save->p)]; if (diff2 & MD2_COLOR) mobj->color = READUINT8(save->p); if (diff2 & MD2_EXTVAL1) diff --git a/src/p_saveg.h b/src/p_saveg.h index 9a0e26c39..5aaece4e9 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -24,8 +24,8 @@ typedef struct { UINT8 skincolor; - UINT8 skin; - UINT8 botskin; + skinnum_t skin; + skinnum_t botskin; UINT8 botcolor; INT32 score; INT32 lives; diff --git a/src/r_skins.c b/src/r_skins.c index 181fd3319..a8496c7f5 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -42,8 +42,8 @@ INT32 numallskins = 0; INT32 numlocalskins = 0; skin_t skins[MAXSKINS]; -UINT8 skinstats[9][9][MAXSKINS]; -UINT8 skinstatscount[9][9] = { +skinnum_t skinstats[9][9][MAXSKINS]; +skinnum_t skinstatscount[9][9] = { {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0}, @@ -55,7 +55,7 @@ UINT8 skinstatscount[9][9] = { {0, 0, 0, 0, 0, 0, 0, 0, 0} }; -UINT8 skinsorted[MAXSKINS] = {}; +skinnum_t skinsorted[MAXSKINS] = {}; skin_t localskins[MAXLOCALSKINS] = {}; skin_t allskins[MAXSKINS+MAXLOCALSKINS] = {}; @@ -398,8 +398,8 @@ static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) static int skinSortFunc(const void *a, const void *b) // tbh i have no clue what the naming conventions for local functions are { int diff = 0; - const UINT8 val_a = *(const UINT8 *)a; - const UINT8 val_b = *(const UINT8 *)b; + const skinnum_t val_a = *(const skinnum_t *)a; + const skinnum_t val_b = *(const skinnum_t *)b; const skin_t *in1 = &skins[val_a]; const skin_t *in2 = &skins[val_b]; @@ -474,7 +474,7 @@ static int skinSortFunc(const void *a, const void *b) // tbh i have no clue what void sortSkinGrid(void) { //CONS_Printf("Sorting skin list (%d)...\n", cv_skinselectgridsort.value); - qs22j(skinsorted, numskins, sizeof(UINT8), skinSortFunc); + qs22j(skinsorted, numskins, sizeof(skinnum_t), skinSortFunc); } // diff --git a/src/r_skins.h b/src/r_skins.h index 929753855..d3e196827 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -71,9 +71,9 @@ extern INT32 numskins; extern INT32 numlocalskins; extern INT32 numallskins; extern skin_t skins[MAXSKINS]; -extern UINT8 skinstats[9][9][MAXSKINS]; -extern UINT8 skinstatscount[9][9]; -extern UINT8 skinsorted[MAXSKINS]; +extern skinnum_t skinstats[9][9][MAXSKINS]; +extern skinnum_t skinstatscount[9][9]; +extern skinnum_t skinsorted[MAXSKINS]; extern skin_t localskins[MAXLOCALSKINS]; extern skin_t allskins[MAXSKINS+MAXLOCALSKINS]; From 242754f8119f53924b0beed470dc989e80023dab Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 12 Sep 2026 16:53:14 +0200 Subject: [PATCH 589/589] disable flat precaching in opengl in encoremode this appears to mess up remapping behavior in certain cases (ex. sneaker/spring panels) since i cba looking into properly fixing this, ill just disable this for now --- src/hardware/hw_cache.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 423a75b32..13354bda4 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -624,13 +624,26 @@ static void HWR_PrecacheLevelFlats(void) { // lookup for flats that may´ve been already loaded flatcheck flatpresent; - size_t i, j; + size_t i; +#if 0 + size_t j; +#endif INT32 k; + // this kinda messes up encore remapping behavior at times + // so just disable it for now ig +#ifdef GLENCORE + if (encoremap) + { + return; + } +#endif + flatcheck_init(&flatpresent); flatcheck_reserve(&flatpresent, numlevelflats); // special case for encore +#if 0 #ifdef GLENCORE if (encoremap) { @@ -670,6 +683,7 @@ static void HWR_PrecacheLevelFlats(void) } } else +#endif #endif { // on non encore we have it simple @@ -1315,6 +1329,7 @@ void HWR_SetPalette(RGBA_t *palette) crushed_palette[i].s.blue = (UINT8)(fblue / 31.0f * 255.0f); crushed_palette[i].s.alpha = 255; } + GL_SetScreenPalette(crushed_palette); } else @@ -1392,6 +1407,7 @@ void HWR_SetMapPalette(void) I_Error("HWR_SetMapPalette: A programmer assumed palette lumps are at least 768 bytes long, but apparently this was a wrong assumption!\n"); RGB_data = (UINT8 *)(W_CacheLumpNum(lumpnum, PU_CACHE)); + // we got the RGB palette now, but we need it in RGBA format. for (i = 0; i < 256; i++) { @@ -1400,6 +1416,7 @@ void HWR_SetMapPalette(void) RGBA_converted[i].s.blue = *(RGB_data++); RGBA_converted[i].s.alpha = 255; } + palette = RGBA_converted; } @@ -1407,6 +1424,7 @@ void HWR_SetMapPalette(void) if (memcmp(mapPalette, palette, sizeof(mapPalette))) { memcpy(mapPalette, palette, sizeof(mapPalette)); + // in palette rendering mode, this means that all rgba textures now have wrong colors // and the lookup table is outdated HWR_SetPaletteLookup(mapPalette);